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
This commit is contained in:
Bjorn Helgaas
2025-07-31 16:11:40 -05:00
6 changed files with 21 additions and 7 deletions

View File

@@ -437,7 +437,7 @@ find_active_client(struct list_head *head)
*/
bool vga_switcheroo_client_probe_defer(struct pci_dev *pdev)
{
if ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
if (pci_is_display(pdev)) {
/*
* apple-gmux is needed on pre-retina MacBook Pro
* to probe the panel if pdev is the inactive GPU.

View File

@@ -34,7 +34,7 @@
#define ROOT_SIZE VTD_PAGE_SIZE
#define CONTEXT_SIZE VTD_PAGE_SIZE
#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
#define IS_GFX_DEVICE(pdev) pci_is_display(pdev)
#define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)

View File

@@ -437,8 +437,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
bool vfio_pci_is_intel_display(struct pci_dev *pdev)
{
return (pdev->vendor == PCI_VENDOR_ID_INTEL) &&
((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY);
return (pdev->vendor == PCI_VENDOR_ID_INTEL) && pci_is_display(pdev);
}
int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)

View File

@@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev)
return false;
}
/**
* pci_is_display - check if the PCI device is a display controller
* @pdev: PCI device
*
* Determine whether the given PCI device corresponds to a display
* controller. Display controllers are typically used for graphical output
* and are identified based on their class code.
*
* Return: true if the PCI device is a display controller, false otherwise.
*/
static inline bool pci_is_display(struct pci_dev *pdev)
{
return (pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY;
}
#define for_each_pci_bridge(dev, bus) \
list_for_each_entry(dev, &bus->devices, bus_list) \
if (!pci_is_bridge(dev)) {} else

View File

@@ -155,7 +155,7 @@ static int i915_gfx_present(struct pci_dev *hdac_pci)
for_each_pci_dev(display_dev) {
if (display_dev->vendor != PCI_VENDOR_ID_INTEL ||
(display_dev->class >> 16) != PCI_BASE_CLASS_DISPLAY)
!pci_is_display(display_dev))
continue;
if (pci_match_id(denylist, display_dev))

View File

@@ -1465,7 +1465,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
* the dGPU is the one who is involved in
* vgaswitcheroo.
*/
if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
if (pci_is_display(p) &&
(atpx_present() || apple_gmux_detect(NULL, NULL)))
return p;
pci_dev_put(p);
@@ -1477,7 +1477,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)
p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
pci->bus->number, 0);
if (p) {
if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY)
if (pci_is_display(p))
return p;
pci_dev_put(p);
}