[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 1/3] virtio-gpu: set hostaddr for virtio iGPU
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |