From nobody Mon Nov 25 05:18:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1717022676; cv=none; d=zohomail.com; s=zohoarc; b=XC+3C4gQDxJF4PGYdhfyELbEpIauSy8FzCxZxw7fqvLw0PozUC+g2/o/4rmqb6P3zNSpVIFQdFEqLNw/oA9BsIALRMdlD7MLE1A+dn5JBzoUTFUZwEcrAhDiTA5fSwjov7ODZohcT3xBWnWePdRN5LrjXg/WqucD7LPYXXbnX5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717022676; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=9hgADU9ovD4qEgIsMBhAKR/XjzFBC7Gt1TDTdKzXrXo=; b=QSePQhloGgzX8ubXxGP8+HhPtHLLPGKpmcN1CRFtwMyAhfN3RPU5sAj1/vyqh5VYf1Kd1Hdw17QDHDmBiLqgoxM/01lqCMEx81WLS5NLN/6l70d6I1WXClTiXVazZ8d2zf9Lk/LFqaDv5masl4HTDTiciD1UN4mgHr/LxqK/17A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717022676065309.4739653344102; Wed, 29 May 2024 15:44:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCS1F-0000qT-3D; Wed, 29 May 2024 18:43:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCS1D-0000q6-74 for qemu-devel@nongnu.org; Wed, 29 May 2024 18:43:39 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCS1A-0003RR-CE for qemu-devel@nongnu.org; Wed, 29 May 2024 18:43:38 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2024 15:43:31 -0700 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by fmviesa006.fm.intel.com with ESMTP; 29 May 2024 15:43:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717022617; x=1748558617; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=o6eJoGEQ4cHDf0gdjpwQZU0x3c/RoKpA2c+dWeUMxvQ=; b=TsRNcMLKhsR7aBB82Hra8lOoTipS8lCX1uAOprQwx6rM7nJZxXW3Gkpz doPbyvNRyXO3h6OEWFeUpl4wtkTDza/rXIcmxrroBn9uBfua2iaHEA0ug Q9JUYq5dM3Aum/xgYn9cC/hlVol7/H+CoFaOGqvYIfwyH4R2lPLbwPhGq 3xvQ8xHR+7L1YDPUNgdoO6dLSner8p1LYGdXfz0iqNBxBfRlKKma7CU7r rEHgaZCGcP8TdHxYa/pjwS74oJlulHYwCWTRQK/dA+y0aUzxB/e1FEfoC WoRidFr9agEEtPSnytw6XRLEN65fIzG/bwOP8r4dyPLGdxLeVyRf17leW Q==; X-CSE-ConnectionGUID: I2tTRlT+RSy734jOQj2njQ== X-CSE-MsgGUID: MZyXvLcXQAizTgVFV8jf5g== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="17254099" X-IronPort-AV: E=Sophos;i="6.08,199,1712646000"; d="scan'208";a="17254099" X-CSE-ConnectionGUID: GzZu+FxqRzi694/eW8w2oA== X-CSE-MsgGUID: LlyM9BTJT3WGHu8/oL+ZIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,199,1712646000"; d="scan'208";a="35633795" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Subject: [PATCH] ui/gtk: Wait until the current guest frame is rendered before switching to RUN_STATE_SAVE_VM Date: Wed, 29 May 2024 15:42:52 -0700 Message-Id: <20240529224252.80395-1-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.15; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.036, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1717022677311100001 From: Dongwon Make sure rendering of the current frame is finished before switching the run state to RUN_STATE_SAVE_VM by waiting for egl-sync object to be signaled. Cc: Marc-Andr=C3=A9 Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/egl-helpers.c | 2 -- ui/gtk.c | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 99b2ebbe23..dafeb36074 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -396,8 +396,6 @@ void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf) fence_fd =3D eglDupNativeFenceFDANDROID(qemu_egl_display, sync); qemu_dmabuf_set_fence_fd(dmabuf, fence_fd); - eglDestroySyncKHR(qemu_egl_display, sync); - qemu_dmabuf_set_sync(dmabuf, NULL); } } =20 diff --git a/ui/gtk.c b/ui/gtk.c index 93b13b7a30..cf0dd6abed 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -600,9 +600,12 @@ void gd_hw_gl_flushed(void *vcon) =20 fence_fd =3D qemu_dmabuf_get_fence_fd(dmabuf); if (fence_fd >=3D 0) { + void *sync =3D qemu_dmabuf_get_sync(dmabuf); qemu_set_fd_handler(fence_fd, NULL, NULL, NULL); close(fence_fd); qemu_dmabuf_set_fence_fd(dmabuf, -1); + eglDestroySyncKHR(qemu_egl_display, sync); + qemu_dmabuf_set_sync(dmabuf, NULL); graphic_hw_gl_block(vc->gfx.dcl.con, false); } } @@ -682,6 +685,22 @@ static const DisplayGLCtxOps egl_ctx_ops =3D { static void gd_change_runstate(void *opaque, bool running, RunState state) { GtkDisplayState *s =3D opaque; + QemuDmaBuf *dmabuf; + int i; + + if (state =3D=3D RUN_STATE_SAVE_VM) { + for (i =3D 0; i < s->nb_vcs; i++) { + VirtualConsole *vc =3D &s->vc[i]; + dmabuf =3D vc->gfx.guest_fb.dmabuf; + if (dmabuf && qemu_dmabuf_get_fence_fd(dmabuf) >=3D 0) { + /* wait for the rendering to be completed */ + eglClientWaitSync(qemu_egl_display, + qemu_dmabuf_get_sync(dmabuf), + EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, + 1000000000); + } + } + } =20 gd_update_caption(s); } --=20 2.34.1