Skip to contentSkip to conversation

vfio/igd: handle q35 machine type

PATCH Superseded Gerd Hoffmann 1 participant 1 message Mar 4, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio/igd: handle q35 machine type

Basically skip the lpc quirks with -M q35. Applies on top of the vfio-igd patch series by alex.

---
 hw/vfio/pci-quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/vfio/pci-quirks.c +15 -0
index 5828362..52df46a 100644
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/nvram/fw_cfg.h"
+#include "hw/i386/ich9.h"
 #include "pci.h"
 #include "trace.h"
 #include "qemu/range.h"
@@ -1410,6 +1411,7 @@ int vfio_pci_igd_lpc_init(VFIOPCIDevice *vdev,
                            struct vfio_region_info *region)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(vdev);
+    PCIBus *bus;
     PCIDevice *lpc_bridge;
     int ret;
 
@@ -1423,6 +1425,19 @@ int vfio_pci_igd_lpc_init(VFIOPCIDevice *vdev,
 
     dc->hotpluggable = false;
 
+    bus = pci_device_root_bus(&vdev->pdev);
+    lpc_bridge = pci_find_device(bus, 0, PCI_DEVFN(0x1f, 0));
+    if (lpc_bridge) {
+        const char *type = object_get_typename(OBJECT(lpc_bridge));
+        if (strcmp(type, TYPE_ICH9_LPC_DEVICE) == 0) {
+            /* q35 lpc present */
+            return 0;
+        } else {
+            /* Huh?  Something else grabbed the slot */
+            return -EBUSY;
+        }
+    }
+
     lpc_bridge = pci_create_simple(pci_device_root_bus(&vdev->pdev),
                                    PCI_DEVFN(0x1f, 0),
                                    "vfio-pci-igd-lpc-bridge");
Signature · 1 line
1.8.3.1