Repository navigation
Conversation
scottjones
left a comment
There was a problem hiding this comment.
Thanks for this, and for the careful measurements. The approach looks right to me, and the locking and the D0 step match pcie-qcom. A few things before it goes in:
pci_enable_link_state_locked()replaces the link's defaults rather than adding to them (aspm.csetsaspm_defaultandclkpm_defaultfrom the mask). WithoutPCIE_LINK_STATE_L0Sin the mask, L0s goes off on any link that supports it, since the core enables L0s and L1 by default on DT platforms. WithoutPCIE_LINK_STATE_CLKPM, Clock PM goes off if iBoot had set CLKREQ_EN. Please add L0S, which is safe because it's masked by what the link supports. For Clock PM, could you check today'slspci -vvLnkCtl ClockPM line and decide from that? Upstream deliberately stopped forcing Clock PM on DT platforms in df5192d, so I'd rather not passPCIE_LINK_STATE_ALLblindly.- The 0.35 W figure came from
pcie_aspm.policy=powersupersave, which also turns on L0s and Clock PM. Could you re-measure on the patched kernel with nopcie_aspmparameter, so the number matches what ships? - The match is on
apple,t6030, which the J516S also carries (t6030-j516s.dts), so the 16" gets this too. Either matchapple,j514sonly or update the description. Its Wi-Fi and SD setup is the same, so I don't expect trouble.
A minor note, no change needed: after a remove and rescan, the substates stay off until reboot. A line in the commit message would cover it.
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 <noreply@anthropic.com> Signed-off-by: Ilyas Akin <ashnwor@gmail.com>
a8b9836 to
37bc064
Compare
|
Thanks. I've force-pushed changes for all three points:
I also added the remove/rescan note to the commit message. |
scottjones
left a comment
There was a problem hiding this comment.
Thanks for turning this around so quickly. All three points are covered: L0s is in the mask, Clock PM is no longer forced and only follows what CLKREQ_EN already says, and the match is J514S only. Thanks too for re-measuring without pcie_aspm, so the 0.3 W is what actually ships. Approving.
One comment, no change needed for this PR. Clock PM is decided per function here, but the ASPM core takes the worst case across all functions on the link (pcie_clkpm_cap_init()). The walk calls pci_enable_link_state_locked() once per function and the last call wins, so whichever function is visited last decides Clock PM for the whole link. If one function had CLKREQ_EN set and the other didn't, this would turn Clock PM on where the core left it off. On J514S clkpm reads 0 on every function, so it can't happen there, but it does mean "only where the ASPM core left CLKREQ# on" isn't strictly true in that mixed case. If the list grows past J514S, it might be worth ANDing CLKREQ_EN across pdev->bus->devices first.
|
For the record, two things a later upstream reviewer would likely ask about. What macOS does on these links. From IORegistry on a J514S running macOS:
Where the saving comes from, toggling per link at runtime on the patched kernel, display off:
So about 0.10 W comes from the Wi-Fi link and about 0.24 W from the SD reader link. SD card I/O with the substates on, off, on (UHS-I SDR104 card, 1 GiB O_DIRECT write and read, 20 s of 4k QD1 random reads):
The cost is in QD1 reads: about +30 µs at p50, 2861/2397 IOPS on against 3078 off. Sequential throughput was within the card's own variation. |
|
Thanks for the review. Good point on Clock PM: the last function visited sets it for the whole link. If the list grows past the J514S, I'll AND CLKREQ_EN across |
|
Tested on a second J514S. On Not tested: power on its own, and battery runtime. Test setup
Testing and write-up assisted by Claude Code. |
What this changes and why
On the J514S (MacBook Pro 14", M3 Pro, T6030), the internal PCIe links only ever enter ASPM L1:
Both ends of each link, and their root ports, advertise ASPM and PCI-PM L1.1 and L1.2 (
L1SubCap: PCI-PM_L1.2+ PCI-PM_L1.1+ ASPM_L1.2+ ASPM_L1.1+). ButL1SubCtl1is all off: the boot loader does not set them, and the default ASPM policy keeps what it found. Writinglink/l1_2_aspmis accepted and changes nothing under the default policy.This enables L1 and its substates on the links of a non-tunneled Apple PCIe controller once its bus is scanned, as
pcie-qcomdoes: each device is put in D0 first (PCIe r6.0 §5.5.4), thenpci_enable_link_state_locked()runs. That call replaces the link's ASPM and Clock PM defaults, so the mask also keepsL0S(masked by what the link supports; these root ports advertise L1 only), and keepsCLKPMonly where the ASPM core left CLKREQ# on. Clock PM is not forced on DT platforms; on the J514S it stays off, as iBoot leaves it.Only the J514S (
apple,j514s), where this was measured, is listed. The J516S has the same T6030 links but has not been measured. Tunneled ports are never touched. The substates are set at probe only, so after a remove and rescan of a device they stay off until reboot.What was tested
pcie_aspmparameter, substates turned off and on again through thelink/sysfs attributes. Display off, 120 one-second samples of the SMC's total system power (macsmc_hwmon"Total System Power") per phase, on AC at 100%, Wi-Fi power save on:About 0.3 W. An earlier run with
pcie_aspm.policy=powersupersave(which also turns on L0s and Clock PM) gave 3.99 → 3.64 W.linux-aurorarecipe and without anypcie_aspmparameter. The ASPM policy staysdefault, yet:link/l1_1_aspm,l1_2_aspm,l1_1_pcipmandl1_2_pcipmread 1 on both 01:00.0 and 02:00.0,link/clkpmreads 0 on all three functions, andlspcishowsL1SubCtl1: PCI-PM_L1.2+ PCI-PM_L1.1+ ASPM_L1.2+ ASPM_L1.1+;make W=1 drivers/pci/controller/pcie-apple.o(clang) is clean. checkpatch is clean apart from the trailers.What was NOT tested
Risk
AI assistance
🤖 Generated with Claude Code