Repository navigation
wifi: brcmfmac: pcie: suppress ASPM L1 across s2idle on BCM4378 - #3970
Conversation
On Apple M1 (T8103) systems running macOS 27.2 (26B123) BCM4378 firmware (18.20.511.0.7.8.207), allowing the BCM4378 PCIe link into ASPM L1 across s2idle causes a hard SoC reset during synchronous device suspend/resume (reproducible even under pm_test=devices and pm_async=0) while the radio transitions through MPC with the function kept in D0. Disabling ASPM L1 permanently would forfeit runtime L1/L1SS power savings while awake. Add pcie_aspm_sleep_disable() and pcie_aspm_sleep_restore() in the PCIe ASPM core to temporarily mask ASPM states via link->aspm_sleep_disable without altering link->aspm_disable, link->aspm_default, or sysfs overrides. Also extend the L1SS restore/sync sleep-suppression checks so suppressing PCIE_LINK_STATE_L1 consistently suppresses L1SS as well, and update saved LNKCTL state across all downstream functions on the link. Use these helpers from brcmf_pcie_pm_prepare() and brcmf_pcie_pm_complete() for Apple-seeded BCM4378 s2idle sleeps so ASPM L1 (and L1SS) are cleared before wiphy_suspend() / brcmf_pcie_s2idle_sleep() and restored cleanly after brcmf_pcie_pm_leave_D3() / wiphy_resume(), keeping runtime ASPM L1/L1SS/CLKPM savings intact while awake and leaving non-BCM4378 chips and deeper sleeps unchanged. Extend brcmf-suspend-tests with prepare/complete coverage and two mutations (s2idle-l1-prepare, s2idle-l1-complete). Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approving. I read the whole change against main 2f5b01a, and it looks right.
What I checked:
- Gating. prepare() acts only for an Apple-seeded BCM4378 (
fwseedand device 0x4425) entering s2idle. Every other brcmfmac PCIe chip returns early, as do S3 and hibernation (wherepm_suspend_target_stateisn'tPM_SUSPEND_TO_IDLE), and none of them touch ASPM. complete() acts only when prepare() set the flag. - Restore. Once prepare() succeeds, complete() runs on every path: a normal wake, a failed suspend callback and an aborted suspend. So L1 always comes back. remove() restores it too if the driver is unbound in between. If prepare() fails, the mask is rolled back and there's nothing to restore.
- Fit with the existing s2idle path. The function stays in D0.
brcmf_pcie_s2idle_sleep()saves config space after L1 is already off, sopci_restore_state()at resume writes L1 off and complete() turns it back on. The controller's L1SS sleep begin/end owns only the L1SS bit ofaspm_sleep_disable. The new checks treat a suppressed L1 as suppressing L1SS too, so neither side can re-enable the other's state early. brcmfmac doesn't use runtime PM, so there's no interaction there. - Locking. The helpers take pci_bus_sem (read), then aspm_lock, then aspm_l1ss_hw_lock. That's the documented order, and it's the same pattern
pci_disable_link_state()uses from probe. prepare() and complete() run in process context, so sleeping there is fine. - Non-wireless hunks. These are drivers/pci/pcie/aspm.c, include/linux/pci.h and the tools/asahi tests. There's no GPU code; the area:gpu label comes from the tools/asahi CODEOWNERS entry.
Local checks on the merge with main 2f5b01a (merge tree f0368f50), on an x86_64 build host:
- arm64 LLVM (clang 23.1.3)
make W=1 drivers/pci/pcie/aspm.o drivers/net/wireless/broadcom/brcm80211/brcmfmac/: rc 0, 0 warnings, 0 errors. All 36 brcmfmac objects and aspm.o were rebuilt with the W=1 flags. scripts/checkpatch.pl --strict --git 9b4f6882dd11: 0 errors, 0 warnings, 0 checks.tools/asahi/run-host-tests.py --only brcmf-suspend: 16/16 pass.--only pciec-policy: 1/1 pass.- Hosted CI hasn't run at this head yet (0 workflow runs).
Notes, none blocking:
pci_update_aspm_saved_state()now runs on every function on the link instead of only function 0. That reaches every multi-function link, which means the Wi-Fi/Bluetooth combo on every Mac, not just BCM4378. I think the change is right: the code already writes LNKCTL on every function, so every saved copy should follow. But it makes this shared PCIe code, so it needs an s2idle row on one other generation before merge, as well as the T8103 row.- The gate keys on the chip, not the firmware. So BCM4378 machines on older firmware, like the J274, also lose L1 during s2idle. That costs a little sleep power, which is fine for this fix.
- Small: the helpers' kernel-doc could say that they may sleep and must not be called with pci_bus_sem held.
- Small:
aspm_sleep_disableis a bitmask, not a count. If the Bluetooth function on the same link ever used these helpers too, one restore would undo the other's suppression. With one user that's fine.
Hardware: the exact-head J313 row in the description covers the board. A J293 row at this head and a second-generation row are being lined up.
|
J293 (13-inch MacBook Pro M1, T8103, 27.2 firmware) exact-head verification, kernel-only one-shot of 9b4f688 built on aarch64 with aurora_defconfig (release 7.3.0-lab-s2idle, boot_id 40493a79-…):
|
|
PASS J714s (M5 Pro, T6050) linux#3970 head 9b4f688 in composite b6002784 (main c2f1583 + #3410 465d7cf + #3334 7be3a9c + #3717 99fc90d + #3970 9b4f688, 7.3.0-m5-comp-3410-3970): Wi-Fi (wlp1s0f0, 3/3 0%-loss ping to gateway & Mini), BT (hci0 Powered: yes), and lspci -vv LnkCtl (ASPM Disabled, RCB 64B, LnkDisable- CommClk-) + L1SubCtl1 on 01:00.0/1/2 identical across pre-sleep, after-sleep-1, and after-sleep-2 (2x rtcwake -m mem -s 20), 0 faults/Oops/WARN/BUG, clean stock handback (b2c723cd). |
|
J773g (T8132 / M4 mini, BCM4388 control) exact-head
|
|
Post-merge host tests on merge commit 662680a (PR head 9b4f688; no hosted Host tests ran on this PR), in the
The 20 commits on main since the merge (up to ccb3d8b) don't touch these tests, the PR's kernel files, or their |
What: Suppress PCIe ASPM L1 (and its L1SS substates) temporarily from
brcmf_pcie_pm_prepare()throughbrcmf_pcie_pm_complete()on Apple-seeded BCM4378 (0x4425, M1 / T8103)s2idlesleeps via newpcie_aspm_sleep_disable()/pcie_aspm_sleep_restore()helpers indrivers/pci/pcie/aspm.c, fixing hard SoC resets on macOS 27.2 (26B123) BCM4378 firmware (18.20.511.0.7.8.207) while keeping runtime ASPM L1/L1SS/CLKPM power savings intact while awake.Tested: J313 (MacBook Air M1, T8103, 27.2
26B123firmware18.20.511.0.7.8.207) exact-head9b4f6882dd11(7.3.0-j313-s2idle+,boot_id=4de5c0e5-7b1f-4ab3-a818-ed96b0706136): PASS — 10/10 reals2idlecycles via/dev/rtc1(suspend_stats/success0 -> 10,fail=0, zero manual sysfs workarounds), all 6 PCIe link PM flags (clkpm,l1_aspm,l1_1_aspm,l1_1_pcipm,l1_2_aspm,l1_2_pcipm) restored to1on0000:01:00.{0,1}after every wake,wld0up (3/3gateway ping,0%loss,10.0 msavg),0kernel BUG/Oops/WARN/AER/IOMMU/brcmfmac errors.7.3.0+,9177b2d4, 27.2 firmware):s2idleand synchronouspm_test=devices(pm_async=0) wheneverl1_aspm=1(even withclkpm=0andL1SS=0).brcmfmacunbound, 15/15pm_test=devicesand 10/10 reals2idlewithl1_aspm=0(clkpm=1), and 10/10 reals2idlewithl1_aspmtoggled only across sleep.J274,7.3.0+, older May 2023 BCM4378 firmware18.20.383.15.7.8.150): passed 10/10 reals2idlewithwld0connected andl1_aspm=1, confirming the trigger is specific to newer (27.2) BCM4378 firmware.tools/asahi/run-host-tests.py --only brcmf-suspend: 16/16 PASS (including news2idle-l1-prepareands2idle-l1-completemutations).tools/asahi/run-host-tests.py --only pciec-policy: 1/1 PASS (all ASPM/L1SS policy + mutation checks)../scripts/checkpatch.pl --strict --git HEAD: 0 errors, 0 warnings, 0 checks.Risk: two-way · Scoped strictly to
PM_SUSPEND_TO_IDLEon Apple-seeded BCM4378 (0x4425) vialink->aspm_sleep_disable(PCIE_LINK_STATE_L1), orthogonal toPCIE_LINK_STATE_L1SSdeep-sleep suppression and preserving useraspm_disable/sysfs overrides; easily revertible.Not yet: Live-tested on
J293(M1 MBP 13", also T8103 + BCM4378 on27.2) or hibernation (PM_SUSPEND_MEM/disk, wherebrcmf_pcie_pm_prepare()is a no-op).