Repository navigation
wifi: brcmfmac: pcie: reset the dongle before freeing host buffers on remove - #1707
Merged
Merged
Conversation
… remove brcmf_pcie_remove() marks the bus down and masks the interrupt, then calls brcmf_detach(), which tears down msgbuf and unmaps the RX buffers posted to the firmware. The chip is only reset near the end of remove. In between, the firmware is still running and associated, so frames that arrive in that window are written into RX buffers that are no longer mapped. With an IOMMU this shows up on every unbind or rmmod under traffic, for example on Apple M1 Pro (BCM4387): apple-dart 581008000.iommu: translation fault: status:0x81000404 stream:1 code:0x404 (unknown) at 0xbf5ab2cc and on M4 Pro (BCM4388) as "write PTE invalid" faults on its DART. Reset the dongle right after the interrupt is quiesced and before brcmf_detach(), and drop the later reset. Firmware commands sent from brcmf_detach() already fail at this point because the bus state is DOWN, so nothing depends on the firmware staying alive. Tested on M1 Pro, 5 rmmod/modprobe cycles each with about 200 packets per second of UDP traffic to the host: 39 DART faults before (0, 10, 10, 9, 10), 0 after, Wi-Fi back within 6 s every time. s2idle and probe at boot unchanged. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brcmf_pcie_remove()unmapped the RX buffers posted to the firmware (inbrcmf_detach()) before it reset the chip. The firmware keeps running and associated until that reset, so frames arriving in the gap were DMA'd into unmapped IOVAs. Every unbind orrmmodunder traffic logged IOMMU translation faults: 581008000 stream 1 on M1 Pro (BCM4387), "write PTE invalid" on the M4 Pro (BCM4388) DART.This resets the dongle right after the interrupt is quiesced and before
brcmf_detach(), and drops the later reset. Firmware commands frombrcmf_detach()already fail at that point because the bus state is DOWN, so nothing relies on the firmware still running.Probe, s2idle and WoWLAN do not touch this path. Only remove does: unbind,
rmmod, and setup failure.Tests
M1 Pro (j316s), one-shot kernel fleet67 + integration brcm80211, brcmfmac loaded once at boot. Five
modprobe -r brcmfmac_wcc brcmfmac; modprobe brcmfmaccycles, each with about 200 UDP packets per second sent to the Mac:Same boot: 3 rtc1 s2idle cycles, gateway up after each. Enforcing, 0 AVC.
M2 (j413), same test (DART 681008000):
3 rtc1 s2idle cycles before the reloads on both kernels, gateway up after each. Enforcing, 0 AVC.
pcie.cis byte-identical to the one built and tested.🤖 Generated with Claude Code