From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664203141; cv=none; d=zohomail.com; s=zohoarc; b=Xc5F1h32IifJ37q+NmJgw1RF/TVd1wH2PTgujViwDRS4dzTfxmInpOpHiKJfTXfJVeINEYHy6z06nBaYT89JZ9dglzJ82NWp1yHET5JiQwwXWHV+vlGlalh6S7SU/xoP6rLU7Y22HaNP6S8QI554JeZX/lxl4uNAft3dK3DNc1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664203141; 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=hgJqtUhKqYxUKgw0hqRvjFGFM1E5VCRpLppH+bxi1mc=; b=Pyz7rht6r2t53VAXHypDKASr0ViIN5RaCcAWx12l8/h5s7lhn5NA+prrVfJaF4NcwZMaIm2M38fCwcKHSZO8XNCT54Rc8+PMcpCwoSG6wobFhUtlaVmgQCYGAkBdQyjdyFg7dCB0t/RQU4myLZdqW+oLANFCkh6Q/No5kJKGGFo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664203141511465.6856014419109; Mon, 26 Sep 2022 07:39:01 -0700 (PDT) Received: from localhost ([::1]:43536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpG8-0004YJ-Bj for importer@patchew.org; Mon, 26 Sep 2022 10:39:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2C-0003jN-NZ for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:36 -0400 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]:33126) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2A-00043X-Ox for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:36 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 40EF76602258; Mon, 26 Sep 2022 15:24:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202271; bh=DOVlmH6R/glWZov62i99PaXzdBdIGZEN0epjvHBVYXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G4/XYu1FUbqLYB7b342IsM/Xdn0fmGnpz/BDYVXmtO3FDnSZWYUS+Jo6Y4MhIZ2HQ VEV296feEFqT52hqyP9tCLkXiymEMYWkGXjQIl5aqVNVdUTZXBpL/aKMsWkMTjV8cN 5mUqCc5aZIMPA4b/YVXPgjYwUUzTpIVrDv+snyyS6uePjTTtRxC3QSNrLHYgn0kzPV v/gyMrjKHUR1bWI0MMvN1bSai+DD4O7G3lFTEfCv+IVGVcI9cdtMwRyVneRTbt2goe Ve7wNbh7beBwfHUvHIeZ0+hxgwLqUuPwgXoot040d2qfT8odkY4JiK5Pnp/1wOvFqf zUhDCss8WLcrg== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, "Dr. David Alan Gilbert" , "Michael S. Tsirkin" Subject: [PATCH v3 1/9] virtio: Add shared memory capability Date: Mon, 26 Sep 2022 16:24:14 +0200 Message-Id: <20220926142422.22325-2-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=2a00:1098:0:82:1000:25:2eeb:e5ab; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664203142571100003 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Reviewed-by: Alex Benn=C3=A9e --- v3: - Remove virtio_pci_shm_cap as virtio_pci_cap64 is used instead. - No need for mask32 as cpu_to_le32 truncates the value. hw/virtio/virtio-pci.c | 18 ++++++++++++++++++ include/hw/virtio/virtio-pci.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index a50c5a57d7..377bb06fec 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1169,6 +1169,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *pr= oxy, return offset; } =20 +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ + struct virtio_pci_cap64 cap =3D { + .cap.cap_len =3D sizeof cap, + .cap.cfg_type =3D VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, + }; + + cap.cap.bar =3D bar; + cap.cap.length =3D cpu_to_le32(length); + cap.length_hi =3D cpu_to_le32(length >> 32); + cap.cap.offset =3D cpu_to_le32(offset); + cap.offset_hi =3D cpu_to_le32(offset >> 32); + cap.cap.id =3D id; + return virtio_pci_add_mem_cap(proxy, &cap.cap); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 2446dcd9ae..5e5c4a4c6d 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -252,4 +252,8 @@ void virtio_pci_types_register(const VirtioPCIDeviceTyp= eInfo *t); */ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); =20 +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id); + #endif --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664204509; cv=none; d=zohomail.com; s=zohoarc; b=j38OFOo1//YyRQ+thDeqDZvxwbqawSxYzPbSWnRiT7dtYOXaKGXK51Ij0blfrVESczqu/6eRSl7Y5Q76zvC7+T6L03cX9RFuFKZknuNuu6Io+zBsJK7yWHxC3m5u3IGhl719tN8ggzny4G13sV4y9VVnRlRvO81BH98qQ5j7MHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664204509; 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=uURQ2MsHS/uzAWp1TP/JpNMLau1Hq6vJYGMZmGjZED8=; b=HIXZ/QiZIYPAkIt24p8DGne9ktZjDBkyY2OqvaQA8B5Sp00wRDTJ6SG5v3UyIophTx7upZPzTW8WkizwNe2y8qdqjBDiWMU0s+J47tOz03OQ4XjveergZQv/9EtRkkEPUTE58rByyV1k0Zr4esg93RBEgpbb91f6aSaq+AvU9DM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664204509506466.3396734782674; Mon, 26 Sep 2022 08:01:49 -0700 (PDT) Received: from localhost ([::1]:43786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpcC-0003ym-2F for importer@patchew.org; Mon, 26 Sep 2022 11:01:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2D-0003mE-Sx for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:37 -0400 Received: from madras.collabora.co.uk ([46.235.227.172]:55430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2A-00043c-Ot for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:37 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id C8015660225B; Mon, 26 Sep 2022 15:24:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202272; bh=udygUkadS5Zhs+4E0ZWq5l2EruUYmnV5jpY281xNGtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mao3iWUkgj7WmEUXFuxA5tCZy7eFu1UJJV0XwiLjFF8+YyQuM39sMdA1FtSJwE8kf yMlC5JjC8e0RX3SA+cxj/LjL1aW7zixT41RPUjLB74pYXKFQJ9YV0c83PMCH0Bm4Ls JT+NpY9N3Q6EJmG2xekeWtDCk5u1B1TqPJOymzIzEvvQd6cOYFKw3PrT/siEUX2jj6 foSXi7EACifq2mlhSG+mBVCqdizJ9Q3OmF8RHrps9TkdX0edxA2OLERvH15VWdH1TD r0SLF6tIJvmyRVu3TBavzzUnShbX7jnfGPvGB0BGQcnYmCgFYoHz+fnD6w6BdK4BOW T95Wbh3vbBYBA== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, Gerd Hoffmann , "Michael S . Tsirkin" Subject: [PATCH v3 2/9] virtio-gpu: hostmem Date: Mon, 26 Sep 2022 16:24:15 +0200 Message-Id: <20220926142422.22325-3-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=46.235.227.172; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664204511726100001 Content-Type: text/plain; charset="utf-8" From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Acked-by: Michael S. Tsirkin --- v3: Formatting fixes hw/display/virtio-gpu-pci.c | 15 +++++++++++++++ hw/display/virtio-gpu.c | 1 + hw/display/virtio-vga.c | 33 ++++++++++++++++++++++++--------- include/hw/virtio/virtio-gpu.h | 5 +++++ 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..2cbbacd7fe 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,21 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *= vpci_dev, Error **errp) DeviceState *vdev =3D DEVICE(g); int i; =20 + if (virtio_gpu_hostmem_enabled(g->conf)) { + vpci_dev->msix_bar_idx =3D 1; + vpci_dev->modern_mem_bar_idx =3D 2; + memory_region_init(&g->hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); + pci_register_bar(&vpci_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &g->hostmem); + virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); + } + + qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus), errp); virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 20cc703dcc..506b3b8eef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1424,6 +1424,7 @@ static Property virtio_gpu_properties[] =3D { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), + DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 4dcb34c4a7..aa8d1ab993 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *v= pci_dev, Error **errp) pci_register_bar(&vpci_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram); =20 - /* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ - vpci_dev->modern_mem_bar_idx =3D 2; - vpci_dev->msix_bar_idx =3D 4; vpci_dev->modern_io_bar_idx =3D 5; =20 + if (!virtio_gpu_hostmem_enabled(g->conf)) { + /* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvg= a. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ + vpci_dev->modern_mem_bar_idx =3D 2; + vpci_dev->msix_bar_idx =3D 4; + } else { + vpci_dev->msix_bar_idx =3D 1; + vpci_dev->modern_mem_bar_idx =3D 2; + memory_region_init(&g->hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); + pci_register_bar(&vpci_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &g->hostmem); + virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); + } + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=3Doff there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2e28507efe..eafce75b04 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -102,12 +102,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ + (_cfg.hostmem > 0) =20 struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; + uint64_t hostmem; }; =20 struct virtio_gpu_ctrl_command { @@ -131,6 +134,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; =20 + MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; =20 int enabled_output_bitmask; --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664203139; cv=none; d=zohomail.com; s=zohoarc; b=BKW55hOclxwD2YKJ0ZgzUUNNMLdnQM3nHBhuAgJn4+B71hjqnPXjRQpHhQKWn+4t0BnUageKzgfz/n/8DFmFPwWj5oa8O0WFGOHAwv9t6HACz69t5xY1X944j9Gx+fGaNHzIFmVdThPImRzB14z+pOXMM2Yhj+ADcWqZ13soWDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664203139; 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=myY+Ee1aFnpcGtEAV6Pey/rJUP8DwrD1KrusELp/4TQ=; b=CZ/0Jm0XhjsLx0OgYYagELWomrNpCckTA4olrbHU5c9REqCkXkhcHBFZA3pQ45f5VzuFvA/iTzV9eeqG3qvUrZdhKikdz+rFo5OBYm4w1lhxTWzUTCSC8ZN5iJRYooJ98VYxrgHJK0nL06lrQOLHMDHMhuRBKPhxAZ3eqf5jITY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664203139846937.8217673612918; Mon, 26 Sep 2022 07:38:59 -0700 (PDT) Received: from localhost ([::1]:43534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpG6-0004M2-GM for importer@patchew.org; Mon, 26 Sep 2022 10:38:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2E-0003nm-D5 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from madras.collabora.co.uk ([46.235.227.172]:55434) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2A-00043m-Ox for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 65456660225C; Mon, 26 Sep 2022 15:24:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202272; bh=Zwzp95/QVrkDF7T71j7pMW1BCcw8wKvkxvkyu1GdhtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kFHjFxEPI8yVZJl8solumgzUrZ1EycmGtwK9UwHl49StCXf9vKVzfFwB6U5mDeh/Z HzCPsSolRwHdDcCIk66J57r8iWKWYyzBowf8IX6dmbo8YEdkmSgxG2TrlC5opiSX4t SUGd2N6lCIX6LOSevzNB2rGK2oQ326QfjuC8KP2aW+bR1eig90IIj8cQ8lwwJrcGLo UbhssusWdw74e+bVHy5CuExR8ILLwEYGpEEIpg+SU/XCONIGhS168KwcPgyi0mX2xP D1BjOtBEu4vTDQF9bqcu7UY6CDB3GVlRPN04XqKY5aCt6MqgqDOub0aPO1GZ6xlzWL 6F8TeXwb0YyiA== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PATCH v3 3/9] virtio-gpu: Handle resource blob commands Date: Mon, 26 Sep 2022 16:24:16 +0200 Message-Id: <20220926142422.22325-4-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=46.235.227.172; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664203140690100001 Content-Type: text/plain; charset="utf-8" Support BLOB resources creation, mapping and unmapping by calling the new stable virglrenderer 0.10 interface. Only enabled when available and via the blob config. E.g. -device virtio-vga-gl,blob=3Dtrue Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko --- v3: Fix memory leaks and unmap resource on destroy. hw/display/virtio-gpu-virgl.c | 171 +++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 12 +- include/hw/virtio/virtio-gpu-bswap.h | 18 +++ include/hw/virtio/virtio-gpu.h | 8 ++ meson.build | 5 + 5 files changed, 210 insertions(+), 4 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 73cb92c8d5..17f00b3fb0 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -16,6 +16,8 @@ #include "trace.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" +#include "hw/virtio/virtio-gpu-bswap.h" +#include "hw/virtio/virtio-iommu.h" =20 #include =20 @@ -398,6 +400,164 @@ static void virgl_cmd_get_capset(VirtIOGPU *g, g_free(resp); } =20 +#ifdef HAVE_VIRGL_RESOURCE_BLOB + +static void virgl_cmd_resource_create_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command = *cmd) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_create_blob cblob; + int ret; + + VIRTIO_GPU_FILL_CMD(cblob); + virtio_gpu_create_blob_bswap(&cblob); + trace_virtio_gpu_cmd_res_create_blob(cblob.resource_id, cblob.size); + + if (cblob.resource_id =3D=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n= ", + __func__); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res =3D virtio_gpu_find_resource(g, cblob.resource_id); + if (res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n", + __func__, cblob.resource_id); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res =3D g_new0(struct virtio_gpu_simple_resource, 1); + QTAILQ_INSERT_HEAD(&g->reslist, res, next); + + res->resource_id =3D cblob.resource_id; + res->blob_size =3D cblob.size; + + if (cblob.blob_mem !=3D VIRTIO_GPU_BLOB_MEM_HOST3D) { + ret =3D virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(= cblob), + cmd, &res->addrs, &res->iov, + &res->iov_cnt); + if (ret !=3D 0) { + cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + } + + if (cblob.blob_mem =3D=3D VIRTIO_GPU_BLOB_MEM_GUEST) { + virtio_gpu_init_udmabuf(res); + } + const struct virgl_renderer_resource_create_blob_args virgl_args =3D { + .res_handle =3D cblob.resource_id, + .ctx_id =3D cblob.hdr.ctx_id, + .blob_mem =3D cblob.blob_mem, + .blob_id =3D cblob.blob_id, + .blob_flags =3D cblob.blob_flags, + .size =3D cblob.size, + .iovecs =3D res->iov, + .num_iovs =3D res->iov_cnt, + }; + ret =3D virgl_renderer_resource_create_blob(&virgl_args); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: virgl blob create error: %s\n", + __func__, strerror(-ret)); + cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; + } +} + +static void virgl_cmd_resource_map_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cm= d) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_map_blob mblob; + int ret; + void *data; + uint64_t size; + struct virtio_gpu_resp_map_info resp; + + VIRTIO_GPU_FILL_CMD(mblob); + virtio_gpu_map_blob_bswap(&mblob); + + if (mblob.resource_id =3D=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n= ", + __func__); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res =3D virtio_gpu_find_resource(g, mblob.resource_id); + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", + __func__, mblob.resource_id); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + ret =3D virgl_renderer_resource_map(res->resource_id, &data, &size); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource map error: %s\n", + __func__, strerror(-ret)); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + memory_region_init_ram_device_ptr(&res->region, OBJECT(g), NULL, size,= data); + memory_region_add_subregion(&g->parent_obj.hostmem, mblob.offset, &res= ->region); + memory_region_set_enabled(&res->region, true); + + memset(&resp, 0, sizeof(resp)); + resp.hdr.type =3D VIRTIO_GPU_RESP_OK_MAP_INFO; + virgl_renderer_resource_get_map_info(mblob.resource_id, &resp.map_info= ); + virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp)); + + res->mapped =3D true; +} + +int virtio_gpu_virgl_resource_unmap(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + if (!res->mapped) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already unmapped %d\n= ", + __func__, res->resource_id); + return VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + } + + memory_region_set_enabled(&res->region, false); + memory_region_del_subregion(&g->parent_obj.hostmem, &res->region); + object_unparent(OBJECT(&res->region)); + + res->mapped =3D false; + return virgl_renderer_resource_unmap(res->resource_id); +} + +static void virgl_cmd_resource_unmap_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cm= d) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_unmap_blob ublob; + VIRTIO_GPU_FILL_CMD(ublob); + virtio_gpu_unmap_blob_bswap(&ublob); + + if (ublob.resource_id =3D=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n= ", + __func__); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res =3D virtio_gpu_find_resource(g, ublob.resource_id); + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", + __func__, ublob.resource_id); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + virtio_gpu_virgl_resource_unmap(g, res); +} + +#endif /* HAVE_VIRGL_RESOURCE_BLOB */ + void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -464,6 +624,17 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, case VIRTIO_GPU_CMD_GET_EDID: virtio_gpu_get_edid(g, cmd); break; +#ifdef HAVE_VIRGL_RESOURCE_BLOB + case VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB: + virgl_cmd_resource_create_blob(g, cmd); + break; + case VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB: + virgl_cmd_resource_map_blob(g, cmd); + break; + case VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB: + virgl_cmd_resource_unmap_blob(g, cmd); + break; +#endif /* HAVE_VIRGL_RESOURCE_BLOB */ default: cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; break; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 506b3b8eef..f79693d44d 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,8 +33,6 @@ =20 #define VIRTIO_GPU_VM_VERSION 1 =20 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, @@ -115,7 +113,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_g= pu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } =20 -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -874,6 +872,10 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, struct virtio_gpu_simple_resource *= res) { + if (res->mapped) { + virtio_gpu_virgl_resource_unmap(g, res); + } + virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov =3D NULL; res->iov_cnt =3D 0; @@ -1323,10 +1325,12 @@ void virtio_gpu_device_realize(DeviceState *qdev, E= rror **errp) return; } =20 +#ifndef HAVE_VIRGL_RESOURCE_BLOB if (virtio_gpu_virgl_enabled(g->parent_obj.conf)) { - error_setg(errp, "blobs and virgl are not compatible (yet)"); + error_setg(errp, "Linked virglrenderer does not support blob r= esources"); return; } +#endif } =20 if (!virtio_gpu_base_device_realize(qdev, diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virti= o-gpu-bswap.h index 9124108485..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -63,10 +63,28 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource= _create_blob *cblob) { virtio_gpu_ctrl_hdr_bswap(&cblob->hdr); le32_to_cpus(&cblob->resource_id); + le32_to_cpus(&cblob->blob_mem); le32_to_cpus(&cblob->blob_flags); + le32_to_cpus(&cblob->nr_entries); + le64_to_cpus(&cblob->blob_id); le64_to_cpus(&cblob->size); } =20 +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ + virtio_gpu_ctrl_hdr_bswap(&mblob->hdr); + le32_to_cpus(&mblob->resource_id); + le64_to_cpus(&mblob->offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ + virtio_gpu_ctrl_hdr_bswap(&ublob->hdr); + le32_to_cpus(&ublob->resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index eafce75b04..708cf1bb9c 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -55,6 +55,9 @@ struct virtio_gpu_simple_resource { int dmabuf_fd; uint8_t *remapped; =20 + MemoryRegion region; + bool mapped; + QTAILQ_ENTRY(virtio_gpu_simple_resource) next; }; =20 @@ -245,6 +248,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, struct virtio_gpu_resp_display_info *dpy_info); =20 /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -289,5 +295,7 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g); void virtio_gpu_virgl_reset(VirtIOGPU *g); int virtio_gpu_virgl_init(VirtIOGPU *g); int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g); +int virtio_gpu_virgl_resource_unmap(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res= ); =20 #endif diff --git a/meson.build b/meson.build index 3885fc1076..c4e801b4f5 100644 --- a/meson.build +++ b/meson.build @@ -718,6 +718,11 @@ if not get_option('virglrenderer').auto() or have_syst= em or have_vhost_user_gpu method: 'pkg-config', required: get_option('virglrenderer'), kwargs: static_kwargs) + + config_host_data.set('HAVE_VIRGL_RESOURCE_BLOB', + cc.has_function('virgl_renderer_resource_create_blo= b', + prefix: '#include = ', + dependencies: virgl)) endif curl =3D not_found if not get_option('curl').auto() or have_block --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664204959; cv=none; d=zohomail.com; s=zohoarc; b=mWOWhNyN52hea0Bbe4kGQa3IiddZDvC3kbpM3Gv/l5Wevhgr8/lOUEyLpGfhYgGXHaCPzT62zP7hdz2S98OjtYS+kZ2SFO2mt0nqSQJbkDkn9cEVvPGLzxDab7HMm45YDafkDPtI8plXLng+xIvnrd6ddFF7oAb9vTdpYXwsRc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664204959; h=Content-Type: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=9mMrgsM9L2MSwufZRpa03PHFKznSgqLzWud/b4qIoH8=; b=jXiMGSO6god5VdnTvW8bPuLPSlHbkEoSsKLnYC9itO+yC3SGSrP11GHyluWNl82d7pyyapNRgapV193kZuQW7vK8LL2MvytxRYWS2eVVtsUwwYaCV8ywRIoYlvLSdREbVcANnmlT20kIi306IShCS918IkLq1TLxQyTgv1WwBzc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664204959387463.078466342845; Mon, 26 Sep 2022 08:09:19 -0700 (PDT) Received: from localhost ([::1]:37032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpjR-00078t-5t for importer@patchew.org; Mon, 26 Sep 2022 11:09:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2E-0003mq-4N for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]:33138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2A-00043r-Rx for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:37 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id EF3EE660225D; Mon, 26 Sep 2022 15:24:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202273; bh=Dy99fE80g16rFdSg0P8X0a9uoAQTTRgiZ6NYQl8RvmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuhWJxWDM2FOOrY9AvV2XiL2ivAUTzVGirXf63B3qMGzD/hbddWSq3c5POrsBx9br BYTVZguA0fJF3yFUPHFu4MQqMOBZv2VubaCBZXNA9/HZ4I28pDRdU36DB3fABiwGUm Zz1/hmD67ZQIvXC5YaFJ7nNWYfmeCk88SgSTOlUDXitm/bfGtodNOLc7BhnDzdPBDr Jm3LR8qalx9y1DYc0/01F/0Pb3OyYFmYFn4vcuueFnpOHG+oCoYOCuQliTTg1IF9dB zyB7Zq4UJjnPNokJvCuCNr/25SYjBaDoXkuQ769S6klrWBunoCEAPoUf8R7jqe3R2L vc07aznHXot+A== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PATCH v3 4/9] virtio-gpu: CONTEXT_INIT feature Date: Mon, 26 Sep 2022 16:24:17 +0200 Message-Id: <20220926142422.22325-5-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=2a00:1098:0:82:1000:25:2eeb:e5ab; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664204960327100001 Create virgl renderer context with flags using context_id when valid. The feature can be enabled via the context_init config option. A warning message will be emitted and the feature will not be used when linking with virglrenderer versions without context_init support. Signed-off-by: Antonio Caggiano Reviewed-by: Marc-Andr=C3=A9 Lureau --- v3: - The feature can be enabled via the context_init config option. - A warning message will be emitted and the feature will not be used when linking with virglrenderer versions without context_init support. - Define HAVE_VIRGL_CONTEXT_INIT in config_host_data. hw/display/virtio-gpu-base.c | 3 +++ hw/display/virtio-gpu-virgl.c | 16 ++++++++++++++-- hw/display/virtio-gpu.c | 2 ++ include/hw/virtio/virtio-gpu.h | 3 +++ meson.build | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index a29f191aa8..6c5f1f327f 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -215,6 +215,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64= _t features, if (virtio_gpu_blob_enabled(g->conf)) { features |=3D (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } + if (virtio_gpu_context_init_enabled(g->conf)) { + features |=3D (1 << VIRTIO_GPU_F_CONTEXT_INIT); + } =20 return features; } diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 17f00b3fb0..1bff8c66ce 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -99,8 +99,20 @@ static void virgl_cmd_context_create(VirtIOGPU *g, trace_virtio_gpu_cmd_ctx_create(cc.hdr.ctx_id, cc.debug_name); =20 - virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, - cc.debug_name); + if (cc.context_init) { +#ifdef HAVE_VIRGL_CONTEXT_INIT + virgl_renderer_context_create_with_flags(cc.hdr.ctx_id, + cc.context_init, + cc.nlen, + cc.debug_name); + return; +#else + qemu_log_mask(LOG_UNIMP, + "Linked virglrenderer does not support context-init\= n"); +#endif + } + =20 + virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, cc.debug_name); } =20 static void virgl_cmd_context_destroy(VirtIOGPU *g, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index f79693d44d..92cd96582e 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1429,6 +1429,8 @@ static Property virtio_gpu_properties[] =3D { DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), + DEFINE_PROP_BIT("context_init", VirtIOGPU, parent_obj.conf.flags, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 708cf1bb9c..a23efb9568 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; =20 #define virtio_gpu_virgl_enabled(_cfg) \ @@ -107,6 +108,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) +#define virtio_gpu_context_init_enabled(_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) =20 struct virtio_gpu_base_conf { uint32_t max_outputs; diff --git a/meson.build b/meson.build index c4e801b4f5..6d4b844ffb 100644 --- a/meson.build +++ b/meson.build @@ -723,6 +723,10 @@ if not get_option('virglrenderer').auto() or have_syst= em or have_vhost_user_gpu cc.has_function('virgl_renderer_resource_create_blo= b', prefix: '#include = ', dependencies: virgl)) + config_host_data.set('HAVE_VIRGL_CONTEXT_INIT', + cc.has_function('virgl_renderer_context_create_with= _flags', + prefix: '#include = ', + dependencies: virgl)) endif curl =3D not_found if not get_option('curl').auto() or have_block --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664205132; cv=none; d=zohomail.com; s=zohoarc; b=DDseBz1WTyqPgN0QKzH/5YacJ58RGS3BFGZid57/kG8LH/BQqiHQSYDkrDoTs+Y/Mx8a2ixUZJRxPvOJtaLp8OBK7GprK3qRlHb+Kelgu1dxXc82acZikJWTGsvjEoxsOLCw77p+W/AowRPX8jQcwvawr3YDZQqjENzkQXh89xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664205132; 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=hPawSMIk3A3m15xwy2zwUg+WuaRmBXWoHf4Nw5yBgcY=; b=ckW7+onxnNf/E3GaXypw92PWGcBOzExSqKT94oTt/++S7I71ccv8g2iGyhvpWLemK2QSoUgS6G4+dWoTc9+kjRYTO41z/TwWer2asxVLlJBEdZWeIpa/XIEc+QNF4hu7pkEX+EdiXU3sx4Ii2N28BVVyYPbDYlcyyXTsXPhhvKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664205132297223.6905397640072; Mon, 26 Sep 2022 08:12:12 -0700 (PDT) Received: from localhost ([::1]:48662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpmE-0003Hq-Uk for importer@patchew.org; Mon, 26 Sep 2022 11:12:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2E-0003pa-S7 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]:33172) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2D-00044F-8C for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8C832660225E; Mon, 26 Sep 2022 15:24:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202273; bh=JS0Ve7s4ciIEACFsL6MbD6nY7syAF1LoJp9WfZQ0O6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ur58yp7hfI8RUIkPaOEVwctDrQBwo7h7PPpRTL5//L5PXr6mBpGsUQX3/bNkJiwsx GTg5TMD01J20RZoJNRMrfgWKUnZXR0fX6OEk09e/St3Ci4YNecPZYO38LNH47aKQtD ftBXd6Sho/en6O8BeaR4PMzsnfYkWT5VSana6FZCf6CGqXMgAbmznisILE4LVYIIvz 9yb3GY3nUfbLWeS1Aolg5XlFl2sdCmuscCd8oO6dIHIrWriIQDtqf3957buVzM5Oll gFMYobUvFONHMj3NFnVSktX3NQpZdkc2/b4/Akv2DtCNry4c3Yc1+seLcpNcf/Byxf Dexi+p3ioIBdw== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PATCH v3 5/9] virtio-gpu: Unrealize Date: Mon, 26 Sep 2022 16:24:18 +0200 Message-Id: <20220926142422.22325-6-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=2a00:1098:0:82:1000:25:2eeb:e5ab; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664205134897100001 Content-Type: text/plain; charset="utf-8" Implement an unrealize function for virtio gpu device. Signed-off-by: Antonio Caggiano Reviewed-by: Alex Benn=C3=A9e --- v3: Call virtio_gpu_base_device_unrealize from virtio_gpu_device_unrealize hw/display/virtio-gpu-base.c | 2 +- hw/display/virtio-gpu.c | 11 +++++++++++ include/hw/virtio/virtio-gpu.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 6c5f1f327f..5cb71e71ad 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -230,7 +230,7 @@ virtio_gpu_base_set_features(VirtIODevice *vdev, uint64= _t features) trace_virtio_gpu_features(((features & virgl) =3D=3D virgl)); } =20 -static void +void virtio_gpu_base_device_unrealize(DeviceState *qdev) { VirtIOGPUBase *g =3D VIRTIO_GPU_BASE(qdev); diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 92cd96582e..f1772a15bb 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1349,6 +1349,16 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) QTAILQ_INIT(&g->fenceq); } =20 +static void virtio_gpu_device_unrealize(DeviceState *qdev) +{ + VirtIOGPU *g =3D VIRTIO_GPU(qdev); + + qemu_bh_delete(g->cursor_bh); + qemu_bh_delete(g->ctrl_bh); + + virtio_gpu_base_device_unrealize(qdev); +} + void virtio_gpu_reset(VirtIODevice *vdev) { VirtIOGPU *g =3D VIRTIO_GPU(vdev); @@ -1447,6 +1457,7 @@ static void virtio_gpu_class_init(ObjectClass *klass,= void *data) vgbc->gl_flushed =3D virtio_gpu_handle_gl_flushed; =20 vdc->realize =3D virtio_gpu_device_realize; + vdc->unrealize =3D virtio_gpu_device_unrealize; vdc->reset =3D virtio_gpu_reset; vdc->get_config =3D virtio_gpu_get_config; vdc->set_config =3D virtio_gpu_set_config; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index a23efb9568..e9281c75f3 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -246,6 +246,7 @@ bool virtio_gpu_base_device_realize(DeviceState *qdev, VirtIOHandleOutput ctrl_cb, VirtIOHandleOutput cursor_cb, Error **errp); +void virtio_gpu_base_device_unrealize(DeviceState *qdev); void virtio_gpu_base_reset(VirtIOGPUBase *g); void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, struct virtio_gpu_resp_display_info *dpy_info); --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664202654; cv=none; d=zohomail.com; s=zohoarc; b=U2WCIKykLwXGL/n8GLaR9ewmteoxRxu8tGkobIbI83wn9X6TWrA2qHBu4H2W8oWadk+EG+GhuuwJIkrhw2KNQhxNCIAEesiQSko98ZhTK8tkZrjAvL953cFh5tBUui2zEdlrCgK1xuIjHW8iVogMjqLT7QhOO4Zu1PP3xLdi1DU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664202654; 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=DKHZnKCYHSahTxWwt7FWCFO+jNG60aafgBN64wrtnjQ=; b=Hhqt7SxRL04HvIWxWEo8MUynL5p/QJtLBb6CDT3gzS2hMmH9UcgAIJyLANFH3cP6/1wMu7QV7+qfO4srKNqcNjJCtvZwzwqClHdd+ovUQAMiaqhR+TJYzsKIr+3oy0PZiCRwlvrIOMHX8/RZ+W5hFpNnC0SJPWtk0jLxHZqua68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664202654538935.0080701914324; Mon, 26 Sep 2022 07:30:54 -0700 (PDT) Received: from localhost ([::1]:38380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocp8G-0003lK-Ez for importer@patchew.org; Mon, 26 Sep 2022 10:30:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2G-0003s6-De for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:40 -0400 Received: from madras.collabora.co.uk ([46.235.227.172]:55474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2D-00044H-B9 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:39 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 23C466602259; Mon, 26 Sep 2022 15:24:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202274; bh=ex01S2Vw15H8RdZuVZEW5Es12jyIKd1HUH+IwkAg1yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZJQgzoSxSrwWvKZ1X16NlM8qhEawRYVWGONKZIq5j8NKCKKNeiENnmTaNsWOXW6p OoyJ6hU4DGD9Edco7rK9O4Ub/muJd0t4TefIogDWUJzpDqRSLR7cJeMCD9ouWkcs26 k++E+HaFCVE29UWPVC+H15b/bhC3K+GZgdFsAMJg5iZDXsVPVE6I0p/JrDJ1vFUH8M 0c43i77qVDQhuj7lFGVVlJpmDanYo0Pi5E1axnIcnAULogF8cJZt5VioTfgpFuvxlI sDdEjhXeX7ZiDmo/aDq+CW2imWnnn6zkW7KQL3Ms5AEtgHm6UVk0ntQicAvxU7VLNl lZHHfkf52TTwg== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PATCH v3 6/9] virtio-gpu: Resource UUID Date: Mon, 26 Sep 2022 16:24:19 +0200 Message-Id: <20220926142422.22325-7-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=46.235.227.172; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664202655536100001 Content-Type: text/plain; charset="utf-8" Enable resource UUID feature and implement command resource assign UUID. This is done by introducing a hash table to map resource IDs to their UUIDs. Signed-off-by: Antonio Caggiano --- v3: Destroy the hash table in the unrealize function hw/display/trace-events | 1 + hw/display/virtio-gpu-base.c | 2 ++ hw/display/virtio-gpu-virgl.c | 11 +++++++++ hw/display/virtio-gpu.c | 41 ++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-gpu.h | 4 ++++ 5 files changed, 59 insertions(+) diff --git a/hw/display/trace-events b/hw/display/trace-events index 0c0ffcbe42..6632344322 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -41,6 +41,7 @@ virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t siz= e) "res 0x%x, size %" P virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x" +virtio_gpu_cmd_res_assign_uuid(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x" diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 5cb71e71ad..54792aa501 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -219,6 +219,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64= _t features, features |=3D (1 << VIRTIO_GPU_F_CONTEXT_INIT); } =20 + features |=3D (1 << VIRTIO_GPU_F_RESOURCE_UUID); + return features; } =20 diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 1bff8c66ce..f9d8ccfdf8 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -45,6 +45,10 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g, args.nr_samples =3D 0; args.flags =3D VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP; virgl_renderer_resource_create(&args, NULL, 0); + + struct virtio_gpu_simple_resource *res =3D g_new0(struct virtio_gpu_si= mple_resource, 1); + res->resource_id =3D c2d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 static void virgl_cmd_create_resource_3d(VirtIOGPU *g, @@ -69,6 +73,10 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, args.nr_samples =3D c3d.nr_samples; args.flags =3D c3d.flags; virgl_renderer_resource_create(&args, NULL, 0); + + struct virtio_gpu_simple_resource *res =3D g_new0(struct virtio_gpu_si= mple_resource, 1); + res->resource_id =3D c3d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 static void virgl_cmd_resource_unref(VirtIOGPU *g, @@ -624,6 +632,9 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, /* TODO add security */ virgl_cmd_ctx_detach_resource(g, cmd); break; + case VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID: + virtio_gpu_resource_assign_uuid(g, cmd); + break; case VIRTIO_GPU_CMD_GET_CAPSET_INFO: virgl_cmd_get_capset_info(g, cmd); break; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index f1772a15bb..09a92b6e76 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -939,6 +939,37 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g, virtio_gpu_cleanup_mapping(g, res); } =20 +void virtio_gpu_resource_assign_uuid(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_assign_uuid assign; + struct virtio_gpu_resp_resource_uuid resp; + QemuUUID *uuid =3D NULL; + + VIRTIO_GPU_FILL_CMD(assign); + virtio_gpu_bswap_32(&assign, sizeof(assign)); + trace_virtio_gpu_cmd_res_assign_uuid(assign.resource_id); + + res =3D virtio_gpu_find_check_resource(g, assign.resource_id, false, _= _func__, &cmd->error); + if (!res) { + return; + } + + memset(&resp, 0, sizeof(resp)); + resp.hdr.type =3D VIRTIO_GPU_RESP_OK_RESOURCE_UUID; + + uuid =3D g_hash_table_lookup(g->resource_uuids, GUINT_TO_POINTER(assig= n.resource_id)); + if (!uuid) { + uuid =3D g_new(QemuUUID, 1); + qemu_uuid_generate(uuid); + g_hash_table_insert(g->resource_uuids, GUINT_TO_POINTER(assign.res= ource_id), uuid); + } + + memcpy(resp.uuid, uuid, sizeof(QemuUUID)); + virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp)); +} + void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -987,6 +1018,9 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g, case VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING: virtio_gpu_resource_detach_backing(g, cmd); break; + case VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID: + virtio_gpu_resource_assign_uuid(g, cmd); + break; default: cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; break; @@ -1347,12 +1381,15 @@ void virtio_gpu_device_realize(DeviceState *qdev, E= rror **errp) QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); + + g->resource_uuids =3D g_hash_table_new_full(NULL, NULL, NULL, g_free); } =20 static void virtio_gpu_device_unrealize(DeviceState *qdev) { VirtIOGPU *g =3D VIRTIO_GPU(qdev); =20 + g_hash_table_destroy(g->resource_uuids); qemu_bh_delete(g->cursor_bh); qemu_bh_delete(g->ctrl_bh); =20 @@ -1382,6 +1419,10 @@ void virtio_gpu_reset(VirtIODevice *vdev) g_free(cmd); } =20 + if (g->resource_uuids) { + g_hash_table_remove_all(g->resource_uuids); + } + virtio_gpu_base_reset(VIRTIO_GPU_BASE(vdev)); } =20 diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index e9281c75f3..7d455b0a03 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -200,6 +200,8 @@ struct VirtIOGPU { QTAILQ_HEAD(, VGPUDMABuf) bufs; VGPUDMABuf *primary[VIRTIO_GPU_MAX_SCANOUTS]; } dmabuf; + + GHashTable *resource_uuids; }; =20 struct VirtIOGPUClass { @@ -273,6 +275,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_resource_assign_uuid(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664203695; cv=none; d=zohomail.com; s=zohoarc; b=HQX1zqVYQ0kWgyz4k/o+IijGMC+JuQix7oaS4qYKL2HuBAwGz8GMnunnypq0Zc/2oIwUvDmtC56blMDhrS0i5+NWzS0LGBUG6jo+Eoq/0PCmfKyTjxJHIt+qs9N/BuZhacdczxhXSuEw6ucqKthqyX/Zw0G0FcbQ/MIe3F5bFR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664203695; 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=hTvH7TC/PPygXQyfzINjZ5YFaY9gsiflpA5ENcZ7epE=; b=PyXwwxSbNlsCiDM+dG3xovd3lyywUaJlGI5PXqD+lOrkmu0j1D2Hx18k5Ak+dfrvan213qhhORhZw7Rl0A8jpgBixTXu5DZtCQ43Z2qXsrU5WpDscOaEGJS3awKn0kWAlXshSHXA4KyiMIj7xHNjkFray0SQ1KDawnlZU7EoS4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664203695279925.3865587316117; Mon, 26 Sep 2022 07:48:15 -0700 (PDT) Received: from localhost ([::1]:60468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpP2-0006ni-4H for importer@patchew.org; Mon, 26 Sep 2022 10:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2G-0003qv-8g for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:40 -0400 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]:33176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2D-00044N-FT for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id A779D660225F; Mon, 26 Sep 2022 15:24:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202275; bh=OPQZG7ytG7XOmX1N+cx0sIGXDh4qy3kHaMuKu0ArY9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYhH39S5QE+7hgL75V6B0d4WGVFcaZWpMNsWI6WkzEonwtrqIIr75ZNqoU51/ZS3t jViu+SQX2NvWI1jtaQ0A3woZ4KoplOkuuX0k9dVErU1EuTyWFCL7jFg0VxajaDFg2f nKFz6mLn4nH/gcyOy7B7hib5LKh2k9p/tFbNhNBxE65ZVMHO0a8cSkqt6HX7LyQz8r oO6ZlrzDl8ZuTrmPuwn9FQ4Aw5V+obYW4H5U73HfzGu6iNVlYr05hMHTi+nPL1R4tk jUBBxMoL/r8peQEbrMCsOfR1U0M3Qksa/zR7Leo9vcA9tXklxHA8swUtDWxyLRJnx8 j6A1hzWPYSkYA== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PATCH v3 7/9] virtio-gpu: Support Venus capset Date: Mon, 26 Sep 2022 16:24:20 +0200 Message-Id: <20220926142422.22325-8-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=2a00:1098:0:82:1000:25:2eeb:e5ab; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664203696311100001 Content-Type: text/plain; charset="utf-8" Add support for the Venus capset, which enables Vulkan support through the Venus Vulkan driver for virtio-gpu. Signed-off-by: Antonio Caggiano --- v3: Improve commit message hw/display/virtio-gpu-virgl.c | 21 +++++++++++++++++---- include/standard-headers/linux/virtio_gpu.h | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index f9d8ccfdf8..16f600adbb 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -388,6 +388,11 @@ static void virgl_cmd_get_capset_info(VirtIOGPU *g, virgl_renderer_get_cap_set(resp.capset_id, &resp.capset_max_version, &resp.capset_max_size); + } else if (info.capset_index =3D=3D 2) { + resp.capset_id =3D VIRTIO_GPU_CAPSET_VENUS; + virgl_renderer_get_cap_set(resp.capset_id, + &resp.capset_max_version, + &resp.capset_max_size); } else { resp.capset_max_version =3D 0; resp.capset_max_size =3D 0; @@ -820,10 +825,18 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) =20 int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g) { - uint32_t capset2_max_ver, capset2_max_size; + uint32_t capset2_max_ver, capset2_max_size, num_capsets; + num_capsets =3D 1; + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VIRGL2, - &capset2_max_ver, - &capset2_max_size); + &capset2_max_ver, + &capset2_max_size); + num_capsets +=3D capset2_max_ver ? 1 : 0; + + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VENUS, + &capset2_max_ver, + &capset2_max_size); + num_capsets +=3D capset2_max_size ? 1 : 0; =20 - return capset2_max_ver ? 2 : 1; + return num_capsets; } diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard= -headers/linux/virtio_gpu.h index 2da48d3d4c..2db643ed8f 100644 --- a/include/standard-headers/linux/virtio_gpu.h +++ b/include/standard-headers/linux/virtio_gpu.h @@ -309,6 +309,8 @@ struct virtio_gpu_cmd_submit { =20 #define VIRTIO_GPU_CAPSET_VIRGL 1 #define VIRTIO_GPU_CAPSET_VIRGL2 2 +/* 3 is reserved for gfxstream */ +#define VIRTIO_GPU_CAPSET_VENUS 4 =20 /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ struct virtio_gpu_get_capset_info { --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664203422; cv=none; d=zohomail.com; s=zohoarc; b=TGMxkB4NbVdkuaFweOXVgTFWD3nKxg5tZULJVBuS7CCF5LnemARNHxRtt4Lzb0IW38MTg6Henxlzu5AmHB+kK9YkdgJUniu0/OHfwVr0FTpAr/zkCvlUM6/x/Kd9LcxVMQtb3+DMGxTytZcEIglQojpmY9aXtK6MjDM966NzaLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664203422; 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=axIWJmzDSju1WvTruCk5NZqu9870+K2I98BSQeGpffs=; b=JVKffNxUcu+ElWiBpIQjZdj+vYn3aqOGpUDS4JOz25QXNalkYwtuOlT27jnxlDCHBXftsQ0Sf75+J8FWVehMOmVNsk/Kd69uml23p5FrhGHDlGrTl7ERn5Wh5IT4eOwD1l+RNI24J77ljyU32m1PhGf8ZbvuhEh5sgvHfAcN9kM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664203422937265.1022291801554; Mon, 26 Sep 2022 07:43:42 -0700 (PDT) Received: from localhost ([::1]:33690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpKf-0001vU-Nd for importer@patchew.org; Mon, 26 Sep 2022 10:43:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2G-0003rB-91 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:40 -0400 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]:33178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2D-00044Q-I1 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:38 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 338DB6602260; Mon, 26 Sep 2022 15:24:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202275; bh=S9ihd1+4Opupsb6uRLXElTS5VgsIkyJoMro+SmD6960=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXWSDGLBYtk6xiN5cCXJPHhF0y9Ggog3vgc/YdPdRzypM+4zxVzur1jqLkznqo5+G uHsOatPed8XM7+F+DMcbYmdjwjtuEuyg0MNTAeKIshJwEViZ16P+w3t4HhNCgTLaAk LBDTujH2u86VKofpNDi2fTbYbE3fokVzo2a+RHSSASjOu4bz0JR3L3JCSoj1ge0n68 h8y5AWLyWN9jf0uIbS3tpUXVNKXondBi/HfXZOQ6NkdbbsGWVEEEVq7Unho2JAirl2 vDYh98swzY4WR+23zyTBA6C/EWbZcqaIEH5OqdH9N0VSkXoDiBsR5NQgscRNo6yz6F O6grg6R7a1Y0g== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PATCH v3 8/9] virtio-gpu: Initialize Venus Date: Mon, 26 Sep 2022 16:24:21 +0200 Message-Id: <20220926142422.22325-9-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=2a00:1098:0:82:1000:25:2eeb:e5ab; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664203424705100001 Content-Type: text/plain; charset="utf-8" Request Venus when initializing VirGL. Signed-off-by: Antonio Caggiano --- hw/display/virtio-gpu-virgl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 16f600adbb..0f17bdddd0 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -806,7 +806,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; =20 - ret =3D virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs); + ret =3D virgl_renderer_init(g, VIRGL_RENDERER_VENUS, &virtio_gpu_3d_cb= s); if (ret !=3D 0) { error_report("virgl could not be initialized: %d", ret); return ret; --=20 2.34.1 From nobody Mon May 13 18:16:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1664205424; cv=none; d=zohomail.com; s=zohoarc; b=JVHTiI1ZWvJFOn3BprR3fmi8dCo37rji+mczC2WRZUYDsvjgB2NStUT0DraNlYPGRwYcOvpHBws8IQHUZ0jScc6+4O8ltW8zT0xrCDkpCESBzyFt29+lleN4hojmJj4laX93hymFsnGIn1pZUrpESDtgGfWB8l0VgtOWFAQVQAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664205424; 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=kc4Tuiz6jZaFg7Ehgc53JtrvlU2tDAwZ0H+Q96/NXz8=; b=bZc6jPqV0Vws32e1IZhK8nQMkMu4Oa7Z+a/djAL4fVYzmL1+7ctVHbS4/um6TMtKBLr5CI0BmVdP+pKkln50jASlial9GFqU0Q3DaJO+uSblCskH2gL+pTp6byRL44Tu6J4H+7XrZiuXQSkn6d87MbcirxJabhndbCJybP3J1nE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1664205424097400.2709776024525; Mon, 26 Sep 2022 08:17:04 -0700 (PDT) Received: from localhost ([::1]:41374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocpqu-0007Wf-RB for importer@patchew.org; Mon, 26 Sep 2022 11:17:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2I-0003x2-D0 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:42 -0400 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]:33180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocp2E-00044k-Kk for qemu-devel@nongnu.org; Mon, 26 Sep 2022 10:24:42 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id D1F7D6602261; Mon, 26 Sep 2022 15:24:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664202276; bh=yyEkMbpfoyqOC7Bjvc1demiUi5fDwZG9YfIFnDv7TqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JDj69LVdt1OfS8MOiI3ZD3oZishsIaiMHKY724/u1DhzWEB6VNgEHkI+8Op5o1fF+ WX0L3F16HOAd9zv58xPk6ovpvmnA+hl815N3mfniMexRYnf8VqRUY2h/kld6ufCw7z OfYOozTGCNt9nyxAcfBwxQUUto5lj6WKqIHo+AAP6Bug1QXdIUnGhd7O3UPUUguckc yPz5LbtoTUSURpPxgfchuC+3x+zlXcWeN7GiXxjA0jwPmdicx5vhiIbTuw7ccoemFu KeUFaaxMkwhhIiihov+00ptaNUao9r4SKf0A60dK/FDyjprbvu1ED5Dbkn/Gp/u8zW QrJ5qJvTFG+fA== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PATCH v3 9/9] virtio-gpu: Get EGL Display callback Date: Mon, 26 Sep 2022 16:24:22 +0200 Message-Id: <20220926142422.22325-10-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926142422.22325-1-antonio.caggiano@collabora.com> References: <20220926142422.22325-1-antonio.caggiano@collabora.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=2a00:1098:0:82:1000:25:2eeb:e5ab; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1664205425632100001 Content-Type: text/plain; charset="utf-8" Implement get_egl_display callback for virglrenderer. Signed-off-by: Antonio Caggiano --- hw/display/virtio-gpu-virgl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 0f17bdddd0..0fd9ad8a3d 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -18,6 +18,7 @@ #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-gpu-bswap.h" #include "hw/virtio/virtio-iommu.h" +#include =20 #include =20 @@ -743,12 +744,18 @@ static int virgl_make_context_current(void *opaque, i= nt scanout_idx, qctx); } =20 +static void *virgl_get_egl_display(void *opaque) +{ + return eglGetCurrentDisplay(); +} + static struct virgl_renderer_callbacks virtio_gpu_3d_cbs =3D { - .version =3D 1, + .version =3D 4, .write_fence =3D virgl_write_fence, .create_gl_context =3D virgl_create_context, .destroy_gl_context =3D virgl_destroy_context, .make_current =3D virgl_make_context_current, + .get_egl_display =3D virgl_get_egl_display, }; =20 static void virtio_gpu_print_stats(void *opaque) --=20 2.34.1