From patchwork Tue Mar 28 11:09:34 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: 96144 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp269694obc; Tue, 28 Mar 2017 04:16:16 -0700 (PDT) X-Received: by 10.55.74.132 with SMTP id x126mr7805256qka.6.1490699776429; Tue, 28 Mar 2017 04:16:16 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z19si3165435qtb.278.2017.03.28.04.16.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 28 Mar 2017 04:16:16 -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]:52451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp6l-0000o2-Uh for patch@linaro.org; Tue, 28 Mar 2017 07:16:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0S-0004Gw-3y for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0Q-00037y-GE for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:34529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0Q-00037S-9p for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:42 -0400 Received: by mail-wr0-x22a.google.com with SMTP id l43so98994392wre.1 for ; Tue, 28 Mar 2017 04:09:42 -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=Ogyi5kz7Ku3eSPaW3zIGslmVSlz8ocnWz5FUjkgwixI=; b=Ufv5u5CTKVAqv5cidgY53QVOLcPwwJCKrUKnp+06/LfguCPMkPKUZr7OOF4TO5hHgS IQ9J296n/UZXbH2AJLbM3HaPXmfAHzDdD5R3w4A/XdvmtdvJPhshueLDOSUYuNg3bTeK PixOV1RncS7D6Taz5rU6K0fQs9v5V/MkZbd8c= 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=Ogyi5kz7Ku3eSPaW3zIGslmVSlz8ocnWz5FUjkgwixI=; b=S+LwfscKF7DXZWZtDvj229N3apBfOlD0Zc2j/vXI6SN3ZosdbEwbElLi86ejOSUZ7I W4ZopcJvlD2Jpq4efoqGJBWhlRYCAaaQyeWYtcgkaU+aAOp87jMTSwLBLwj0s/l7kW6d mv9MZvQivuJj0AU953Do6RNoE8lhoVavECZPX9NclGFf5FG3R2/gfBcQm3XI469/udME ybjnpVD15C9LKU2G8KEYabWVN/DN+kesU2ns8L8jT8p9f/hFpBe06B4DjVjCeFqdUm/U Dw6qSA/PzcwdQT6AWaZJAUrWgWsSpkEMapTf+cTrehxyd5vLOOA0YKyKA9A7BpDWExsh ovoQ== X-Gm-Message-State: AFeK/H2SzwneHyc04En7nNd7ugPdUwDCh/UuB7x0d96FAi2LHp+R2QN/HEodXfiCkMTf1lME X-Received: by 10.223.133.182 with SMTP id 51mr26270192wrt.39.1490699381204; Tue, 28 Mar 2017 04:09:41 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k139sm3187013wmg.11.2017.03.28.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 93A183E0632; Tue, 28 Mar 2017 12:09:36 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:34 +0100 Message-Id: <20170328110936.24806-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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::22a Subject: [Qemu-devel] [PULL 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Gerd Hoffmann 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 Reviewed-by: Paolo Bonzini Reviewed-by: Gerd Hoffmann --- 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); }