From: Peter Xu <peterx@redhat.com>
To: Mattias Nissler <mnissler@rivosinc.com>
Cc: qemu-devel@nongnu.org, john.levon@nutanix.com,
stefanha@redhat.com,
"Richard Henderson" <richard.henderson@linaro.org>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Jagannathan Raman" <jag.raman@oracle.com>,
"David Hildenbrand" <david@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v4 2/5] softmmu: Support concurrent bounce buffers
Date: Tue, 19 Sep 2023 13:14:09 -0400 [thread overview]
Message-ID: <ZQnW4e1wordu4UbM@x1n> (raw)
In-Reply-To: <20230919160814.3343727-3-mnissler@rivosinc.com>
On Tue, Sep 19, 2023 at 09:08:10AM -0700, Mattias Nissler wrote:
> @@ -3119,31 +3143,35 @@ void *address_space_map(AddressSpace *as,
> void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,
> bool is_write, hwaddr access_len)
> {
> - if (buffer != as->bounce.buffer) {
> - MemoryRegion *mr;
> - ram_addr_t addr1;
> + MemoryRegion *mr;
> + ram_addr_t addr1;
> +
> + mr = memory_region_from_host(buffer, &addr1);
> + if (mr == NULL) {
> + BounceBuffer *bounce = container_of(buffer, BounceBuffer, buffer);
> + assert(bounce->magic == BOUNCE_BUFFER_MAGIC);
>
> - mr = memory_region_from_host(buffer, &addr1);
> - assert(mr != NULL);
> if (is_write) {
> - invalidate_and_set_dirty(mr, addr1, access_len);
> - }
> - if (xen_enabled()) {
> - xen_invalidate_map_cache_entry(buffer);
> + address_space_write(as, bounce->addr, MEMTXATTRS_UNSPECIFIED,
> + bounce->buffer, access_len);
> }
> - memory_region_unref(mr);
> +
> + memory_region_unref(bounce->mr);
> + qatomic_sub(&as->bounce_buffer_size, bounce->len);
> + /* Write bounce_buffer_size before reading map_client_list. */
> + smp_mb();
> + address_space_notify_map_clients(as);
> + bounce->magic = ~BOUNCE_BUFFER_MAGIC;
> + g_free(bounce);
> return;
> }
> +
> + if (xen_enabled()) {
> + xen_invalidate_map_cache_entry(buffer);
> + }
> if (is_write) {
> - address_space_write(as, as->bounce.addr, MEMTXATTRS_UNSPECIFIED,
> - as->bounce.buffer, access_len);
> - }
> - qemu_vfree(as->bounce.buffer);
> - as->bounce.buffer = NULL;
> - memory_region_unref(as->bounce.mr);
This line needs to be kept?
> - /* Clear in_use before reading map_client_list. */
> - qatomic_set_mb(&as->bounce.in_use, false);
> - address_space_notify_map_clients(as);
> + invalidate_and_set_dirty(mr, addr1, access_len);
> + }
> }
--
Peter Xu
next prev parent reply other threads:[~2023-09-19 17:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 16:08 [PATCH v4 0/5] Support message-based DMA in vfio-user server Mattias Nissler
2023-09-19 16:08 ` [PATCH v4 1/5] softmmu: Per-AddressSpace bounce buffering Mattias Nissler
2023-09-19 17:12 ` Peter Xu
2023-09-19 16:08 ` [PATCH v4 2/5] softmmu: Support concurrent bounce buffers Mattias Nissler
2023-09-19 17:14 ` Peter Xu [this message]
2023-09-19 18:14 ` Mattias Nissler
2023-09-19 16:08 ` [PATCH v4 3/5] Update subprojects/libvfio-user Mattias Nissler
2023-09-19 16:08 ` [PATCH v4 4/5] vfio-user: Message-based DMA support Mattias Nissler
2023-09-19 16:08 ` [PATCH v4 5/5] vfio-user: Fix config space access byte order Mattias Nissler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQnW4e1wordu4UbM@x1n \
--to=peterx@redhat.com \
--cc=david@redhat.com \
--cc=elena.ufimtseva@oracle.com \
--cc=jag.raman@oracle.com \
--cc=john.levon@nutanix.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mnissler@rivosinc.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).