From patchwork Thu Jun 10 22:48:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 12314245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A7D2C48BD1 for ; Thu, 10 Jun 2021 23:02:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55FBF61287 for ; Thu, 10 Jun 2021 23:02:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55FBF61287 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrThH-0001zM-GS for qemu-devel@archiver.kernel.org; Thu, 10 Jun 2021 19:02:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg8-0007hm-DP for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:36 -0400 Received: from mga17.intel.com ([192.55.52.151]:53003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg6-0007CA-7U for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:36 -0400 IronPort-SDR: pJrEjXBoqu0HzN6itOGIpeF02GMAPRXxmh0KFWmDs+5vwrTJFqzizxijKtgNJEg07Uwcge6yex 4beOsR0ML7hw== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796186" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796186" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: M7v2seMkRiBr2B3RaJ3ziTPItiPTNWcGPnwDBBkBJv2VG6jLfj98ars5jTKUT+72YrUaqR/dVu 6bT1nGJ6yu/w== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888377" Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 7/8] virtio-gpu: Add dmabuf helpers for synchronization Date: Thu, 10 Jun 2021 15:48:36 -0700 Message-Id: <20210610224837.670192-8-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.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: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" These helpers will be used in the next subsequent patches to wait until a dmabuf object (via a texture) has been used by the UI to render and submit its buffer. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- hw/display/virtio-gpu-udmabuf.c | 28 ++++++++++++++++++++++++++++ include/hw/virtio/virtio-gpu.h | 2 ++ stubs/virtio-gpu-udmabuf.c | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.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, VGPUDMABuf *dmabuf) g_free(dmabuf); } +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 == 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 = virtio_gpu_find_dmabuf(g, res); + if (dmabuf && dmabuf->buf.sync) { + scanout = &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/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); /* virtio-gpu-3d.c */ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, diff --git a/stubs/virtio-gpu-udmabuf.c b/stubs/virtio-gpu-udmabuf.c index 81f661441a..59dab1a66c 100644 --- a/stubs/virtio-gpu-udmabuf.c +++ b/stubs/virtio-gpu-udmabuf.c @@ -25,3 +25,9 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, /* nothing (stub) */ return 0; } + +void virtio_gpu_resource_wait_sync(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + /* nothing (stub) */ +}