From nobody Mon Feb 9 13:59:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623109191; cv=none; d=zohomail.com; s=zohoarc; b=ILjf1Ias8ksgR/KLdeiVaiJAYlDMUHRdrjf6JRbpv8J0FnSi/rvFCuwJu69AXZG3g+CFv3etsd/kS5PP+0bUIOFtcGY80YEAqwkd1lH/vOVyTvtLB4Md5GZXGNZuXNcgakpHB5USvkz+Av/V7len0TmMoq8SSxldOPm8BvxvIq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623109191; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=StuWFobsXpW1fr8O4GtTztRomqi0p4FNs6VW0HyIqDI=; b=Jz8HWqh2F9s2FeoGpj8DjUNvZJr3fi3rwIiXBG15zPs3at9IUjobgovDIK1bpe5ZazKt4zUdthStmaCIfmkNH/ipDP21Vo6JQB8SuJNKtAXP0s/kt6q/t70bSitQ/+SH7iogZHHzIlHyJCY5U69B27v5hiuj2SHfLjQvA6WCMIY= ARC-Authentication-Results: i=1; mx.zohomail.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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623109191333936.8519027180288; Mon, 7 Jun 2021 16:39:51 -0700 (PDT) Received: from localhost ([::1]:37490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqOqU-0003cO-AE for importer@patchew.org; Mon, 07 Jun 2021 19:39:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqOoy-0001bq-Rk for qemu-devel@nongnu.org; Mon, 07 Jun 2021 19:38:16 -0400 Received: from mga06.intel.com ([134.134.136.31]:2273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqOow-00071e-R1 for qemu-devel@nongnu.org; Mon, 07 Jun 2021 19:38:16 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 16:38:03 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 16:38:03 -0700 IronPort-SDR: LXuayxLVuqC+5EGJnn5hfGn8zYeH/FmPxOVu7CsMroEe7SMjq2RYPK86j5ApsGKiOBsWODmH6K DtZxMxK8UqSw== X-IronPort-AV: E=McAfee;i="6200,9189,10008"; a="265889552" X-IronPort-AV: E=Sophos;i="5.83,256,1616482800"; d="scan'208";a="265889552" IronPort-SDR: l/zINiWlQKZnIy7XNYBSXINVDPjE0kB8I2pyusHylyqARwZrLVHH3YEsJ65m1KPMsxloBwCoLu bvQWGJzEXxHg== X-IronPort-AV: E=Sophos;i="5.83,256,1616482800"; d="scan'208";a="551403362" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v1 5/5] virtio-gpu: Make resource_flush wait on the sync object for blobs Date: Mon, 7 Jun 2021 16:25:30 -0700 Message-Id: <20210607232530.454435-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607232530.454435-1-vivek.kasireddy@intel.com> References: <20210607232530.454435-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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=134.134.136.31; envelope-from=vivek.kasireddy@intel.com; helo=mga06.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dongwon Kim , Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" To make sure that the Guest would not use the backing storage associated with a blob resource before or at the same time when the Host does a blit with it, resource_flush needs to wait on the sync object associated with the blob. Doing this would prevent tearing/flickering or other issues when using blob resources. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim --- hw/display/virtio-gpu-udmabuf.c | 28 ++++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 1 + include/hw/virtio/virtio-gpu.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index 33e329e8aa..8c1b6f8763 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -167,6 +167,34 @@ static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUD= MABuf *dmabuf) g_free(dmabuf); } =20 +static VGPUDMABuf +*virtio_gpu_find_dmabuf(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + VGPUDMABuf *dmabuf, *tmp; + + QTAILQ_FOREACH_SAFE(dmabuf, &g->dmabuf.bufs, next, tmp) { + if (dmabuf->buf.fd =3D=3D res->dmabuf_fd) { + return dmabuf; + } + } + + return NULL; +} + +void virtio_gpu_resource_wait_sync(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + struct virtio_gpu_scanout *scanout; + VGPUDMABuf *dmabuf; + + dmabuf =3D virtio_gpu_find_dmabuf(g, res); + if (dmabuf && dmabuf->buf.sync) { + scanout =3D &g->parent_obj.scanout[dmabuf->scanout_id]; + dpy_gl_wait_dmabuf(scanout->con, &dmabuf->buf); + } +} + static VGPUDMABuf *virtio_gpu_create_dmabuf(VirtIOGPU *g, uint32_t scanout_id, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 4d549377cb..dd037137e9 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -523,6 +523,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, console_has_gl(scanout->con)) { dpy_gl_update(scanout->con, 0, 0, scanout->width, scanout->height); + virtio_gpu_resource_wait_sync(g, res); return; } } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index bcf54d970f..9b9b499d06 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -274,6 +274,8 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, uint32_t scanout_id, struct virtio_gpu_simple_resource *res, struct virtio_gpu_framebuffer *fb); +void virtio_gpu_resource_wait_sync(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); =20 /* virtio-gpu-3d.c */ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, --=20 2.30.2