From nobody Sat May 11 10:24:57 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=1711064730; cv=none; d=zohomail.com; s=zohoarc; b=KeNBzq3XhmTe91geX7H+OF0HbdiQk/SwCSS1sTsQs9vifN/yTQuubykiSTFh8Iiiep6zQ1Iomz4/ErXCOaH8P2O110hWp7P3JFU2W/9THb8GpM68dbU//ScWOSUkNRMTIQRen1VUTcQBEL4f/Rh2ohgmEzFitndSyv3bCCCCo8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711064730; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KXATRJp4mgAd2UIsY0nlKaepgkLgg27+8JVqFJ0YGDg=; b=JS0Vk6zGt73hnu5lY0teZUD1T2eMRxEasEwuSkz/IaJdwomNwuL4+j4gWOgJunsebIqVbRZowFESWPHahr45jXbv93g5XOOX79pfKgf6eUGUp5TaUM9S2G9kcHyA7IGN9kLsivrY9BMdvIcCgpk1C8Cjm/2bOvvpHrVbwOVo23M= 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 1711064730448934.3305268430822; Thu, 21 Mar 2024 16:45:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnS59-0007Ng-Eq; Thu, 21 Mar 2024 19:44:23 -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 1rnS58-0007NU-48 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 19:44:22 -0400 Received: from mgamail.intel.com ([198.175.65.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnS56-0007iR-A3 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 19:44:21 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 16:44:14 -0700 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by fmviesa006.fm.intel.com with ESMTP; 21 Mar 2024 16:44:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711064661; x=1742600661; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HWowGrDZ5wAvedguTHijDQ0FxMS517gzwRYLO/rG7Tk=; b=fKzv+lX5JRiIgmdO0Qc/iEQUY34rDk9JFhYYDLCxyySUCHobl7K2JRIC 2K2kh0PdBUDAq6V6lnmy36yuX47kgrbTvWFKVMeGDc3aiVb73o+68/nvk n9O4qipgManTRaP6/tIeIrEK+vQQtk5QUkwBMp1F9cYX+E4YOK0DgNyJe R4w1aKmHI6hQ90GElYWIgKSLUQ3LOuuUVVWy4SGZs61oLJ17l/ixYxIeL KhGS/FTXDp07NGcoQNH3GEhN46XG3wmLVSsIVV6vnWdXJLf11UVNDB7Ym rDR9E8FRJyqIUJTVGaiul0vVsCZtgOrD1cgnWfZJYvXnidSBkb+pb39Cp w==; X-IronPort-AV: E=McAfee;i="6600,9927,11020"; a="6217225" X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="6217225" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="14743274" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Cc: philmd@linaro.org, marcandre.lureau@redhat.com Subject: [PATCH v4 1/3] ui/console: Introduce dpy_gl_dmabuf_get_height/width() helpers Date: Thu, 21 Mar 2024 16:42:34 -0700 Message-Id: <20240321234236.3476163-2-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240321234236.3476163-1-dongwon.kim@intel.com> References: <20240321234236.3476163-1-dongwon.kim@intel.com> 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.16; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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: 1711064732039100005 From: Dongwon Kim dpy_gl_dmabuf_get_height() and dpy_gl_dmabuf_get_width() are helpers for retrieving width and height fields from QemuDmaBuf struct. Cc: Philippe Mathieu-Daud=C3=A9 Cc: Marc-Andr=C3=A9 Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- include/ui/console.h | 2 ++ hw/display/virtio-gpu-udmabuf.c | 7 ++++--- hw/vfio/display.c | 9 ++++++--- ui/console.c | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 0bc7a00ac0..6064487fc4 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -358,6 +358,8 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf = *dmabuf, bool have_hot, uint32_t hot_x, uint32_t hot_y); void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); +uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index d51184d658..a4ebf828ec 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -206,6 +206,7 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, { struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; VGPUDMABuf *new_primary, *old_primary =3D NULL; + uint32_t width, height; =20 new_primary =3D virtio_gpu_create_dmabuf(g, scanout_id, res, fb, r); if (!new_primary) { @@ -216,10 +217,10 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, old_primary =3D g->dmabuf.primary[scanout_id]; } =20 + width =3D dpy_gl_dmabuf_get_width(&new_primary->buf); + height =3D dpy_gl_dmabuf_get_height(&new_primary->buf); g->dmabuf.primary[scanout_id] =3D new_primary; - qemu_console_resize(scanout->con, - new_primary->buf.width, - new_primary->buf.height); + qemu_console_resize(scanout->con, width, height); dpy_gl_scanout_dmabuf(scanout->con, &new_primary->buf); =20 if (old_primary) { diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 1aa440c663..c962e5f88f 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -286,6 +286,7 @@ static void vfio_display_dmabuf_update(void *opaque) VFIOPCIDevice *vdev =3D opaque; VFIODisplay *dpy =3D vdev->dpy; VFIODMABuf *primary, *cursor; + uint32_t width, height; bool free_bufs =3D false, new_cursor =3D false; =20 primary =3D vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY); @@ -296,10 +297,12 @@ static void vfio_display_dmabuf_update(void *opaque) return; } =20 + width =3D dpy_gl_dmabuf_get_width(&primary->buf); + height =3D dpy_gl_dmabuf_get_height(&primary->buf); + if (dpy->dmabuf.primary !=3D primary) { dpy->dmabuf.primary =3D primary; - qemu_console_resize(dpy->con, - primary->buf.width, primary->buf.height); + qemu_console_resize(dpy->con, width, height); dpy_gl_scanout_dmabuf(dpy->con, &primary->buf); free_bufs =3D true; } @@ -328,7 +331,7 @@ static void vfio_display_dmabuf_update(void *opaque) cursor->pos_updates =3D 0; } =20 - dpy_gl_update(dpy->con, 0, 0, primary->buf.width, primary->buf.height); + dpy_gl_update(dpy->con, 0, 0, width, height); =20 if (free_bufs) { vfio_display_free_dmabufs(vdev); diff --git a/ui/console.c b/ui/console.c index 43226c5c14..1d0513a733 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1132,6 +1132,24 @@ void dpy_gl_cursor_position(QemuConsole *con, } } =20 +uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf) +{ + if (dmabuf) { + return dmabuf->width; + } + + return 0; +} + +uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf) +{ + if (dmabuf) { + return dmabuf->height; + } + + return 0; +} + void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf) { --=20 2.34.1 From nobody Sat May 11 10:24:57 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=1711064730; cv=none; d=zohomail.com; s=zohoarc; b=IgbKvEjtbbym9Yo9FqORevpIkF8qBhikwiiqQyd6B6hg+Iicc2qwAAUCQ4LaZSoYE1B7iXG7WD0ZhQ3SyJryWY7DCdaKNbdz+nXTe25GYgPpdm0LAcKipUn1tsPw2GEaRf29aSTnxEhfnCDdLGjBIRbO82PIzscMJfeVRR7hB+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711064730; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5AlOMIYMS6LsihoSX826fhcOmgLrZ8AL9iSjcqKoo3I=; b=jZoNfOoS60WT4hsrJgoHCRSzaWoK6VAaGWHxyqOaqp8JUQH8dXu5RfYV9wtZV3urv2rkM217ft029/PWwGd7B+E3EEWh3YFD6fa8Uzw7CJmd6ZoVWs+3Fkx/kpM9j2xjJu4kvjtPLIrsLXBg7NPLLaxnq5I2w6kSKXgroslgkT8= 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 1711064730332513.8785365240095; Thu, 21 Mar 2024 16:45:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnS5B-0007OI-G3; Thu, 21 Mar 2024 19:44:25 -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 1rnS59-0007Nh-F9 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 19:44:23 -0400 Received: from mgamail.intel.com ([198.175.65.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnS57-0007kU-UO for qemu-devel@nongnu.org; Thu, 21 Mar 2024 19:44:23 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 16:44:15 -0700 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by fmviesa006.fm.intel.com with ESMTP; 21 Mar 2024 16:44:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711064663; x=1742600663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sI7svSTFRCL8NwyeTl20Ot0CS4c3XsqEdwHOLT2cXZo=; b=ggkzUKDv5ASRGCeR02zXh2BtVpH13rt8FoXCIQ5FP8DafUZcJeIlJApc 8fTDnFafqCwZY5zOu+l8IKo5stSnjYLUxNW45Qx5DupPdBpYy7Gpf3F3/ /9Jq3eDDOWhCIS4hoQpsywFFF9aTXDuDUWDaMr1F0K/oqvkdkTWIMvrto ah+I7TJ43Q7JZ6PkuIM7T6724H3Bw7sQHlLSxvnbVrHgqbg5S1x7gtywJ 0ocHUWBs/DabvezcFbL44kQgI6dVkBs/S+uh77qimy65u3UpksA93ouhn LLYfnFGU09rKgab1rIV8qzYUYCs3Hg7fDyJibvVzP0jO+iHnjyYUTr9eR g==; X-IronPort-AV: E=McAfee;i="6600,9927,11020"; a="6217228" X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="6217228" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="14743275" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Cc: philmd@linaro.org, marcandre.lureau@redhat.com Subject: [PATCH v4 2/3] ui/console: Introduce dpy_gl_dmabuf_get_fd() helper Date: Thu, 21 Mar 2024 16:42:35 -0700 Message-Id: <20240321234236.3476163-3-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240321234236.3476163-1-dongwon.kim@intel.com> References: <20240321234236.3476163-1-dongwon.kim@intel.com> 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.16; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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: 1711064732055100006 From: Dongwon Kim dpy_gl_dmabuf_get_fd() is a helper for retrieving FD of the dmabuf from QemuDmaBuf struct. Cc: Philippe Mathieu-Daud=C3=A9 Cc: Marc-Andr=C3=A9 Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- include/ui/console.h | 1 + hw/vfio/display.c | 8 +++++++- ui/console.c | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/ui/console.h b/include/ui/console.h index 6064487fc4..d5334a806c 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -360,6 +360,7 @@ void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf); uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf); +int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, diff --git a/hw/vfio/display.c b/hw/vfio/display.c index c962e5f88f..676b2fc5f3 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -259,9 +259,15 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevi= ce *vdev, =20 static void vfio_display_free_one_dmabuf(VFIODisplay *dpy, VFIODMABuf *dma= buf) { + int fd; + QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next); + fd =3D dpy_gl_dmabuf_get_fd(&dmabuf->buf); + if (fd > -1) { + close(fd); + } + dpy_gl_release_dmabuf(dpy->con, &dmabuf->buf); - close(dmabuf->buf.fd); g_free(dmabuf); } =20 diff --git a/ui/console.c b/ui/console.c index 1d0513a733..69560aac7e 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1504,6 +1504,15 @@ int qemu_console_get_height(QemuConsole *con, int fa= llback) } } =20 +int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf) +{ + if (dmabuf) { + return dmabuf->fd; + } + + return -1; +} + int qemu_invalidate_text_consoles(void) { QemuConsole *s; --=20 2.34.1 From nobody Sat May 11 10:24:57 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=1711064731; cv=none; d=zohomail.com; s=zohoarc; b=ewMGryhyphNshX2Es4W7fR4ht+FlA+ZJoO6/wnbEleK68kYyg+xOFpF1254HomGXowJb2dmj5daHCOwtYmkY8uy9E8/eccbbBuLQsmi6xeiv2wP4aROMoZkX4Lfgu+vxz7o0CfrXRzLJRkh79qKDUgOie1xTlDe5EbejY+BVk8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711064731; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Lh9+G1DrYGVdlCxfuH13QeIzeCTBy/FGYecG8Epbx+w=; b=XmCwUJT5OQlxbP2IMzaYURf9vA47VM3kCXoI5vwRNgXihi526y9eEKxkoLaFzyRHLRlFu9t+vkju0MqM3VY/3eOu9CZkEn/4Zvc28F4CcCPNgsskwssFvL5MGQ66WyNGIGZVhbhX7FvLrtZyvC5QZMPXHTGgoSicTlOuSBEuSPw= 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 1711064731085681.7059270481059; Thu, 21 Mar 2024 16:45:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnS5C-0007Oh-14; Thu, 21 Mar 2024 19:44:26 -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 1rnS5A-0007OA-EE for qemu-devel@nongnu.org; Thu, 21 Mar 2024 19:44:24 -0400 Received: from mgamail.intel.com ([198.175.65.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnS58-0007iR-AQ for qemu-devel@nongnu.org; Thu, 21 Mar 2024 19:44:24 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 16:44:15 -0700 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by fmviesa006.fm.intel.com with ESMTP; 21 Mar 2024 16:44:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711064663; x=1742600663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XHxenZTiVD2BMTHBPjnXxu1VWCcBYKNP5NgVKpP821k=; b=UKHtQ5+EGv/Ey7IQ42jzRL70w/ah3twt8xrOv2vY0DEVsfh/PQLKWycE ++5oiQw4i9TmcfAWphjZr7pOz5n0RniQP4P/w7bOPbuMSrKKxDAqAkpE2 hhKfeWVYaX41Fgz1subKJqjjo1APc2sz59GvZ/8aagC3EbKA/VV81JNsM uL3Zkao92lse1qq+q2p+wnriYW2dgyWTIIX+bGQNmRXFvl5FLCPZOcCdb g+2laKpDLwxDMZ39LIDc4zinYYgsN7trwDdlOyt1GKwcYI/z4grZEJ725 NIhdNGUb1z02G9TrFYMGsJUYyCRdn4v4ytiid8mEREXZIIzENZj2nMjQ7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11020"; a="6217231" X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="6217231" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="14743277" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Cc: philmd@linaro.org, marcandre.lureau@redhat.com Subject: [PATCH v4 3/3] ui/console: Introduce dpy_gl_create_dmabuf() helper Date: Thu, 21 Mar 2024 16:42:36 -0700 Message-Id: <20240321234236.3476163-4-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240321234236.3476163-1-dongwon.kim@intel.com> References: <20240321234236.3476163-1-dongwon.kim@intel.com> 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.16; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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: 1711064732107100009 From: Dongwon Kim dpy_gl_create_dmabuf() allocates QemuDmaBuf and initialize fields. hw/display modules, hw/vfio and ui/dbus-listener now use this method to create QemuDmaBuf instead of declaring and initializing it on their own. Cc: Philippe Mathieu-Daud=C3=A9 Cc: Marc-Andr=C3=A9 Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- include/hw/vfio/vfio-common.h | 2 +- include/hw/virtio/virtio-gpu.h | 4 ++-- include/ui/console.h | 6 ++++++ hw/display/vhost-user-gpu.c | 33 ++++++++++++++++++--------------- hw/display/virtio-gpu-udmabuf.c | 23 ++++++++--------------- hw/vfio/display.c | 26 +++++++++++--------------- ui/console.c | 28 ++++++++++++++++++++++++++++ ui/dbus-listener.c | 28 ++++++++++++---------------- 8 files changed, 86 insertions(+), 64 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index b9da6c08ef..d66e27db02 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -148,7 +148,7 @@ typedef struct VFIOGroup { } VFIOGroup; =20 typedef struct VFIODMABuf { - QemuDmaBuf buf; + QemuDmaBuf *buf; uint32_t pos_x, pos_y, pos_updates; uint32_t hot_x, hot_y, hot_updates; int dmabuf_id; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index ed44cdad6b..56d6e821bf 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -169,7 +169,7 @@ struct VirtIOGPUBaseClass { DEFINE_PROP_UINT32("yres", _state, _conf.yres, 800) =20 typedef struct VGPUDMABuf { - QemuDmaBuf buf; + QemuDmaBuf *buf; uint32_t scanout_id; QTAILQ_ENTRY(VGPUDMABuf) next; } VGPUDMABuf; @@ -238,7 +238,7 @@ struct VhostUserGPU { VhostUserBackend *vhost; int vhost_gpu_fd; /* closed by the chardev */ CharBackend vhost_chr; - QemuDmaBuf dmabuf[VIRTIO_GPU_MAX_SCANOUTS]; + QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS]; bool backend_blocked; }; =20 diff --git a/include/ui/console.h b/include/ui/console.h index d5334a806c..01e998264b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -358,6 +358,12 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf= *dmabuf, bool have_hot, uint32_t hot_x, uint32_t hot_y); void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); +QemuDmaBuf *dpy_gl_create_dmabuf(uint32_t width, uint32_t height, + uint32_t stride, uint32_t x, + uint32_t y, uint32_t backing_width, + uint32_t backing_height, uint32_t fourcc, + uint64_t modifier, uint32_t dmabuf_fd, + bool allow_fences, bool y0_top); uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf); uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf); int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf); diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 709c8a02a1..0e49a934ed 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -249,6 +249,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) case VHOST_USER_GPU_DMABUF_SCANOUT: { VhostUserGpuDMABUFScanout *m =3D &msg->payload.dmabuf_scanout; int fd =3D qemu_chr_fe_get_msgfd(&g->vhost_chr); + uint64_t modifier =3D 0; QemuDmaBuf *dmabuf; =20 if (m->scanout_id >=3D g->parent_obj.conf.max_outputs) { @@ -261,30 +262,32 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostU= serGpuMsg *msg) =20 g->parent_obj.enable =3D 1; con =3D g->parent_obj.scanout[m->scanout_id].con; - dmabuf =3D &g->dmabuf[m->scanout_id]; - if (dmabuf->fd >=3D 0) { - close(dmabuf->fd); - dmabuf->fd =3D -1; + dmabuf =3D g->dmabuf[m->scanout_id]; + if (dmabuf) { + int dmabuf_fd =3D dpy_gl_dmabuf_get_fd(dmabuf); + if (dmabuf_fd >=3D 0) { + close(dmabuf_fd); + } + dpy_gl_release_dmabuf(con, dmabuf); } - dpy_gl_release_dmabuf(con, dmabuf); + if (fd =3D=3D -1) { dpy_gl_scanout_disable(con); break; } - *dmabuf =3D (QemuDmaBuf) { - .fd =3D fd, - .width =3D m->fd_width, - .height =3D m->fd_height, - .stride =3D m->fd_stride, - .fourcc =3D m->fd_drm_fourcc, - .y0_top =3D m->fd_flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, - }; + if (msg->request =3D=3D VHOST_USER_GPU_DMABUF_SCANOUT2) { VhostUserGpuDMABUFScanout2 *m2 =3D &msg->payload.dmabuf_scanou= t2; - dmabuf->modifier =3D m2->modifier; + modifier =3D m2->modifier; } =20 - dpy_gl_scanout_dmabuf(con, dmabuf); + dmabuf =3D dpy_gl_create_dmabuf(m->fd_width, m->fd_height, m->fd_s= tride, + 0, 0, 0, 0, m->fd_drm_fourcc, modifi= er, + fd, false, m->fd_flags & + VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP); + + dpy_gl_scanout_dmabuf(con, g->dmabuf[m->scanout_id]); + g->dmabuf[m->scanout_id] =3D dmabuf; break; } case VHOST_USER_GPU_DMABUF_UPDATE: { diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index a4ebf828ec..2bc8697d86 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -162,7 +162,7 @@ static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDM= ABuf *dmabuf) struct virtio_gpu_scanout *scanout; =20 scanout =3D &g->parent_obj.scanout[dmabuf->scanout_id]; - dpy_gl_release_dmabuf(scanout->con, &dmabuf->buf); + dpy_gl_release_dmabuf(scanout->con, dmabuf->buf); QTAILQ_REMOVE(&g->dmabuf.bufs, dmabuf, next); g_free(dmabuf); } @@ -181,17 +181,10 @@ static VGPUDMABuf } =20 dmabuf =3D g_new0(VGPUDMABuf, 1); - dmabuf->buf.width =3D r->width; - dmabuf->buf.height =3D r->height; - dmabuf->buf.stride =3D fb->stride; - dmabuf->buf.x =3D r->x; - dmabuf->buf.y =3D r->y; - dmabuf->buf.backing_width =3D fb->width; - dmabuf->buf.backing_height =3D fb->height; - dmabuf->buf.fourcc =3D qemu_pixman_to_drm_format(fb->format); - dmabuf->buf.fd =3D res->dmabuf_fd; - dmabuf->buf.allow_fences =3D true; - dmabuf->buf.draw_submitted =3D false; + dmabuf->buf =3D dpy_gl_create_dmabuf(r->width, r->height, fb->stride, + r->x, r->y, fb->width, fb->height, + qemu_pixman_to_drm_format(fb->forma= t), + 0, res->dmabuf_fd, false, 0); dmabuf->scanout_id =3D scanout_id; QTAILQ_INSERT_HEAD(&g->dmabuf.bufs, dmabuf, next); =20 @@ -217,11 +210,11 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, old_primary =3D g->dmabuf.primary[scanout_id]; } =20 - width =3D dpy_gl_dmabuf_get_width(&new_primary->buf); - height =3D dpy_gl_dmabuf_get_height(&new_primary->buf); + width =3D dpy_gl_dmabuf_get_width(new_primary->buf); + height =3D dpy_gl_dmabuf_get_height(new_primary->buf); g->dmabuf.primary[scanout_id] =3D new_primary; qemu_console_resize(scanout->con, width, height); - dpy_gl_scanout_dmabuf(scanout->con, &new_primary->buf); + dpy_gl_scanout_dmabuf(scanout->con, new_primary->buf); =20 if (old_primary) { virtio_gpu_free_dmabuf(g, old_primary); diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 676b2fc5f3..62f5db2d54 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -240,15 +240,11 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDev= ice *vdev, } =20 dmabuf =3D g_new0(VFIODMABuf, 1); - dmabuf->dmabuf_id =3D plane.dmabuf_id; - dmabuf->buf.width =3D plane.width; - dmabuf->buf.height =3D plane.height; - dmabuf->buf.backing_width =3D plane.width; - dmabuf->buf.backing_height =3D plane.height; - dmabuf->buf.stride =3D plane.stride; - dmabuf->buf.fourcc =3D plane.drm_format; - dmabuf->buf.modifier =3D plane.drm_format_mod; - dmabuf->buf.fd =3D fd; + dmabuf->dmabuf_id =3D plane.dmabuf_id; + dmabuf->buf =3D dpy_gl_create_dmabuf(plane.width, plane.height, plane.= stride, + 0, 0, plane.width, plane.height, + plane.drm_format, plane.drm_format_= mod, + fd, false, 0); if (plane_type =3D=3D DRM_PLANE_TYPE_CURSOR) { vfio_display_update_cursor(dmabuf, &plane); } @@ -262,12 +258,12 @@ static void vfio_display_free_one_dmabuf(VFIODisplay = *dpy, VFIODMABuf *dmabuf) int fd; =20 QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next); - fd =3D dpy_gl_dmabuf_get_fd(&dmabuf->buf); + fd =3D dpy_gl_dmabuf_get_fd(dmabuf->buf); if (fd > -1) { close(fd); } =20 - dpy_gl_release_dmabuf(dpy->con, &dmabuf->buf); + dpy_gl_release_dmabuf(dpy->con, dmabuf->buf); g_free(dmabuf); } =20 @@ -303,13 +299,13 @@ static void vfio_display_dmabuf_update(void *opaque) return; } =20 - width =3D dpy_gl_dmabuf_get_width(&primary->buf); - height =3D dpy_gl_dmabuf_get_height(&primary->buf); + width =3D dpy_gl_dmabuf_get_width(primary->buf); + height =3D dpy_gl_dmabuf_get_height(primary->buf); =20 if (dpy->dmabuf.primary !=3D primary) { dpy->dmabuf.primary =3D primary; qemu_console_resize(dpy->con, width, height); - dpy_gl_scanout_dmabuf(dpy->con, &primary->buf); + dpy_gl_scanout_dmabuf(dpy->con, primary->buf); free_bufs =3D true; } =20 @@ -323,7 +319,7 @@ static void vfio_display_dmabuf_update(void *opaque) if (cursor && (new_cursor || cursor->hot_updates)) { bool have_hot =3D (cursor->hot_x !=3D 0xffffffff && cursor->hot_y !=3D 0xffffffff); - dpy_gl_cursor_dmabuf(dpy->con, &cursor->buf, have_hot, + dpy_gl_cursor_dmabuf(dpy->con, cursor->buf, have_hot, cursor->hot_x, cursor->hot_y); cursor->hot_updates =3D 0; } else if (!cursor && new_cursor) { diff --git a/ui/console.c b/ui/console.c index 69560aac7e..f3920e7713 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1132,6 +1132,33 @@ void dpy_gl_cursor_position(QemuConsole *con, } } =20 +QemuDmaBuf *dpy_gl_create_dmabuf(uint32_t width, uint32_t height, + uint32_t stride, uint32_t x, + uint32_t y, uint32_t backing_width, + uint32_t backing_height, uint32_t fourcc, + uint64_t modifier, uint32_t dmabuf_fd, + bool allow_fences, bool y0_top) { + QemuDmaBuf *dmabuf; + + dmabuf =3D g_new0(QemuDmaBuf, 1); + + dmabuf->width =3D width; + dmabuf->height =3D height; + dmabuf->stride =3D stride; + dmabuf->x =3D x; + dmabuf->y =3D y; + dmabuf->backing_width =3D backing_width; + dmabuf->backing_height =3D backing_height; + dmabuf->fourcc =3D fourcc; + dmabuf->modifier =3D modifier; + dmabuf->fd =3D dmabuf_fd; + dmabuf->allow_fences =3D allow_fences; + dmabuf->y0_top =3D y0_top; + dmabuf->fence_fd =3D -1; + + return dmabuf; +} + uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf) { if (dmabuf) { @@ -1164,6 +1191,7 @@ void dpy_gl_release_dmabuf(QemuConsole *con, dcl->ops->dpy_gl_release_dmabuf(dcl, dmabuf); } } + g_free(dmabuf); } =20 void dpy_gl_update(QemuConsole *con, diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 4a0a5d78f9..a2145704cc 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -438,28 +438,24 @@ static void dbus_scanout_texture(DisplayChangeListene= r *dcl, trace_dbus_scanout_texture(tex_id, backing_y_0_top, backing_width, backing_height, x, y, w, h); #ifdef CONFIG_GBM - QemuDmaBuf dmabuf =3D { - .width =3D w, - .height =3D h, - .y0_top =3D backing_y_0_top, - .x =3D x, - .y =3D y, - .backing_width =3D backing_width, - .backing_height =3D backing_height, - }; + int32_t fd; + uint32_t stride, fourcc; + uint64_t modifier; + QemuDmaBuf *dmabuf; =20 assert(tex_id); - dmabuf.fd =3D egl_get_fd_for_texture( - tex_id, (EGLint *)&dmabuf.stride, - (EGLint *)&dmabuf.fourcc, - &dmabuf.modifier); - if (dmabuf.fd < 0) { + fd =3D egl_get_fd_for_texture(tex_id, (EGLint *)&stride, (EGLint *)&fo= urcc, + &modifier); + if (fd < 0) { error_report("%s: failed to get fd for texture", __func__); return; } + dmabuf =3D dpy_gl_create_dmabuf(w, h, stride, x, y, backing_width, + backing_height, fourcc, modifier, fd, + false, backing_y_0_top); =20 - dbus_scanout_dmabuf(dcl, &dmabuf); - close(dmabuf.fd); + dbus_scanout_dmabuf(dcl, dmabuf); + close(fd); #endif =20 #ifdef WIN32 --=20 2.34.1