Commit 41112160 authored by Tomita Moeko's avatar Tomita Moeko Committed by Alex Williamson
Browse files

vfio/pci: match IGD devices in display controller class



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. A new helper function
vfio_pci_is_intel_display() is introduced to check if the device might
be an IGD device.

Signed-off-by: default avatarTomita Moeko <tomitamoeko@gmail.com>
Link: https://lore.kernel.org/r/20250123163416.7653-1-tomitamoeko@gmail.com


Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent d082ecbc
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -111,9 +111,7 @@ 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 (vfio_pci_is_intel_display(pdev)) {
		ret = vfio_pci_igd_init(vdev);
		if (ret && ret != -ENODEV) {
			pci_warn(pdev, "Failed to setup Intel IGD regions\n");
+6 −0
Original line number Diff line number Diff line
@@ -435,6 +435,12 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
	return 0;
}

bool vfio_pci_is_intel_display(struct pci_dev *pdev)
{
	return (pdev->vendor == PCI_VENDOR_ID_INTEL) &&
	       ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY);
}

int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
{
	int ret;
+6 −0
Original line number Diff line number Diff line
@@ -67,8 +67,14 @@ void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
					u16 cmd);

#ifdef CONFIG_VFIO_PCI_IGD
bool vfio_pci_is_intel_display(struct pci_dev *pdev);
int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
#else
static inline bool vfio_pci_is_intel_display(struct pci_dev *pdev)
{
	return false;
}

static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
{
	return -ENODEV;