Skip to content

Commit 4111216

Browse files
tomitamoekoawilliam
authored andcommitted
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: Tomita Moeko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent d082ecb commit 4111216

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ static int vfio_pci_open_device(struct vfio_device *core_vdev)
111111
if (ret)
112112
return ret;
113113

114-
if (vfio_pci_is_vga(pdev) &&
115-
pdev->vendor == PCI_VENDOR_ID_INTEL &&
116-
IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
114+
if (vfio_pci_is_intel_display(pdev)) {
117115
ret = vfio_pci_igd_init(vdev);
118116
if (ret && ret != -ENODEV) {
119117
pci_warn(pdev, "Failed to setup Intel IGD regions\n");

drivers/vfio/pci/vfio_pci_igd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
435435
return 0;
436436
}
437437

438+
bool vfio_pci_is_intel_display(struct pci_dev *pdev)
439+
{
440+
return (pdev->vendor == PCI_VENDOR_ID_INTEL) &&
441+
((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY);
442+
}
443+
438444
int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
439445
{
440446
int ret;

drivers/vfio/pci/vfio_pci_priv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
6767
u16 cmd);
6868

6969
#ifdef CONFIG_VFIO_PCI_IGD
70+
bool vfio_pci_is_intel_display(struct pci_dev *pdev);
7071
int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
7172
#else
73+
static inline bool vfio_pci_is_intel_display(struct pci_dev *pdev)
74+
{
75+
return false;
76+
}
77+
7278
static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
7379
{
7480
return -ENODEV;

0 commit comments

Comments
 (0)