From 6b45d19134cb676183c92894dab76af4f05f557b Mon Sep 17 00:00:00 2001 From: Michael Bottini Date: Thu, 14 Oct 2021 11:17:35 -0700 Subject: [PATCH 1/3] PCI/ASPM: Create ASPM override Devices that appear under the Intel VMD host bridge are not visible to BIOS and therefore not programmed by BIOS with ASPM settings. For these devices, it is necessary for the driver to configure ASPM. Since ASPM settings are adjustable at runtime by module parameter, use the same mechanism to allow drivers to override the default (in this case never configured) BIOS policy to ASPM_STATE_ALL. Then, reconfigure ASPM on the link. Signed-off-by: Michael Bottini --- drivers/pci/pci.h | 3 +++ drivers/pci/pcie/aspm.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 1cce56c2aea0..860620dffaac 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -740,6 +740,9 @@ static inline int pci_acpi_program_hp_params(struct pci_dev *dev) #ifdef CONFIG_PCIEASPM extern const struct attribute_group aspm_ctrl_attr_group; +void pcie_aspm_override_policy(struct pci_dev *dev); +#else +static inline void pcie_aspm_override_policy(struct pci_dev *dev) {} #endif extern const struct attribute_group pci_dev_reset_method_attr_group; diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 013a47f587ce..0da079b7ee30 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1140,6 +1140,24 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) } EXPORT_SYMBOL(pci_disable_link_state); +void pcie_aspm_override_policy(struct pci_dev *pdev) +{ + struct pcie_link_state *link = pcie_aspm_get_link(pdev); + + down_read(&pci_bus_sem); + mutex_lock(&aspm_lock); + + if (link) { + link->aspm_default = ASPM_STATE_ALL; + pcie_config_aspm_link(link, policy_to_aspm_state(link)); + pcie_set_clkpm(link, policy_to_clkpm_state(link)); + } + + mutex_unlock(&aspm_lock); + up_read(&pci_bus_sem); +} +EXPORT_SYMBOL(pcie_aspm_override_policy); + static int pcie_aspm_set_policy(const char *val, const struct kernel_param *kp) { -- 2.25.1