Skip to content

Commit ddc9753

Browse files
Shaohua Lijbarnes993
authored andcommitted
PCI: don't enable ASPM on devices with mixed PCIe/PCI functions
The Slot 03:00.* of JMicron controller has two functions, but one is PCIE endpoint the other isn't PCIE device, very strange. PCIE spec defines all functions should have the same config for ASPM, so disable ASPM for the whole slot in this case. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent c1f69db commit ddc9753

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/pci/pcie/aspm.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,23 @@ static void free_link_state(struct pci_dev *pdev)
506506
pdev->link_state = NULL;
507507
}
508508

509+
static int pcie_aspm_sanity_check(struct pci_dev *pdev)
510+
{
511+
struct pci_dev *child_dev;
512+
int child_pos;
513+
514+
/*
515+
* Some functions in a slot might not all be PCIE functions, very
516+
* strange. Disable ASPM for the whole slot
517+
*/
518+
list_for_each_entry(child_dev, &pdev->subordinate->devices, bus_list) {
519+
child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP);
520+
if (!child_pos)
521+
return -EINVAL;
522+
}
523+
return 0;
524+
}
525+
509526
/*
510527
* pcie_aspm_init_link_state: Initiate PCI express link state.
511528
* It is called after the pcie and its children devices are scaned.
@@ -526,6 +543,9 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
526543
if (list_empty(&pdev->subordinate->devices))
527544
goto out;
528545

546+
if (pcie_aspm_sanity_check(pdev))
547+
goto out;
548+
529549
mutex_lock(&aspm_lock);
530550

531551
link_state = kzalloc(sizeof(*link_state), GFP_KERNEL);

0 commit comments

Comments
 (0)