Skip to content

Commit 35259ff

Browse files
committed
PCI: Log device type during enumeration
Log the device type when enumeration a device. Sample output changes: - pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 + pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 conventional PCI endpoint - pci 0000:00:1c.0: [8086:a110] type 01 class 0x060400 + pci 0000:00:1c.0: [8086:a110] type 01 class 0x060400 PCIe Root Port Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent b85ea95 commit 35259ff

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

drivers/pci/probe.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,43 @@ static void early_dump_pci_device(struct pci_dev *pdev)
18171817
value, 256, false);
18181818
}
18191819

1820+
static const char *pci_type_str(struct pci_dev *dev)
1821+
{
1822+
static const char * const str[] = {
1823+
"PCIe Endpoint",
1824+
"PCIe Legacy Endpoint",
1825+
"PCIe unknown",
1826+
"PCIe unknown",
1827+
"PCIe Root Port",
1828+
"PCIe Switch Upstream Port",
1829+
"PCIe Switch Downstream Port",
1830+
"PCIe to PCI/PCI-X bridge",
1831+
"PCI/PCI-X to PCIe bridge",
1832+
"PCIe Root Complex Integrated Endpoint",
1833+
"PCIe Root Complex Event Collector",
1834+
};
1835+
int type;
1836+
1837+
if (pci_is_pcie(dev)) {
1838+
type = pci_pcie_type(dev);
1839+
if (type < ARRAY_SIZE(str))
1840+
return str[type];
1841+
1842+
return "PCIe unknown";
1843+
}
1844+
1845+
switch (dev->hdr_type) {
1846+
case PCI_HEADER_TYPE_NORMAL:
1847+
return "conventional PCI endpoint";
1848+
case PCI_HEADER_TYPE_BRIDGE:
1849+
return "conventional PCI bridge";
1850+
case PCI_HEADER_TYPE_CARDBUS:
1851+
return "CardBus bridge";
1852+
default:
1853+
return "conventional PCI";
1854+
}
1855+
}
1856+
18201857
/**
18211858
* pci_setup_device - Fill in class and map information of a device
18221859
* @dev: the device structure to fill
@@ -1887,8 +1924,9 @@ int pci_setup_device(struct pci_dev *dev)
18871924

18881925
pci_set_removable(dev);
18891926

1890-
pci_info(dev, "[%04x:%04x] type %02x class %#08x\n",
1891-
dev->vendor, dev->device, dev->hdr_type, dev->class);
1927+
pci_info(dev, "[%04x:%04x] type %02x class %#08x %s\n",
1928+
dev->vendor, dev->device, dev->hdr_type, dev->class,
1929+
pci_type_str(dev));
18921930

18931931
/* Device class may be changed after fixup */
18941932
class = dev->class >> 8;

0 commit comments

Comments
 (0)