From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LOvaQ-0006qx-LW for qemu-devel@nongnu.org; Mon, 19 Jan 2009 09:58:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LOvaP-0006qh-S4 for qemu-devel@nongnu.org; Mon, 19 Jan 2009 09:58:46 -0500 Received: from [199.232.76.173] (port=33088 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOvaP-0006qe-OP for qemu-devel@nongnu.org; Mon, 19 Jan 2009 09:58:45 -0500 Received: from yw-out-1718.google.com ([74.125.46.152]:32177) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LOvaP-0000KZ-9C for qemu-devel@nongnu.org; Mon, 19 Jan 2009 09:58:45 -0500 Received: by yw-out-1718.google.com with SMTP id 6so1138672ywa.82 for ; Mon, 19 Jan 2009 06:58:44 -0800 (PST) Message-ID: <49749518.90308@codemonkey.ws> Date: Mon, 19 Jan 2009 08:58:32 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1232308399-21679-1-git-send-email-avi@redhat.com> <1232308399-21679-3-git-send-email-avi@redhat.com> In-Reply-To: <1232308399-21679-3-git-send-email-avi@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/5] Add map client retry notification Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org Avi Kivity wrote: > The target memory mapping API may fail if the bounce buffer resources > are exhausted. Add a notification mechanism to allow clients to retry > the mapping operation when resources become available again. > > Signed-off-by: Avi Kivity > Fantastic! Clearly, I should have read the next patch before responding to the first. Regards, Anthony Liguori > --- > cpu-all.h | 3 +++ > exec.c | 38 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 41 insertions(+), 0 deletions(-) > > diff --git a/cpu-all.h b/cpu-all.h > index 3439999..67e795e 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -928,6 +928,9 @@ void *cpu_physical_memory_map(target_phys_addr_t addr, > int is_write); > void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, > int is_write); > +void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)); > +void cpu_unregister_map_client(void *cookie); > + > uint32_t ldub_phys(target_phys_addr_t addr); > uint32_t lduw_phys(target_phys_addr_t addr); > uint32_t ldl_phys(target_phys_addr_t addr); > diff --git a/exec.c b/exec.c > index 7162271..62bedc0 100644 > --- a/exec.c > +++ b/exec.c > @@ -3053,6 +3053,43 @@ typedef struct { > > static BounceBuffer bounce; > > +typedef struct MapClient { > + void *opaque; > + void (*callback)(void *opaque); > + LIST_ENTRY(MapClient) link; > +} MapClient; > + > +static LIST_HEAD(map_client_list, MapClient) map_client_list > + = LIST_HEAD_INITIALIZER(map_client_list); > + > +void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)) > +{ > + MapClient *client = qemu_malloc(sizeof(*client)); > + > + client->opaque = opaque; > + client->callback = callback; > + LIST_INSERT_HEAD(&map_client_list, client, link); > + return client; > +} > + > +void cpu_unregister_map_client(void *_client) > +{ > + MapClient *client = (MapClient *)_client; > + > + LIST_REMOVE(client, link); > +} > + > +static void cpu_notify_map_clients(void) > +{ > + MapClient *client; > + > + while (!LIST_EMPTY(&map_client_list)) { > + client = LIST_FIRST(&map_client_list); > + client->callback(client->opaque); > + LIST_REMOVE(client, link); > + } > +} > + > void *cpu_physical_memory_map(target_phys_addr_t addr, > target_phys_addr_t *plen, > int is_write) > @@ -3137,6 +3174,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, > } > qemu_free(bounce.buffer); > bounce.buffer = NULL; > + cpu_notify_map_clients(); > } > > /* warning: addr must be aligned */ >