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 <bhelgaas@google.com>
Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Link: https://patch.msgid.link/20251110222929.2140564-3-helgaas@kernel.org
This commit is contained in:
Bjorn Helgaas
2025-11-10 16:22:26 -06:00
parent 4495bffd86
commit 575b98e39d
2 changed files with 15 additions and 0 deletions

View File

@@ -1542,6 +1542,19 @@ int pci_enable_link_state_locked(struct pci_dev *pdev, int state)
}
EXPORT_SYMBOL(pci_enable_link_state_locked);
void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap)
{
if (lnkcap & PCI_EXP_LNKCAP_ASPM_L0S)
pdev->aspm_l0s_support = 0;
if (lnkcap & PCI_EXP_LNKCAP_ASPM_L1)
pdev->aspm_l1_support = 0;
pci_info(pdev, "ASPM: Link Capabilities%s%s treated as unsupported to avoid device defect\n",
lnkcap & PCI_EXP_LNKCAP_ASPM_L0S ? " L0s" : "",
lnkcap & PCI_EXP_LNKCAP_ASPM_L1 ? " L1" : "");
}
static int pcie_aspm_set_policy(const char *val,
const struct kernel_param *kp)
{