From 37bc064385a134c97da9ce7cd2fa7e8353a66750 Mon Sep 17 00:00:00 2001 From: Ilyas Akin Date: Mon, 16 Nov 2026 14:01:11 +0300 Subject: [PATCH] PCI: apple: Allow L1 substates on J514S internal links On a J514S (MacBook Pro 14", M3 Pro), both ends of the Wi-Fi/Bluetooth link (BCM4388) and of the SD reader link (GL9755) advertise ASPM and PCI-PM L1.1 and L1.2, as do their root ports, but the links only ever enter L1: the boot loader leaves the substates off, and the default ASPM policy keeps what it found. Enable L1 and its substates on the links of a non-tunneled controller of a listed machine once its bus is scanned, as pcie-qcom does. pci_enable_link_state_locked() replaces the link's ASPM and Clock PM defaults, so the mask keeps L0s (masked by what the link supports; these root ports advertise L1 only), and keeps Clock PM only where the ASPM core left CLKREQ# enabled: it is not forced on DT platforms. On the J514S Clock PM stays off. With this patch and no pcie_aspm parameter, display-off idle power was 3.06 W with the substates on, 3.36 W after turning them off through the link sysfs attributes and 3.02 W after turning them back on (medians of 120 one-second samples of the SMC's total system power): about 0.3 W. Ping to the router stayed at about 3 ms with no sample above 5 ms, and a LAN transfer ran at 315-331 Mbit/s against 308-334 Mbit/s without them. Only the J514S, where this was measured, is listed. The J516S (16" M3 Pro) has the same T6030 links but has not been measured. Tunneled ports are never touched. The substates are set at probe only: after a remove and rescan of a device they stay off until reboot. Assisted-by: Claude:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Ilyas Akin --- drivers/pci/controller/pcie-apple.c | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 805ff1a8d084f2..42b88c373a8ce1 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -2701,6 +2701,41 @@ static int apple_pcie_neo_enumerate(struct pci_host_bridge *bridge) return ret; } +/* + * Machines whose internal links may enter the ASPM and PCI-PM L1.1 and L1.2 + * substates. Both ends of these links support them, but the boot loader + * leaves them off and the default ASPM policy keeps what it found. On a J514S + * (T6030) turning them on for the Wi-Fi/Bluetooth and SD reader links lowered + * display-off idle power by about 0.3 W, with no change in Wi-Fi latency or + * throughput. Only measured machines are listed; tunneled ports never are. + * The J516S has the same T6030 links but has not been measured. + */ +static const char *const apple_pcie_l1ss_machines[] = { + "apple,j514s", NULL +}; + +static int apple_pcie_enable_l1ss(struct pci_dev *pdev, void *data) +{ + int state = PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_L1_1 | PCIE_LINK_STATE_L1_2 | + PCIE_LINK_STATE_L1_1_PCIPM | PCIE_LINK_STATE_L1_2_PCIPM; + u16 lnkctl; + + /* + * pci_enable_link_state_locked() replaces the link's defaults. L0s is + * masked by what the link supports, so keep it. Clock PM is not forced + * on DT platforms: keep it only where the ASPM core left CLKREQ# on. + */ + if (!pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnkctl) && + (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN)) + state |= PCIE_LINK_STATE_CLKPM; + + /* PCI-PM L1 substates need the device in D0 (PCIe r6.0, sec 5.5.4). */ + pci_set_power_state_locked(pdev, PCI_D0); + pci_enable_link_state_locked(pdev, state); + return 0; +} + static int apple_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -2875,6 +2910,8 @@ static int apple_pcie_probe(struct platform_device *pdev) if (pcie->hw->tunneled) pci_walk_bus(bridge->bus, apple_pcie_tunnel_keep_d0, NULL); + else if (of_machine_compatible_match(apple_pcie_l1ss_machines)) + pci_walk_bus(bridge->bus, apple_pcie_enable_l1ss, NULL); return 0; }