mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] vfio/pci: update igd matching conditions
@ 2024-12-30 16:10 Tomita Moeko
  2025-01-03 17:44 ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: Tomita Moeko @ 2024-12-30 16:10 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Tomita Moeko, kvm, linux-kernel

igd device can either expose as a VGA controller or display controller
depending on whether it is configured as the primary display device in
BIOS. In both cases, the OpRegion may be present. Also checks if the
device is at bdf 00:02.0 to avoid setting up igd-specific regions on
Intel discrete GPUs.

Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
---
Changelog:
v2:
Fix misuse of pci_get_domain_bus_and_slot(), now only compares bdf
without touching device reference count.
Link: https://lore.kernel.org/all/20241229155140.7434-1-tomitamoeko@gmail.com/

 drivers/vfio/pci/vfio_pci.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index e727941f589d..906a1db46d15 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -111,9 +111,11 @@ static int vfio_pci_open_device(struct vfio_device *core_vdev)
 	if (ret)
 		return ret;
 
-	if (vfio_pci_is_vga(pdev) &&
-	    pdev->vendor == PCI_VENDOR_ID_INTEL &&
-	    IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
+	if (IS_ENABLED(CONFIG_VFIO_PCI_IGD) &&
+	    (pdev->vendor == PCI_VENDOR_ID_INTEL) &&
+	    (((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) ||
+	     ((pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER)) &&
+	    (pci_dev_id(pdev) == PCI_DEVID(0, PCI_DEVFN(2, 0)))) {
 		ret = vfio_pci_igd_init(vdev);
 		if (ret && ret != -ENODEV) {
 			pci_warn(pdev, "Failed to setup Intel IGD regions\n");
-- 
2.45.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-04 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-30 16:10 [PATCH v2] vfio/pci: update igd matching conditions Tomita Moeko
2025-01-03 17:44 ` Alex Williamson
2025-01-04 16:09   ` Tomita Moeko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®