Re: My AlderLake Dell (XPS-9320) needs these patches to get full standby/low-power modes

Kenneth Crudup
2024-12-19T20:38:00Z

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

Or, just use (some version of) the attached patch (against Linus' recent
master) that enables VMD ASPM this for us "automatically" if there's a
detected VMD ?

I'd prefer a scalpel to a bludgeon (and have been trying to get some
version of these fixes into mainline for a while).

-Kenny

On 12/19/24 11:52, David E. Box wrote:

> If you want to override this behavior, you can try setting pcie_aspm=force on
> the kernel command line.

--
Kenneth R. Crudup / Sr. SW Engineer, Scott County Consulting, Orange
County CA

[-- Attachment #2: aspm-enable-take-2 --]
[-- Type: text/plain, Size: 1557 bytes --]

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 28567d457613..a5df6230cf3c 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -768,6 +768,31 @@ static void aspm_l1ss_init(struct pcie_link_state *link)
aspm_calc_l12_info(link, parent_l1ss_cap, child_l1ss_cap);
}

+/*
+ * BIOS may not be able to access config space of devices under VMD domain, so
+ * it relies on software to enable ASPM for links under VMD.
+ */
+static bool pci_fixup_vmd_bridge_enable_aspm(struct pci_dev *pdev)
+{
+ struct pci_bus *bus = pdev->bus;
+ struct device *dev;
+ struct pci_driver *pdrv;
+
+ if (!pci_is_root_bus(bus))
+ return false;
+
+ dev = bus->bridge->parent;
+ if (dev == NULL)
+ return false;
+
+ pdrv = pci_dev_driver(to_pci_dev(dev));
+ if (pdrv == NULL || strcmp("vmd", pdrv->name))
+ return false;
+
+ pci_info(pdev, "enable ASPM for pci bridge behind vmd");
+ return true;
+}
+
static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
{
struct pci_dev *child = link->downstream, *parent = link->pdev;
@@ -846,7 +871,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
}

/* Save default state */
- link->aspm_default = link->aspm_enabled;
+ link->aspm_default = pci_fixup_vmd_bridge_enable_aspm(parent) ?
+ PCIE_LINK_STATE_ASPM_ALL : link->aspm_enabled;

/* Setup initial capable state. Will be updated later */
link->aspm_capable = link->aspm_support;