Skip to content

Commit 0a8f410

Browse files
committed
PCI: Move Apex Edge TPU class quirk to fix BAR assignment
Some Google Apex Edge TPU devices have a class code of 0 (PCI_CLASS_NOT_DEFINED). This prevents the PCI core from assigning resources for the Apex BARs because __dev_sort_resources() ignores classless devices, host bridges, and IOAPICs. On x86, firmware typically assigns those resources, so this was not a problem. But on some architectures, firmware does *not* assign BARs, and since the PCI core didn't do it either, the Apex device didn't work correctly: apex 0000:01:00.0: can't enable device: BAR 0 [mem 0x00000000-0x00003fff 64bit pref] not claimed apex 0000:01:00.0: error enabling PCI device f390d08 ("staging: gasket: apex: fixup undefined PCI class") added a quirk to fix the class code, but it was in the apex driver, and if the driver was built as a module, it was too late to help. Move the quirk to the PCI core, where it will always run early enough that the PCI core will assign resources if necessary. Link: https://lore.kernel.org/r/CAEzXK1r0Er039iERnc2KJ4jn7ySNUOG9H=Ha8TD8XroVqiZjgg@mail.gmail.com Fixes: f390d08 ("staging: gasket: apex: fixup undefined PCI class") Reported-by: Luís Mendes <[email protected]> Debugged-by: Luís Mendes <[email protected]> Tested-by: Luis Mendes <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: Todd Poynor <[email protected]>
1 parent 8f3d9f3 commit 0a8f410

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/pci/quirks.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5567,3 +5567,10 @@ static void pci_fixup_no_d0_pme(struct pci_dev *dev)
55675567
dev->pme_support &= ~(PCI_PM_CAP_PME_D0 >> PCI_PM_CAP_PME_SHIFT);
55685568
}
55695569
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASMEDIA, 0x2142, pci_fixup_no_d0_pme);
5570+
5571+
static void apex_pci_fixup_class(struct pci_dev *pdev)
5572+
{
5573+
pdev->class = (PCI_CLASS_SYSTEM_OTHER << 8) | pdev->class;
5574+
}
5575+
DECLARE_PCI_FIXUP_CLASS_HEADER(0x1ac1, 0x089a,
5576+
PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class);

drivers/staging/gasket/apex_driver.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,6 @@ static const struct pci_device_id apex_pci_ids[] = {
570570
{ PCI_DEVICE(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID) }, { 0 }
571571
};
572572

573-
static void apex_pci_fixup_class(struct pci_dev *pdev)
574-
{
575-
pdev->class = (PCI_CLASS_SYSTEM_OTHER << 8) | pdev->class;
576-
}
577-
DECLARE_PCI_FIXUP_CLASS_HEADER(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID,
578-
PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class);
579-
580573
static int apex_pci_probe(struct pci_dev *pci_dev,
581574
const struct pci_device_id *id)
582575
{

0 commit comments

Comments
 (0)