From patchwork Tue Mar 28 08:36:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 96115 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1602165qgd; Tue, 28 Mar 2017 01:40:46 -0700 (PDT) X-Received: by 10.200.37.208 with SMTP id f16mr24070092qtf.118.1490690446886; Tue, 28 Mar 2017 01:40:46 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 33si2904936qku.316.2017.03.28.01.40.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 28 Mar 2017 01:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csmgI-0002c8-G5 for patch@linaro.org; Tue, 28 Mar 2017 04:40:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csmcA-0008GY-IG for qemu-devel@nongnu.org; Tue, 28 Mar 2017 04:36:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csmc9-00015z-Fs for qemu-devel@nongnu.org; Tue, 28 Mar 2017 04:36:30 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:34775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csmc9-00015R-AN for qemu-devel@nongnu.org; Tue, 28 Mar 2017 04:36:29 -0400 Received: by mail-wr0-x232.google.com with SMTP id l43so92602043wre.1 for ; Tue, 28 Mar 2017 01:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lLQqSMJCk0I/TFhPrU94g2NRUMy855zAUX4c+qVRZBc=; b=BOihpOuNYo0CmOVP5OOaxd5+YEngEr4qgmTo86sao9HSSA9WHjW7RydllyGzkHAbWi XzQONi+LneQiptGwfQVS6czeRpN7swAEI9Hs56R3fUAklOqKZkyhHCgfLiOVDSSjZle0 rMygiVgo+PtOVwlICVsmACKixHWw+XAeepdRg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lLQqSMJCk0I/TFhPrU94g2NRUMy855zAUX4c+qVRZBc=; b=el03gfv3hA7I8jMr1ZvOTlyNKO3uf5ui1Ax9cr+W7t5L6WaGLi4O3du0eg00PnFnD+ YPv1WvIOaQU2A1K2I5LuUkShm7KyOh9jFq2Ja4T1fVdlGRIVWus+5AUTLt/HfMSYAL6K wz2yg8+ibsoLqUC+ISa8nSWtaxIKWwDw0DyMCJFDkWs/pVwlmmWe25q9cqIBxQU8+vUX ZvYrhv9a+/rOA0Y7LkI5qDmlX3QEQGbMZppMtSrSDlbLRbBfZ89mx4abyKWnA0zNNNOJ YfDuas04X2yP3Y9Weimym8f6/ncfMSJWwNji6VxIZwow4J3Pw7qByXRGcjGgzFSyr3Dt JLIg== X-Gm-Message-State: AFeK/H2J0iKEeeQt0vEe6x+tk42Eo89UNd8/1adXcB3750x7GkAEVNDOB51hWSWZ6O2KBWav X-Received: by 10.223.176.204 with SMTP id j12mr26517984wra.10.1490690188120; Tue, 28 Mar 2017 01:36:28 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o15sm3854931wra.61.2017.03.28.01.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 01:36:25 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 747533E0632; Tue, 28 Mar 2017 09:36:23 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net, pbonzini@redhat.com, kraxel@redhat.com Date: Tue, 28 Mar 2017 09:36:21 +0100 Message-Id: <20170328083623.10396-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328083623.10396-1-alex.bennee@linaro.org> References: <20170328083623.10396-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 Subject: [Qemu-devel] [PATCH v2 4/6] ui/console: use exclusive mechanism directly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@listserver.greensocs.com, nikunj@linux.vnet.ibm.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, bobby.prani@gmail.com, =?utf-8?q?Alex_Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The previous commit (8bb93c6f99) using async_safe_run_on_cpu() doesn't work on graphics sub-system which restrict which threads can do GUI updates. Rather the special casing MacOS we just directly call the helper and move all the exclusive handling into do_dafe_dpy_refresh(). The unfortunate bouncing of the BQL is to ensure there is no deadlock as vCPUs waiting on the BQL are kicked into their quiescent state. Signed-off-by: Alex Bennée --- ui/console.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 2.11.0 diff --git a/ui/console.c b/ui/console.c index dd27c9501b..419b098c11 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1576,19 +1576,22 @@ bool dpy_gfx_check_format(QemuConsole *con, } /* - * Safe DPY refresh for TCG guests. This runs when the TCG vCPUs are - * quiescent so we can avoid races between dirty page tracking for - * direct frame-buffer access by the guest. + * Safe DPY refresh for TCG guests. We use the exclusive mechanism to + * ensure the TCG vCPUs are quiescent so we can avoid races between + * dirty page tracking for direct frame-buffer access by the guest. * * This is a temporary stopgap until we've fixed the dirty tracking * races in display adapters. */ -static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque) +static void do_safe_dpy_refresh(DisplayChangeListener *dcl) { - DisplayChangeListener *dcl = opaque.host_ptr; + qemu_mutex_unlock_iothread(); + start_exclusive(); qemu_mutex_lock_iothread(); dcl->ops->dpy_refresh(dcl); qemu_mutex_unlock_iothread(); + end_exclusive(); + qemu_mutex_lock_iothread(); } static void dpy_refresh(DisplayState *s) @@ -1598,8 +1601,7 @@ static void dpy_refresh(DisplayState *s) QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { if (tcg_enabled()) { - async_safe_run_on_cpu(first_cpu, do_safe_dpy_refresh, - RUN_ON_CPU_HOST_PTR(dcl)); + do_safe_dpy_refresh(dcl); } else { dcl->ops->dpy_refresh(dcl); }