Repository navigation
wifi: brcmfmac: pcie: don't drop ring completions in the hard IRQ handler - #3770
Conversation
…dler brcmf_pcie_quick_check_isr() masks the dongle with brcmf_pcie_intr_disable() whenever mailboxint reads non-zero. Since commit f04be34 ("wifi: brcmfmac: Do not service msgbuf IRQs until ready in MSI mode") that helper also clears irq_ready, and the threaded handler services the rings only while irq_ready is set. The thread therefore skips brcmf_proto_msgbuf_rx_trigger() for exactly the interrupts the hard handler caught with mailboxint still set, and then sets irq_ready again on its way out. In MSI mode the firmware clears mailboxint itself, so whether the hard handler sees it set is a race. When it does, completions that arrived with that interrupt stay in the D2H rings until a later interrupt. On firmware that sends mailbox data over the control ring (no BRCMF_PCIE_SHARED_USE_MAILBOX) that includes the D3 ACK, and ioctl responses: brcmf_msgbuf_query_dcmd_len() and brcmf_pcie_pm_enter_D3() then time out, the latter aborting system suspend. On a MacBook Air (M1) with BCM4378 this became frequent with PCIe ASPM L1.2 enabled. In INTx mode the hard handler always clears irq_ready first, so the rings are never serviced at all. Let the hard handler mask the dongle without touching irq_ready, and let the thread unmask without setting it, so irq_ready is controlled only by the code that sets the rings up and tears them down. Fixes: f04be34 ("wifi: brcmfmac: Do not service msgbuf IRQs until ready in MSI mode") Signed-off-by: Naeem Malik <malik2015naeem@gmail.com> Link: omacom/linux-aurora@3a936ed
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 6b8d44fe
Blocker (shown on hardware): with this change, the J473 (T8112, BCM4388, 27.2) reset 3/3 times within seconds of an s2idle resume. The same module built without the change survived 3/3.
- Setup: the J473's production kernel source (
18058ea2; the diff applies cleanly), with brcmfmac built from it once with and once without this diff, same config and same out-of-tree build. Modules were swapped live. Each cycle: load, wait 5 s, thenrtcwake -d rtc1 -m mem -s 8withmem_sleep=s2idle. Wi-Fi was powered but not associated; Ethernet carried management. - With this change: the suspend logs
brcmf_configure_lpas: LPAS setup failed (-107), using disconnect fallback, thenPM: suspend exit, and about 2 s later the Mac resets while awake (rtcwakenever returns). There is no panic text in the journal. This happened 3/3 times. - Without it (stock module reloaded, and our own build without the diff): it slept the full 10 s and was still alive 30 s later, 3/3.
- Caveat: one control boot reset later, while I unloaded the control module after its cycle (the journal isn't flushed past the suspend entry, so I don't know why). The reset right after resume happened only with this change.
- Not tested yet: associated Wi-Fi cycles, and the PR head on
main.
Checked (code): the bug is real on main. brcmf_pcie_quick_check_isr() → brcmf_pcie_intr_disable() clears irq_ready, so brcmf_pcie_isr_thread() skips brcmf_proto_msgbuf_rx_trigger() for that interrupt. Masking only mailboxmask in the hard handler, and unmasking only while irq_ready is still set, reads correctly and no longer re-arms irq_ready behind a teardown. One thing worth checking for the reset: the resume path now depends on irq_ready alone to unmask. If irq_ready is false or stale across the D3 leave in the s2idle_d0 path, the dongle stays masked. Conversely, if an interrupt lands before the rings are reinitialized, the thread can now unmask and service them while irq_ready is true from before the suspend.
With irq_ready no longer cleared by the hard handler, nothing cleared it for the two sleeps that keep the function in D0 (WoWLAN and the Apple s2idle path): it stayed set from before the suspend. Every interrupt in that window then had its thread service the rings and unmask the dongle, also while brcmf_pcie_pm_leave_D3() runs pci_restore_state() on the live link, which rewrites its config space, ASPM/L1SS and MSI state. A J473 (BCM4388) reset seconds after every s2idle resume with the previous commit alone, and survived without it. Make the ownership explicit: - intr_disable() clears irq_ready before masking and intr_enable() sets it before unmasking, so an interrupt raised as the mask opens cannot leave the dongle masked. - Both D0 sleeps stop ring servicing with intr_quiesce(), which also waits for a running handler and masks again. WoWLAN unmasks the dongle for its wake interrupt with irq_ready still clear, after wowl_sleeping is set. - leave_D3() keeps the IRQ disabled around pci_restore_state() in both D0 sleeps. - brcmf_pcie_wowl_wake() sets irq_ready and the mask explicitly before the bus comes up, and runs the thread once for completions posted while the dongle was masked. brcmf-suspend-tests checks both sleeps keep ring servicing off, that the restore runs with the IRQ disabled and that the resume kicks the thread, with a mutation for each. Signed-off-by: Satya Benson <satya@benson.earth>
75e9ab1 to
9dab09e
Compare
|
@RyanTheTide thanks for the run and the pointer. The reset is real, and you were right about Why commit 1 alone resets in s2idle: on Commit 2 ( Untested: everything on hardware at Could you repeat your J473 cycle at |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 9dab09e9
J473 (T8112, BCM4388) at 9dab09e9 (pcie.c applied to the J473's production source 18058ea2, module swapped live): s2idle pass 8/8 cycles with no reset after resume (2 fresh loads with one cycle each, then 6 consecutive cycles in one load). Wi-Fi was powered but not associated.
Correcting my earlier HOLD numbers: unloading brcmfmac after an s2idle in the same boot resets this Mac whether or not your change is in. It happened once during a v2 reload, and once with my unpatched control module. Two of the three v1 resets I reported came after such an unload, so they don't count. The clean v1 evidence is a single case (fresh load, first s2idle, reset about 2 s after resume), which matches your irq_ready analysis. v2 shows no reset in the clean procedure.
Checked: commit 2 sets irq_ready before unmasking and clears it before masking, and both D0 sleeps quiesce (servicing off, synchronize_irq(), mask). That closes both the post-resume window and the gap in intr_enable().
Not covered (follow-up, not blocking): associated-Wi-Fi s2idle cycles on the J473 (needs the lab AP), and the unload-after-s2idle reset, which happens without this change too and probably deserves its own issue.
|
host-tests at |
Follow aurora-silicon/linux main (integration/aurora no longer exists) at 4a42f31, which brings in #3133 (T8112 DCP on firmware 27.2). Retire, each merged upstream and in this intake: aurora-silicon/linux#2145 as 6f84f56 aurora-silicon/linux#2150 as 15b1e2e aurora-silicon/linux#2152 as 8bd4942 aurora-silicon/linux#2153 as a2801d4 aurora-silicon/linux#2154 as 90d3f11 aurora-silicon/linux#2156 as dff34de aurora-silicon/linux#2199 as d51160c aurora-silicon/linux#2147, closed in favour of #3114 (merged as e8d93e4, in this intake) j613-touchid-data-ready, superseded by aurora-silicon/linux#2678 (merged as 3777510), which describes the same line for the J613 and J615 in t8122-j613-j615.dtsi Update remaining carries: - #2146, #2148, #2149 and #2151 re-pinned to their main-merged PR heads (carried via merge = true). - #2155 pinned to ad63582 (last reviewed commit before #2155 rebased onto the post-4a42f3105002 IIO API change in #3473; adds the describe-by-role follow-up). - #3490 (merged on integration/aurora-7.3 in #529) re-pinned cleanly to upstream 717a6ff..e6e8509, dropping the 00cbc67 rebase commit d98f2a8. - #370 replaced by merged upstream aurora-silicon/linux#3770 (6b8d44f + 9dab09e, adding the D0 sleep quiesce/resume fix for BCM4388 s2idle). - #3607 now carries all three commits including KUnit tests in drivers/bluetooth/hci_bcm4377_test.c (present in 4a42f31). - xart-pin-7.3 note updated (#486 open, #506 closed). Based-on-work-by: Satya Benson <satya@benson.earth> Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
What: brcmfmac's hard IRQ handler clears
irq_readywhenever it seesmailboxintset, so the threaded handler skips ring servicing for that interrupt and D2H completions (ioctl responses, the D3 ACK on firmware that sends mailbox data over the control ring) stay in the rings until a later interrupt. The first commit carries Naeem Malik's fix: the hard handler masks the dongle without touchingirq_ready, and the thread unmasks without setting it. The second commit makesirq_readyand the mask explicit across the two sleeps that keep the function in D0 (WoWLAN and Apple s2idle): with the first commit alone,irq_readystayed set through those sleeps, and a J473 reset after every s2idle resume.Tested: J473 (T8112, BCM4388) at 6b8d44f (first commit only): reset 3/3 about 2 s after an s2idle resume; without it 3/3 survived. No Mac yet at 9dab09e. arm64
LLVM=1 W=1build ofbrcmfmac/is clean;brcmf-suspend-testspass with all 13 mutations caught (3 new).Risk: two-way door · Macs with Broadcom PCIe Wi-Fi (brcmfmac): M1, M2, M3 and later
Not yet: any hardware run at 9dab09e: s2idle cycles unassociated and associated (the J473 case above), WoWLAN s2idle wake, deep sleep, and a throughput check. Draft until one passes.
Details
Commit 1 is carried from draft #1989 (13 fixes, conflicts with
main). It applies cleanly tomain. Author, author date, message and diff are unchanged (patch-id identical to60de23202956), except that an AI-attribution trailer is removed, as the commit policy requires.Commit 2:
intr_disable()clearsirq_readybefore masking.intr_enable()sets it before unmasking, so an interrupt raised as the mask opens can't leave the dongle masked.intr_quiesce(): ring servicing off, wait for a running handler, then mask again. WoWLAN then unmasks the dongle for its wake interrupt withirq_readystill clear (afterwowl_sleepingis set), so the thread reports the wakeup and does nothing else.pm_leave_D3()keeps the IRQ disabled aroundpci_restore_state()in both D0 sleeps. That restore rewrites config space, ASPM/L1SS and MSI state on a link that stayed up.wowl_wake()setsirq_readyand the mask explicitly before the bus comes up. It then runs the thread once for completions posted while the dongle was masked, since in MSI mode they may have no interrupt of their own.Credit: Naeem Malik wrote the first commit in omacom/linux-aurora (3a936ed). RyanTheTide carried it into #1989, then found the reset on J473 and pointed at the
irq_readyownership. Thank you both.Evidence
maind5e9949314fd; the branch still merges cleanly withmain4e4603f31864.git diff 60de2320^ 60de2320 | git patch-id=git diff d5e99493 6b8d44fe | git patch-id=7e7ad490652f.brcmf-suspend-tests.pypasses (50 controls). Every mutation fails, includingd0-quiesce(no quiesce at the s2idle sleep),d0-restore-irq(restore with the IRQ enabled) andd0-kick(no thread run at resume). The otherbrcmf*/brcmfmac-*host tests pass, exceptbrcmf-ps-nap-tests: its ASan harness fails to compile in this environment on plainmaintoo.