Received: from eggs.gnu.org ([2001:4830:134:3::10]:45478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWEZ1-0001p1-9o for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:39:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWEYv-0004bt-4l for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:38:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWEYu-0004bl-U6 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:38:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2D1cqgi022094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 12 Mar 2015 21:38:52 -0400 From: Fam Zheng Date: Fri, 13 Mar 2015 09:38:42 +0800 Message-Id: <1426210723-16735-4-git-send-email-famz@redhat.com> In-Reply-To: <1426210723-16735-1-git-send-email-famz@redhat.com> References: <1426210723-16735-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 3/4] exec: Notify cpu_register_map_client caller if the bounce buffer is available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini The caller's workflow is like if (!address_space_map()) { ... cpu_register_map_client(); } If bounce buffer became available after address_space_map() but before cpu_register_map_client(), the caller could miss it and has to wait for the next bounce buffer uesr to release, which may never happen in the worse case. Just notify the caller with the passed callback in cpu_register_map_client(). Signed-off-by: Fam Zheng --- exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exec.c b/exec.c index 93ccd5a..82781e4 100644 --- a/exec.c +++ b/exec.c @@ -2502,6 +2502,9 @@ void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)) client->opaque = opaque; client->callback = callback; QSLIST_INSERT_HEAD_ATOMIC(&map_client_list, client, link); + if (!atomic_read(&bounce.in_use)) { + callback(opaque); + } return client; } -- 1.9.3