Skip to content

Commit 575b98e

Browse files
committed
PCI/ASPM: Add pcie_aspm_remove_cap() to override advertised link states
Add pcie_aspm_remove_cap(). A quirk can use this to prevent use of ASPM L0s or L1 link states, even if the device advertised support for them. Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Shawn Lin <[email protected]> Reviewed-by: Lukas Wunner <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 4495bff commit 575b98e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/pci/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,13 +958,15 @@ void pci_save_aspm_l1ss_state(struct pci_dev *dev);
958958
void pci_restore_aspm_l1ss_state(struct pci_dev *dev);
959959

960960
#ifdef CONFIG_PCIEASPM
961+
void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap);
961962
void pcie_aspm_init_link_state(struct pci_dev *pdev);
962963
void pcie_aspm_exit_link_state(struct pci_dev *pdev);
963964
void pcie_aspm_pm_state_change(struct pci_dev *pdev, bool locked);
964965
void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
965966
void pci_configure_ltr(struct pci_dev *pdev);
966967
void pci_bridge_reconfigure_ltr(struct pci_dev *pdev);
967968
#else
969+
static inline void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap) { }
968970
static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { }
969971
static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { }
970972
static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev, bool locked) { }

drivers/pci/pcie/aspm.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,19 @@ int pci_enable_link_state_locked(struct pci_dev *pdev, int state)
15421542
}
15431543
EXPORT_SYMBOL(pci_enable_link_state_locked);
15441544

1545+
void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap)
1546+
{
1547+
if (lnkcap & PCI_EXP_LNKCAP_ASPM_L0S)
1548+
pdev->aspm_l0s_support = 0;
1549+
if (lnkcap & PCI_EXP_LNKCAP_ASPM_L1)
1550+
pdev->aspm_l1_support = 0;
1551+
1552+
pci_info(pdev, "ASPM: Link Capabilities%s%s treated as unsupported to avoid device defect\n",
1553+
lnkcap & PCI_EXP_LNKCAP_ASPM_L0S ? " L0s" : "",
1554+
lnkcap & PCI_EXP_LNKCAP_ASPM_L1 ? " L1" : "");
1555+
1556+
}
1557+
15451558
static int pcie_aspm_set_policy(const char *val,
15461559
const struct kernel_param *kp)
15471560
{

0 commit comments

Comments
 (0)