Skip to content

Commit e6035a0

Browse files
committed
Merge branch 'pci/boot-display'
- Add pci_is_display() to check for "Display" base class and use it in ALSA hda, vfio, vga_switcheroo, vt-d (Mario Limonciello) * pci/boot-display: ALSA: hda: Use pci_is_display() iommu/vt-d: Use pci_is_display() vga_switcheroo: Use pci_is_display() vfio/pci: Use pci_is_display() PCI: Add pci_is_display() to check if device is a display controller
2 parents 010c310 + 6642adf commit e6035a0

6 files changed

Lines changed: 21 additions & 7 deletions

File tree

drivers/gpu/vga/vga_switcheroo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ find_active_client(struct list_head *head)
437437
*/
438438
bool vga_switcheroo_client_probe_defer(struct pci_dev *pdev)
439439
{
440-
if ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
440+
if (pci_is_display(pdev)) {
441441
/*
442442
* apple-gmux is needed on pre-retina MacBook Pro
443443
* to probe the panel if pdev is the inactive GPU.

drivers/iommu/intel/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define ROOT_SIZE VTD_PAGE_SIZE
3535
#define CONTEXT_SIZE VTD_PAGE_SIZE
3636

37-
#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
37+
#define IS_GFX_DEVICE(pdev) pci_is_display(pdev)
3838
#define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
3939
#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
4040
#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)

drivers/vfio/pci/vfio_pci_igd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
437437

438438
bool vfio_pci_is_intel_display(struct pci_dev *pdev)
439439
{
440-
return (pdev->vendor == PCI_VENDOR_ID_INTEL) &&
441-
((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY);
440+
return (pdev->vendor == PCI_VENDOR_ID_INTEL) && pci_is_display(pdev);
442441
}
443442

444443
int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)

include/linux/pci.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev)
744744
return false;
745745
}
746746

747+
/**
748+
* pci_is_display - check if the PCI device is a display controller
749+
* @pdev: PCI device
750+
*
751+
* Determine whether the given PCI device corresponds to a display
752+
* controller. Display controllers are typically used for graphical output
753+
* and are identified based on their class code.
754+
*
755+
* Return: true if the PCI device is a display controller, false otherwise.
756+
*/
757+
static inline bool pci_is_display(struct pci_dev *pdev)
758+
{
759+
return (pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY;
760+
}
761+
747762
#define for_each_pci_bridge(dev, bus) \
748763
list_for_each_entry(dev, &bus->devices, bus_list) \
749764
if (!pci_is_bridge(dev)) {} else

sound/hda/hdac_i915.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int i915_gfx_present(struct pci_dev *hdac_pci)
155155

156156
for_each_pci_dev(display_dev) {
157157
if (display_dev->vendor != PCI_VENDOR_ID_INTEL ||
158-
(display_dev->class >> 16) != PCI_BASE_CLASS_DISPLAY)
158+
!pci_is_display(display_dev))
159159
continue;
160160

161161
if (pci_match_id(denylist, display_dev))

sound/pci/hda/hda_intel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
14651465
* the dGPU is the one who is involved in
14661466
* vgaswitcheroo.
14671467
*/
1468-
if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
1468+
if (pci_is_display(p) &&
14691469
(atpx_present() || apple_gmux_detect(NULL, NULL)))
14701470
return p;
14711471
pci_dev_put(p);
@@ -1477,7 +1477,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
14771477
p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
14781478
pci->bus->number, 0);
14791479
if (p) {
1480-
if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY)
1480+
if (pci_is_display(p))
14811481
return p;
14821482
pci_dev_put(p);
14831483
}

0 commit comments

Comments
 (0)