[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] virtio-gpu: set hostaddr for virtio iGPU


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "Edgar E . Iglesias" <edgar.iglesias@xxxxxxxxx>, "Michael S . Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Julia Zhang <julia.zhang@xxxxxxx>
  • Date: Sat, 7 Dec 2024 18:55:36 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+vj8HPAjMVLVff8tdV9jtHw/j79hcngd7Jdhce14dQI=; b=V1aSL+g2kLX4ehPGo7eQuGWq5oFVXx0p69U3atB3mJMHJsO3AwRhGoJmxJA0NU7AKOnPYxcXU/D4lvTH9KNEEzC0od7Qm57sYx02OMLJvyzUEkF/apzlK4IBMF5jy9hu9yEYagLqZo/ym6+CFpZAaZ7prLI1024iSvz9GjuZHaSOc54G/dUmt87cm5H2Bv2pqCdIpJ1pw6OMEfFyuwEmcW3dG1og3bfbX6tp+1D7xxnbxKya5wkPN1jgYWayOM+ozTVGa14VEMVIspUAFUECLvLQSK+WFMCpkXsJQOnJfzYC0Kfp+2A2zBHZlebHOxAyUB6o2aL+JGx1TTV8j8gmDQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eTWqjXj/cHSYr9UurojeUnLoCM8xnLBh4kp2mmvwj+GNr0RCF09Fod71jpmoo2ed9v3XL2CWtoNOxMcE9CVBxrbm3HGucK6FjnEX+UgU5Cji7ykrh6cO5ayQJBmnThVZYRG1XgjQU6lKM8wBhuV1dKStdrxLJbL8GyJlVnulZ5lq0DRAuAFw/GZPZ4fYDVsq7A03B0Yw3VD5/7qZ6tan8Dx3q5LEdcoZxF/TyIzHGGv+GLxS2UDxqnKffZZyk3PWibkNyW9YbKA+cdhYxM1KrVYTyc1c1QolaqwMzGw8u920NXyLJtFREfD1W/m5K0rtxhdT0N0H8iXB+qnKtMP2YQ==
  • Cc: Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, "Xenia Ragiadakou" <burzalodowa@xxxxxxxxx>, Julia Zhang <julia.zhang@xxxxxxx>, "Chen Jiqian" <Jiqian.Chen@xxxxxxx>, Huang Rui <ray.huang@xxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>, Zhu Lingshan <Lingshan.Zhu@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, <qemu-devel@xxxxxxxxxx>
  • Delivery-date: Sat, 07 Dec 2024 10:56:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Get physical pci notation from hvm file and set hostaddr for virtio
iGPU. 

Signed-off-by: Julia Zhang <julia.zhang@xxxxxxx>
---
 hw/display/virtio-gpu.c        |  6 ++++++
 hw/xen/xen_pt.c                | 10 +++++-----
 hw/xen/xen_pt.h                |  1 -
 include/hw/pci/pci_device.h    |  1 +
 include/hw/virtio/virtio-gpu.h |  2 ++
 5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index c0570ef856..d68b64ac22 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -26,6 +26,7 @@
 #include "hw/virtio/virtio-gpu-bswap.h"
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/virtio/virtio-bus.h"
+#include "hw/virtio/virtio-pci.h"
 #include "hw/qdev-properties.h"
 #include "qemu/log.h"
 #include "qemu/memfd.h"
@@ -1458,6 +1459,8 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error 
**errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
     VirtIOGPU *g = VIRTIO_GPU(qdev);
+    BusState *qbus = BUS(qdev_get_parent_bus(qdev));
+    VirtIOPCIProxy *proxy = VIRTIO_PCI(qbus->parent);
 
     if (virtio_gpu_blob_enabled(g->parent_obj.conf)) {
         if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) &&
@@ -1508,6 +1511,8 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error 
**errp)
     QTAILQ_INIT(&g->reslist);
     QTAILQ_INIT(&g->cmdq);
     QTAILQ_INIT(&g->fenceq);
+
+    proxy->pci_dev.hostaddr = g->parent_obj.conf.hostaddr;
 }
 
 static void virtio_gpu_device_unrealize(DeviceState *qdev)
@@ -1669,6 +1674,7 @@ static Property virtio_gpu_properties[] = {
                     VIRTIO_GPU_FLAG_BLOB_ENABLED, false),
     DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0),
     DEFINE_PROP_UINT8("x-scanout-vmstate-version", VirtIOGPU, 
scanout_vmstate_version, 2),
+    DEFINE_PROP_PCI_HOST_DEVADDR("hostaddr", VirtIOGPU, 
parent_obj.conf.hostaddr),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index c0042b3515..8e5ff09b66 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -828,9 +828,9 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
 
     /* register real device */
     XEN_PT_LOG(d, "Assigning real physical device %02x:%02x.%d"
-               " to devfn 0x%x\n",
+               " to devfn 0x%x, %02x:%02x.%d\n",
                s->hostaddr.bus, s->hostaddr.slot, s->hostaddr.function,
-               s->dev.devfn);
+               s->dev.devfn, pci_bus_num(pci_get_bus(&s->dev)), 
PCI_SLOT(s->dev.devfn), PCI_FUNC(s->dev.devfn));
 
     s->is_virtfn = s->real_device.is_virtfn;
     if (s->is_virtfn) {
@@ -991,7 +991,7 @@ static void xen_pt_unregister_device(PCIDevice *d)
 }
 
 static Property xen_pci_passthrough_properties[] = {
-    DEFINE_PROP_PCI_HOST_DEVADDR("hostaddr", XenPCIPassthroughState, hostaddr),
+    DEFINE_PROP_PCI_HOST_DEVADDR("hostaddr", XenPCIPassthroughState, 
dev.hostaddr),
     DEFINE_PROP_BOOL("permissive", XenPCIPassthroughState, permissive, false),
     DEFINE_PROP_END_OF_LIST(),
 };
@@ -1022,8 +1022,8 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error 
**errp)
     PCIBus *pci_bus = pci_get_bus(pci_dev);
 
     xen_host_pci_device_get(&s->real_device,
-                            s->hostaddr.domain, s->hostaddr.bus,
-                            s->hostaddr.slot, s->hostaddr.function,
+                            s->dev.hostaddr.domain, s->dev.hostaddr.bus,
+                            s->dev.hostaddr.slot, s->dev.hostaddr.function,
                             errp);
     if (*errp) {
         error_append_hint(errp, "Failed to \"open\" the real pci device");
diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h
index 095a0f0365..f61a134ff5 100644
--- a/hw/xen/xen_pt.h
+++ b/hw/xen/xen_pt.h
@@ -233,7 +233,6 @@ typedef struct XenPTMSIX {
 struct XenPCIPassthroughState {
     PCIDevice dev;
 
-    PCIHostDeviceAddress hostaddr;
     bool is_virtfn;
     bool permissive;
     bool permissive_warned;
diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
index 8eaf0d58bb..b7acf3822d 100644
--- a/include/hw/pci/pci_device.h
+++ b/include/hw/pci/pci_device.h
@@ -56,6 +56,7 @@ typedef struct PCIReqIDCache PCIReqIDCache;
 
 struct PCIDevice {
     DeviceState qdev;
+    PCIHostDeviceAddress hostaddr;
     bool partially_hotplugged;
     bool has_power;
 
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 553799b8cc..e385794a06 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -24,6 +24,7 @@
 #include "standard-headers/linux/virtio_gpu.h"
 #include "standard-headers/linux/virtio_ids.h"
 #include "qom/object.h"
+#include "hw/pci/pci.h"
 
 #define TYPE_VIRTIO_GPU_BASE "virtio-gpu-base"
 OBJECT_DECLARE_TYPE(VirtIOGPUBase, VirtIOGPUBaseClass,
@@ -125,6 +126,7 @@ struct virtio_gpu_base_conf {
     uint32_t xres;
     uint32_t yres;
     uint64_t hostmem;
+    PCIHostDeviceAddress hostaddr;
 };
 
 struct virtio_gpu_ctrl_command {
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.