Repository navigation
wifi: brcmfmac: pcie: don't drop ring completions in the hard IRQ handler - #370
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") Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Naeem Malik <[email protected]>
|
[Joshua's agent] Review of 3a936ed, read offline against base b798f2b. The cause and the fix read correctly to me. In the base, Two optional notes:
Your own A/B shows no behaviour change from #370 alone (the 4th-suspend failure is the same), so the evidence for this one is code reading. |
|
@scottjones @chriskearney this one has been green and mergeable since 5 Nov with no approving review yet. Could one of you take a look when you have a moment? #371 sits on top of this one, so #370 should go in first. Thanks! |
scottjones
left a comment
There was a problem hiding this comment.
Approving, thanks Naeem. The bug is real and this is the right fix.
In the base, the hard handler's brcmf_pcie_intr_disable() clears irq_ready, so the thread skips brcmf_proto_msgbuf_rx_trigger() for exactly the interrupts where it saw mailboxint set, then sets irq_ready again on the way out. Mainline brcmfmac has no irq_ready, so this came in with f04be34. Masking the dongle directly in the hard handler and leaving irq_ready to setup and teardown fixes it. It also stops the thread turning irq_ready back on while reset or release_irq is tearing things down.
The case is stronger than the description says. On legacy INTx the hard handler only wakes the thread when mailboxint is set, so in the base the rings were never serviced at all. Apple Silicon uses MSI, so that path doesn't affect us, but it makes the bug plainer.
It builds clean with the package config (compile-check, W=1, no new warnings), and check-commits passes. Nothing in tools/ exercises this path, so as the description says, the support is code reading rather than a test.
One follow-up I'd like, though it's optional and doesn't block the merge: in brcmf_pcie_intr_enable(), set irq_ready with WRITE_ONCE before the mailboxmask write, so it pairs with the READ_ONCE you added. Right now the mask is written first. With CONFIG_PREEMPT, if the interrupt lands on the same CPU in that gap, the FIFO IRQ thread can run first, see irq_ready false, and leave the dongle masked, where the old code always unmasked. In MSI mode the next MSI should recover it (f04be34 says MSIs still arrive while masked), and the window is tiny. But the base couldn't get stuck masked, and it's a two-line change, so I'd fold it into this PR if you're happy to. A separate PR is fine too.
0e6ac99
omacom/linux-aurora carry/edgeB-7.3 (tag edgeB3) 54835f485826: edgeB2 plus aurora-silicon/linux#1598 (T8122 SPI2 input and SPI4 reference clocks), the J613 Touch ID data-ready line, and omacom/linux-aurora#370 (brcmfmac ring completions). The M3 Air's Touch ID works again: the SPI2 clock was described as 200 MHz, so the sensor frame missed its transfer budget. Mesa and aura are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sync the kernel and Mesa to today's Aurora tips, with our carries re-applied: - linux-aurora 7.3.0.aurora0testedgeC: omacom/linux-aurora tag edgeC (carry/aurora-7.3) e50bdd5dea6f, aurora-silicon/linux integration/aurora de2c29696952 plus our open PRs omacom#2145 to omacom#2156 and omacom#2199, omacom#1598, the J613 Touch ID data-ready line and omacom/linux-aurora#370. Config unchanged. - mesa-aurora and vulkan-aurora: omacom/mesa tag edgeC (carry/aurora-7.3) fb3b11e121c, aurora-wip 45963937b6f0 plus aurora-silicon/mesa omacom#415 and omacom#416. aura stays at edgeB2 (703a0a92). Lab-tested on the M3 Air, MacBook Neo, M4 Pro (J616s) and M2 Max (J414c). Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a MacBook Air (M1, 2020, J313) with BCM4378,
brcmfmaccan leave ring completions unserviced, including ioctl responses and the D3 ACK. They then time out.Cause
brcmf_pcie_quick_check_isr()masks the dongle withbrcmf_pcie_intr_disable()whenever it readsmailboxintnon-zero. Since f04be34 ("wifi: brcmfmac: Do not service msgbuf IRQs until ready in MSI mode"), that helper also clearsirq_ready, and the threaded handler services the rings only whileirq_readyis set. So for exactly the interrupts the hard handler caught withmailboxintstill set, the thread skipsbrcmf_proto_msgbuf_rx_trigger(), then setsirq_readyagain on its way out.In MSI mode the firmware clears
mailboxintitself, so whether the hard handler sees it set is a race. When it does, the completions that came with that interrupt wait in the D2H rings until some later interrupt. This firmware sends mailbox data over the control ring (noBRCMF_PCIE_SHARED_USE_MAILBOX), so that includes the D3 ACK.brcmf_msgbuf_query_dcmd_len()andbrcmf_pcie_pm_enter_D3()then time out, and the second aborts system suspend. In INTx mode the hard handler always clearsirq_readyfirst, so the rings are never serviced from the thread at all.Change
The hard handler masks the dongle without touching
irq_ready, and the thread unmasks it only whileirq_readyis set, without setting it.irq_readyis now controlled only by the code that sets the rings up and tears them down, which is what f04be34 meant it for.Testing
Suspend stress through maclab on a MacBook Air (M1, 2020, J313): two lab builds from this tree at
b798f2b, with the Mac's own config. Each ran 15 cycles of 25 s s2idle (woken by a timer) with Wi-Fi traffic in between, with PCIe ASPM L1.1/L1.2 on the Wi-Fi link (powersupersave, L1.2 timing as macOS programs it).7.2.11-labb798f2b0-4585j1105-104309-e433brcmf_pcie_pm_enter_D3timed out on the 4th suspend and suspend was aborted; omarchy-m-test regressed (failedsystemd-suspend.service)7.2.11-lab428772f0-1559j1105-104457-32c5This patch alone does not fix that failure. The firmware itself does not acknowledge D3 on every 4th suspend with the L1 substates on, and the stacked follow-up PR handles that. This PR fixes a separate, real loss of completions, found by reading the code and confirmed by two independent reviews. Both the 4th-suspend failure and the unacknowledged D3 are visible in dmesg either way.
The tested commit
428772fdiffers from this PR's commit only in the alignment of one continuation line (checkpatch.pl --strict). checkpatch's only remaining warning is that it cannot resolve theFixes:commit id in a tree without that history; f04be34 is inintegration/aurora.Not tested:
🤖 Generated with Claude Code