Repository navigation
wifi: brcmfmac: pcie: guard D3 suspend IRQ and verify device presence before resume BAR0 read - #3951
IronsideXXVI wants to merge 2 commits into
Conversation
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 80d19d6
Blockers:
- Wait for the approved Actions CI runs (
host-tests,pr-text,readiness) to complete green at80d19d66bb11. - Post an exact-head
80d19d66bb11hardware deep-sleep + s2idle row (and a secondbrcmfmacMac control row, per merge policy §1/§3 — currently listed under Not yet).
Checked:
- Audited the full 16-line diff in
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.cat80d19d66bb11: no code blockers found. - Setting
d3_suspendedbeforesynchronize_irq()andbrcmf_pcie_intr_disable()inbrcmf_pcie_pm_enter_D3()(after the WoWLAN ands2idle_d0early returns) drains any in-flight ISR and blocks spurious MSIs from reading BAR0 inbrcmf_pcie_quick_check_isr()while the link is down. - Checking
pci_device_is_present()inbrcmf_pcie_pm_leave_D3()before clearingd3_suspendedor readingintmaskavoids an asynchronous fabric SError on a failed relink and cleanly reports-ENODEVtoapple_radio_sleep_endpoint_resumed(). On hot resume,brcmf_pcie_intr_enable()restoresirq_readyand unmasks interrupts; on cold reprobe, a freshdevinfostarts withd3_suspended = false. - Non-blocking note: clearing
d3_suspended = falseafter confirmingintmask != 0(just beforebrcmf_pcie_intr_enable()) would also keepd3_suspendedset ifpm_leave_D3()takes theapple_radio_sleep_owned()-EUCLEANearly return without reprobing.
|
Updating those two host test harnesses (and covering |
… before resume BAR0 read If the PCIe host port fails to relink after deep sleep, reading BAR0 + 0x2000 (intmask) in brcmf_pcie_pm_leave_D3() or handling a replayed/spurious MSI in brcmf_pcie_quick_check_isr() while the link is down triggers an asynchronous fabric SError on Apple Silicon. - In brcmf_pcie_pm_enter_D3(), set devinfo->d3_suspended, drain any in-flight IRQ handler via synchronize_irq(), and mask mailboxmask via brcmf_pcie_intr_disable() while leaving intmask intact for hot-resume detection. - Short-circuit brcmf_pcie_quick_check_isr() while d3_suspended is set. - In brcmf_pcie_pm_leave_D3(), verify pci_device_is_present() before reading BAR0 + 0x2000 (intmask), returning -ENODEV cleanly (and reporting -ENODEV to apple_radio_sleep_endpoint_resumed()) if the endpoint is absent, and clear d3_suspended only on hot resume right before brcmf_pcie_intr_enable() so -ENODEV and owned-sleep -EUCLEAN early returns keep d3_suspended armed. - Update the brcmf-suspend-tests.py and brcmfmac-sleep-lifetime-tests.c host test harnesses with the new fields/stubs and add controls and mutations covering D3 ISR gating, absent-endpoint -ENODEV without BAR0 reads, and owned-sleep -EUCLEAN retention of d3_suspended. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
80d19d6 to
f61003b
Compare
|
Thanks for catching both host-test harness failures and for the review note on
Local verification at
|
|
Code, updated |
|
Quick J604 (
|
|
Forward-merged Local verification at
Next: standalone exact-head hardware row at |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: the code is fine at d2dcb0af97d9. Merge once the two hardware results below are in. I'm not approving yet only because they are missing.
Forward merge: clean. The pcie.c change is line for line the one at f61003b5, and nothing from main is removed. The branch tree is exactly b924bf47 plus the four PR files. The BCM4378 s2idle L1 suppression (prepare/complete/remove) is intact. The result also merges cleanly into main 5fe340ac (tree 42a56ca0); later main commits don't touch these files.
Still needed (blocking):
- J604 deep sleep + s2idle on this head, with Wi-Fi back after each wake and one
modprobe -r brcmfmac/modprobe brcmfmacat the end. The 10/10 soak is good support, but it ran the earlier flag placement next to other sleep changes. - A second
brcmfmacMac of another generation, same steps. Best is an M1 with the BCM4378 (T8103, where deep sleep is offered); a T6040 MacBook Pro also works. Please enabledyndbgforbrcmf_pcie_pm_*or note whether the wake was a hot resume or a reprobe.
Not blocking, a follow-up is fine (main faults at the first wake in these cases, so nothing here is a regression):
- After an absent-device wake the driver stays bound, and the next step still touches the dead link. s2idle masks over BAR0 (
pcie.c:3593) and its wake marks the bus up while the ISR is still gated. Deep sleep sendsHOST_D3_INFORM(:3659).modprobe -rrunsbrcmf_pcie_reset_device(). An early return inbrcmf_pcie_pm_enter_D3()whiled3_suspendedis set would cover both sleeps (keep the last good saved config: a freshpci_save_state()would store all-ones). brcmf_pcie_reset()reuses the samedevinfo, so cleard3_suspendedinbrcmf_pcie_request_irq(). Otherwise a reset after a failed wake comes back with its interrupts ignored.- On the J713, a reported
-ENODEVends inapple_radio_terminal()(a panic), as-EUCLEANalready does. The "degrades cleanly" wording holds for the other boards. - The PR body still describes
80d19d66(flag cleared before theintmaskread); update it with the new result.
What I ran and read
Run on the merge tree 42a56ca0 (no hardware):
- arm64 clang
W=1ofdrivers/net/wireless/broadcom/brcm80211/brcmfmac/(BRCMDBG=y): 0 warnings. checkpatch.pl --strict: 0/0/0 on the commit and on the net diff.run-host-tests.py --only brcm95/95,--only bcm437713/13, in the CI container image.
Read:
- BCM4378/4387/4388 (and 4355/4364/4377) all set
fw_seed, so s2idle keeps the function in D0 and returns before the new code; WoWLAN too. Only deep sleep and hibernation use it. - Suspend order is right: flag, drain, then mask, so no thread can unmask afterwards.
intmaskandmailboxmaskare separate registers in both layouts. A failedD0_INFORMstill goes through remove/probe with a freshdevinfo. - The presence check is one config read, which the PCI core already does in its noirq resume.
Hosted Host tests and pr-text are waiting for approval at this head.
There was a problem hiding this comment.
Verdict: MERGE at d2dcb0a
Checked: D3 entry guards new IRQ arrivals before draining in-flight handlers, then masks interrupts while BAR access is still valid. Resume checks presence before the first BAR read and restores IRQ admission on the successful retained path. The D0 s2idle return paths remain separate. I ran the exact production-backed host suite and all 58 controls passed.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approving at d2dcb0af97d9. The code is the same as in my review of this head, where only the rows were missing, and I found nothing that has to change. My follow-up notes there still stand and don't block this.
What I checked again
- Suspend sets the flag, waits for the running handler, then masks the dongle, so nothing can unmask afterwards. A suspend that fails after that goes through the hot resume, which clears the flag.
- Resume checks the device before its first register read. The flag is cleared only on a hot resume; a reprobe starts with new state.
- s2idle (device left in D0) and WoWLAN return before the new code, so only deep sleep and hibernation use it.
- It merges cleanly on main
dc4d6f065001andbrcmfmac/pcie.ocompiles there (arm64, GCC,W=1, no warnings).
Rows still owed before merge
- J604: deep sleep and s2idle at this head, Wi-Fi back after each wake, one module reload at the end.
- A second generation. Our J516s (M3 Pro, T6030) and J773g (M4 mini, T8132) both drive a BCM4388 with
brcmfmac, and this head is in our next kernel for them. J516s can be the second generation if its deep sleep wakes; J773g adds the suspend/resume path withpm_test=devices. An M1 (BCM4378) or a T6040 MacBook Pro row counts as well.
Please update the PR body: it still describes the older flag placement.
What: Guard
brcmfmacPCIe D3 suspend/resume against spurious MSIs and absent-endpoint BAR0 reads indrivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:brcmf_pcie_pm_enter_D3(), setdevinfo->d3_suspended, drain any in-flight IRQ handler viasynchronize_irq(devinfo->pdev->irq), and maskmailboxmaskviabrcmf_pcie_intr_disable()(leavingintmaskintact for hot-resume detection).brcmf_pcie_quick_check_isr(), returnIRQ_NONEimmediately whileREAD_ONCE(devinfo->d3_suspended)is true so replayed/spurious MSIs during suspend/resume do not read BAR0 while the link is down.brcmf_pcie_pm_leave_D3(), verifypci_device_is_present(devinfo->pdev)before clearingd3_suspendedor readingBAR0 + 0x2000(intmask), returning-ENODEVcleanly (and notifyingapple_radio_sleep_endpoint_resumed(dev, -ENODEV)) instead of triggering an asynchronous fabric SError when a host PCIe port fails to relink after deep sleep.Tested:
aurora-silicon/linuxmain(bf2931e57045, branchj604-brcmfmac-d3-resume-bar0-guard, commit80d19d66bb11):scripts/checkpatch.pl --strict:0errors,0warnings,0checks (40lines checked).LLVM=1 W=1:drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o0warnings (728096bytes).linux-aurora 7.3.0.aurora1-1.1685, commit89d82de1c143):0compiler warnings inbrcmfmac/pcie.c, ARM64 QEMU KUnit202/202passed.linux-aurora 1.1685, bootb650c46a):1/1deep-sleep suspend/resume wake passed (rc=0,0SErrors,0kernel faults), alongside0PMP events (600 s idle window),33.5 Cidle thermal gate, and1582.7 fpsProRes decode gate.Risk: two-way door ·
brcmfmacPCIe (drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c,+16 / -0lines) —s2idleD0 / WoWLAN early-return paths inbrcmf_pcie_pm_enter_D3()andbrcmf_pcie_pm_leave_D3()return before touchingd3_suspended, normal deep-sleep wakes wherepci_device_is_present()is true cleard3_suspendedand proceed identically, and a plain revert restores prior behavior.Not yet:
1.1685(queued next after the1/1deep-sleep wake pass), plus a hardware boot + deep-sleep/s2idle row at this exactmain(bf2931e57045) head (80d19d66bb11) on T8132 and a secondbrcmfmacMac.Details and verification
Scope (
j604-brcmfmac-d3-resume-bar0-guard, head80d19d66bb11onmainbf2931e57045)drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c(+16 / -0)Signed-off-by: Dylan Ironside <dylan@dylanironside.io>scripts/checkpatch.pl --strict:0 errors, 0 warnings, 0 checks(40lines checked).LLVM=1 W=1:drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o0warnings (728096bytes).Mechanism summary
brcmf_pcie_quick_check_isr()withd3_suspended, draining in-flight IRQs viasynchronize_irq()and maskingmailboxmaskinpm_enter_D3(), and verifyingpci_device_is_present()before clearingd3_suspendedor readingintmask(BAR0 + 0x2000) inpm_leave_D3()ensures an unlinked endpoint degrades cleanly to-ENODEVwithout faulting the fabric.