diff mbox series

[L/M/Unstable,8/9] UBUNTU: SAUCE: PCI/ASPM: Allow ASPM override over FADT default

Message ID 20230906075421.357683-9-kai.heng.feng@canonical.com
State New
Headers show
Series Enable ASPM for NVMe behind VMD | expand

Commit Message

Kai-Heng Feng Sept. 6, 2023, 7:54 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2034504

On cases where BIOS can't program ASPM registers, allow the driver to do
so, essentially ignoring the FADT ASPM flag.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/pci/pcie/aspm.c | 5 +++--
 include/linux/pci.h     | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 74659be8e61e..67df4a467b0f 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -701,7 +701,8 @@  static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
 	aspm_l1ss_init(link);
 
 	/* Save default state */
-	link->aspm_default = link->aspm_enabled;
+	link->aspm_default = parent->dev_flags & PCI_DEV_FLAGS_ENABLE_ASPM ?
+			     ASPM_STATE_ALL : link->aspm_enabled;
 
 	/* Setup initial capable state. Will be updated later */
 	link->aspm_capable = link->aspm_support;
@@ -1226,7 +1227,7 @@  int pci_enable_link_state(struct pci_dev *pdev, int state)
 	 * systems we have to observe the FADT ACPI_FADT_NO_ASPM bit and
 	 * the _OSC method), we can't honor that request.
 	 */
-	if (aspm_disabled) {
+	if (aspm_disabled && !(pdev->dev_flags & PCI_DEV_FLAGS_ENABLE_ASPM)) {
 		pci_warn(pdev, "can't override BIOS ASPM; OS doesn't have ASPM control\n");
 		return -EPERM;
 	}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d470ae6a4178..ada73214b007 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -244,6 +244,8 @@  enum pci_dev_flags {
 	PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 11),
 	/* Device does honor MSI masking despite saying otherwise */
 	PCI_DEV_FLAGS_HAS_MSI_MASKING = (__force pci_dev_flags_t) (1 << 12),
+	/* Enable ASPM regardless of how LnkCtl is programmed */
+	PCI_DEV_FLAGS_ENABLE_ASPM = (__force pci_dev_flags_t) (1 << 13),
 };
 
 enum pci_irq_reroute_variant {