diff mbox series

[v2,9/9] vfio/igd: Introduce x-igd-lpc option for LPC bridge ID quirk

Message ID 20250303175220.74917-10-tomitamoeko@gmail.com (mailing list archive)
State New
Headers show
Series vfio/igd: Decoupling quirks with legacy mode | expand

Commit Message

Tomita Moeko March 3, 2025, 5:52 p.m. UTC
The LPC bridge/Host bridge IDs quirk is also not dependent on legacy
mode. Recent Windows driver no longer depends on these IDs, as well as
Linux i915 driver, while UEFI GOP seems still needs them. Make it an
option to allow users enabling and disabling it as needed.

Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
---
 hw/vfio/igd.c | 14 ++++++++------
 hw/vfio/pci.c |  2 ++
 hw/vfio/pci.h |  3 +++
 3 files changed, 13 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
index 9bfaa24c24..d3ebbebe4e 100644
--- a/hw/vfio/igd.c
+++ b/hw/vfio/igd.c
@@ -557,13 +557,9 @@  bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
             return false;
         }
 
-        /* Enable OpRegion quirk */
+        /* Enable OpRegion and LPC brige quirk */
         vdev->features |= VFIO_FEATURE_ENABLE_IGD_OPREGION;
-
-        /* Setup LPC bridge / Host bridge PCI IDs */
-        if (!vfio_pci_igd_setup_lpc_bridge(vdev, errp)) {
-            return false;
-        }
+        vdev->features |= VFIO_FEATURE_ENABLE_IGD_LPC;
     }
 
     /* Setup OpRegion access */
@@ -572,6 +568,12 @@  bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
         return false;
     }
 
+    /* Setup LPC bridge / Host bridge PCI IDs */
+    if ((vdev->features & VFIO_FEATURE_ENABLE_IGD_LPC) &&
+        !vfio_pci_igd_setup_lpc_bridge(vdev, errp)) {
+        return false;
+     }
+
     /*
      * Allow user to override dsm size using x-igd-gms option, in multiples of
      * 32MiB. This option should only be used when the desired size cannot be
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 8fb415cf45..1e49c4b58b 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3354,6 +3354,8 @@  static const Property vfio_pci_dev_properties[] = {
                     VFIO_FEATURE_ENABLE_REQ_BIT, true),
     DEFINE_PROP_BIT("x-igd-opregion", VFIOPCIDevice, features,
                     VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT, false),
+    DEFINE_PROP_BIT("x-igd-lpc", VFIOPCIDevice, features,
+                    VFIO_FEATURE_ENABLE_IGD_LPC_BIT, false),
     DEFINE_PROP_BIT("x-igd-legacy-mode", VFIOPCIDevice, features,
                     VFIO_FEATURE_ENABLE_IGD_LEGACY_MODE_BIT, true),
     DEFINE_PROP_ON_OFF_AUTO("enable-migration", VFIOPCIDevice,
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 4bddfb80f8..dd645a5465 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -154,6 +154,9 @@  struct VFIOPCIDevice {
 #define VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT 2
 #define VFIO_FEATURE_ENABLE_IGD_OPREGION \
                                 (1 << VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT)
+#define VFIO_FEATURE_ENABLE_IGD_LPC_BIT 3
+#define VFIO_FEATURE_ENABLE_IGD_LPC \
+                                (1 << VFIO_FEATURE_ENABLE_IGD_LPC_BIT)
 #define VFIO_FEATURE_ENABLE_IGD_LEGACY_MODE_BIT 4
 #define VFIO_FEATURE_ENABLE_IGD_LEGACY_MODE \
                                 (1 << VFIO_FEATURE_ENABLE_IGD_LEGACY_MODE_BIT)