Skip to content

PCI/ASPM & nvme-pci: apple-ans: Enable ASPM L1 and L1 PM Substates on Apple S3E NVMe - #183

Open
grierj wants to merge 3 commits into
OrchardLinux:mainfrom
grierj:nvme-apple-ans-aspm
Open

grierj wants to merge 3 commits into
OrchardLinux:mainfrom
grierj:nvme-apple-ans-aspm

Conversation

@grierj

@grierj grierj commented Dec 5, 2026

Copy link
Copy Markdown

Summary

Enable PCIe ASPM L1 on Apple S3E (ANS) NVMe links (106b:2002) and PCIe L1 PM Substates (L1.1/L1.2) on T8011 (A10X) storage links, cutting ~330 mW of continuous idle power draw on J207.

Root Cause

  1. ASPM L1 blocked by DevCap acceptable latency: Apple S3E NVMe (106b:2002) advertises DevCap L1 acceptable latency <32us (0x5) while its paired Apple H8/H9 root ports (106b:1009) report LnkCap L1 exit latency <64us (0x6). pcie_aspm_check_latency() strips PCIE_LINK_STATE_L1, leaving the link stuck in L0 on every Apple S3E board.
  2. L1 PM Substates clobbered & not opted in on T8011: Even after L1 is allowed, nvme_pci_apple_ans_config() overwrote PCI_L1SS_CTL2 = 0 (T_POWER_ON = 0us) and PCI_L1SS_CTL1 with enable bits cleared (wiping aspm_calc_l12_info()'s programmed timings), and Devicetree ASPM defaults only enable L0s/L1.

Changes

  1. arch/arm64/boot/dts/apple/t8010.dtsi: Add aspm-no-l1ss; to the shared T8010 pci@0,0 storage root port node (ordered before the latency quirk for clean bisection), since T8010 keeps port 0 CLKREQ# in software GPIO input mode (clkreq-gpios) rather than hardware PCIe pinmux. (s8000.dtsi, s8001.dtsi, and s8003.dtsi already carry aspm-no-l0s; aspm-no-l1;.)
  2. drivers/pci/quirks.c: Override DevCap L1 acceptable latency for Apple S3E NVMe (106b:2002) via the existing aspm_l1_acceptable_latency() quirk, enabling ASPM L1 on T8010 and T8011.
  3. drivers/nvme/host/pci-apple-ans.c: Add l1ss_enable to struct apple_ans_host:
    • Enabled on apple_ans_host_t8011 and apple_ans_host_j120 (where port 0 CLKREQ# is hardware-pinmuxed to the PCIe controller and REFCLK gating is permitted).
    • Kept off on s8000/s8001/s8003 (S8003_RC_PORT_PWR_REFCLK_NOGATE) and t8010 (clkreq-gpios).
    • When l1ss_enable is true, preserve the ASPM core's PCI_L1SS_CTL1/CTL2 timing registers in nvme_pci_apple_ans_config() and call pci_enable_link_state() for L1 + L1.1/L1.2 (ASPM + PCI-PM) once synchronously in nvme_pci_apple_ans_init() (outside reset_work to avoid pci_bus_sem recursion under AER recovery, and before nvme_pci_enable() saves PCI config state). When false, explicitly disable L1SS via pci_disable_link_state() before pci_enable_device_mem().

Hardware Verification (J207 / iPad Pro 10.5" Wi-Fi, T8011)

Built via orchard build --device j207 --kernel ... hardware-check and RAM-booted on J207:

  • Cold boot logs pci 0000:01:00.0: ASPM: overriding L1 acceptable latency from 0x5 to 0x7 and brings up nvme0n1 cleanly.
  • 0000:01:00.0/link/*: l1_aspm=1, l1_1_aspm=1, l1_2_aspm=1, l1_1_pcipm=1, l1_2_pcipm=1 (LnkCtl=0x0042, L1SubCtl1=0x403c190f / 0x403c000f, L1SubCtl2=0x78 [T_PwrOn=30us], LTR=0x10081008).
  • Wi-Fi (0000:02:00.0) remains untouched at l1_aspm=1, l1_1_aspm=0, l1_2_aspm=0.
  • 128 MiB NVMe read + 10 intermittent reads (200 ms spacing for repeated L1.2 wake transitions) + sysfs l1_aspm toggle (1 -> 0 -> 1) + 32 MiB read all passed with zero AER errors (0x104=0, 0x110=0 on both 00:00.0 and 01:00.0).
  • Settled battery current (bq27xxx_battery_hdq, 35 s idle on 500 mA USB SDP):
    • L0 (l1_aspm=0): -107 mA (3.782 V, -405 mW)
    • L1 + L1.1/L1.2 (cold-boot default): -20 mA (3.789 V, -76 mW)
    • Savings: 87 mA (~329 mW)

Port 0 on T8010 keeps CLKREQ# configured as a software GPIO input
(clkreq-gpios) rather than hardware PCIe CLKREQ# pinmux, so the storage
link cannot enter PCIe L1 PM Substates (L1.1/L1.2) safely.

Add aspm-no-l1ss to the shared T8010 storage root port node so the PCIe
ASPM core enforces this restriction from enumeration onward (including
under pcie_aspm.policy=powersupersave), while still allowing ASPM L1.

Assisted-by: LLM
Signed-off-by: Grier Johnson <grier@scooterfarm.com>
Apple S3E (ANS) NVMe controllers (106b:2002) advertise an L1 acceptable
latency of <32us (0x5) in DevCap while pairing exclusively with Apple
H8/H9 root ports that report <64us (0x6) L1 exit latency.

Because 64us exceeds 32us, pcie_aspm_check_latency() strips
PCIE_LINK_STATE_L1 and leaves the storage link stuck in L0 on Apple
H8/H9 boards whose storage port allows ASPM L1 (T8010 and T8011; S800x
boards explicitly opt out via aspm-no-l1 in devicetree).

Override DevCap L1 acceptable latency via the existing
aspm_l1_acceptable_latency() quirk, allowing ASPM L1 to be enabled.

Assisted-by: LLM
Signed-off-by: Grier Johnson <grier@scooterfarm.com>
On Apple T8011 (A10X), the storage root port pinmuxes CLKREQ# to the PCIe
controller and permits REFCLK gating, so the Apple S3E NVMe link supports
PCIe L1 PM Substates (L1.1 and L1.2).

Previously, nvme_pci_apple_ans_config() overwrote PCI_L1SS_CTL2 with 0 and
PCI_L1SS_CTL1 with the enable bits cleared, clobbering the L1.2 timing
parameters computed by the PCIe ASPM core during enumeration, and
devicetree ASPM defaults only enable L0s/L1.

Add an l1ss_enable flag to struct apple_ans_host (enabled on T8011 and
J120, kept off on S8000/S8001/S8003 where REFCLK gating is disabled and on
T8010 where port 0 CLKREQ# stays in software GPIO mode). When set, leave
the ASPM core's L1SS timing registers intact in nvme_pci_apple_ans_config()
and request L1 + L1.1/L1.2 via pci_enable_link_state() in
nvme_pci_apple_ans_init() (and explicitly disable L1SS when l1ss_enable is
false). Doing this once synchronously during probe ensures it runs before
pci_enable_device_mem() applies ASPM policy (protecting older T8010 DTBs
without aspm-no-l1ss) and outside reset_work (avoiding pci_bus_sem
recursion under AER recovery), while nvme_pci_enable() subsequently saves
the resulting PCI config state for suspend/resume.

Assisted-by: LLM
Signed-off-by: Grier Johnson <grier@scooterfarm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant