Repository navigation
Fix Wi-Fi dying after suspend on BCM43602 MacBooks - #10332
garethevs3 wants to merge 1 commit into
Conversation
brcmfmac's firmware occasionally fails to reinitialize its message ring after suspend/resume on BCM43602 (2015-2017 MacBooks), leaving every wifi ioctl timing out until a reboot. It's intermittent because the in-place PCIe resume path sometimes succeeds and sometimes doesn't, which is what makes it look like Wi-Fi randomly dies after sleep rather than failing consistently. Tracked upstream and unfixed since 2017 (kernel.org bugzilla #196019, #197977). Installs a systemd-sleep hook that unloads and reloads the brcmfmac module around every suspend, forcing the same clean firmware download a cold boot already does successfully, instead of relying on the in-place resume path. Scoped to the confirmed BCM43602 PCI IDs already used by fix-brcmfmac-supplicant.sh, not the broader chip list -- the T2-era chips have their own suspend behavior already being tracked in discussion omacom#4695. Verified on a MacBookPro12,1 (BCM43602, 14e4:43ba): repeated manual unload/reload cycles complete cleanly and NetworkManager reconnects within a few seconds each time. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017XWKvdTCkjZXrGHPvDySZ4
|
@robosayem review this pr |
robosayem
left a comment
There was a problem hiding this comment.
Approved. Verified the technical claims independently.
Mechanism checks out. The failure model is real and accurately described — kernel bugzilla #197977 is literally titled brcmf_msgbuf_query_dcmd: Timeout on response for query command, and both cited bugs are open against BCM43602. Unload/reload around suspend via a systemd-sleep hook is the established workaround class for brcmfmac resume failures, and /usr/lib/systemd/system-sleep is the correct vendor location.
Module handling is correct across kernel generations. On kernels ≥ 6.1 the vendor code builds as a separate brcmfmac-wcc module that brcmfmac depends on, so unloading the core first would fail with EBUSY — the script removes brcmfmac_wcc before brcmfmac, which is the right order, and the silenced errors make it a clean no-op on older kernels. Arch builds CONFIG_BRCMFMAC_PCIE=y as a bool compiled into brcmfmac.ko (not a separate transport module), so there is nothing else that needs unloading. Reloading also re-reads /etc/modprobe.d, so this composes correctly with fix-brcmfmac-supplicant.sh's feature_disable option.
Repo conventions. 100644 mode matches its siblings and works because run_logged sources scripts with bash -eE; the script is set -e-safe (the only failure-capable commands are inside the if condition). The hook has a shebang, 755 mode, and exit 0 so a hook failure can never block suspend. The lspci gate is a no-op on non-matching hardware, so adding it unconditionally to all.sh is safe.
Two non-blocking notes
- Existing installs never see this:
install/hardware/all.shruns at install time only. A BCM43602 user who installed Omarchy before this lands keeps dying wifi through every update unless they rerun the script manually. The migrations mechanism exists for exactly this kind of state repair, and this script is idempotent by construction. Was a migration considered, or is install-time-only intentional for now? - Unlike the supplicant script, the lspci gate is not Apple-scoped (
sys_vendorcheck absent). BCM43602 also ships in a few third-party PCIe cards. The workaround is benign there (one extra module cycle per suspend), so I do not think it needs the gate, just flagging the difference.
The PR's own open item (MacBookPro13,x unverified) is fair to leave for whoever owns that hardware.
|
Verified on MacBookPro11,5 (BCM43602 14e4:43ba, second model after the author's 12,1). Repro: a suspend/resume produced the exact reported signature -- brcmf_msgbuf_query_dcmd timeouts cascading into -5 errors with bus is down -- and Wi-Fi stayed dead until reboot. (Disclosure: this box runs with amdgpu/radeon blacklisted for an unrelated suspend workaround; the wifi device path and the log signature match your 12,1 line-for-line.) Fix check: installed the hook; manual pre unloads both modules and post brings the interface back. Then a systemctl suspend: a third firmware download in the journal proves the post hook fired, reconnect completed ~5s after wake, zero timeouts since. One note on method: an rtcwake -m mem retest does NOT exercise this hook -- rtcwake bypasses systemd-sleep, confirmed by counting firmware loads. Worth naming systemctl suspend in the test plan. |
|
Follow-up from two lid-close cycles on the same 11,5: the hook has a silent-failure mode worth hardening before merge. Both cycles resumed cleanly, then Wi-Fi died with NO timeout cascade and NO wpa lines at all -- just silence, followed by NM wedged unkillably and a hard poweroff (plus the now-familiar frozen first reboot). Firmware-load count for the whole boot was 1 (boot only): the post never reloaded because there was nothing to reload -- the pre removal must have failed silently. Why it fails only sometimes: the pre runs modprobe -r while NM is concurrently tearing the device down (my log shows deactivating/DHCP-cancel/inetaddr err:-52 in the same second). Twice today the identical command succeeded from an idle shell, so it is a race, hidden by 2>/dev/null. When removal loses, post modprobe is a no-op on the still-loaded module, protection is zero, and nothing logs it. Suggestion: bring the interface down before rmmod (ip link set down on the wlp netdev), retry briefly, and fail loudly to the journal instead of 2>/dev/null -- a hook that silently no-ops leaves exactly the corpse above. Happy to test a v2 here. |
|
Incident from the same 11,5 that sharpens the hardening note: when the firmware is already flaking as pre runs (a msgbuf timeout 2s earlier), the unload itself walked into a GPF -- brcmf_pcie_remove -> brcmf_detach -> general protection fault in _cfg80211_unregister_wdev on a 0xdead address, segfaulting modprobe and wedging wpa_supplicant into D. Suspend aborted on the unfreezable task; the screen then blanked via DPMS ~30s later, which reads exactly like dead resume but the machine never slept. The logger line is what made this diagnosable after the fact, so the loud-failure part of the suggestion is validated. Open question for the hook design: whether to attempt unload at all when the firmware is already timing out, versus logging and leaving the doomed stack alone. |
|
Can confirm my fix is still working after a week of solid use. Haven't experienced a dropout since 👍 |
|
Lid-path proof on the 11,5, complementing the systemctl test: lid close with the v2 hook armed, firmware reload logged on resume, reconnect in 4s, zero timeouts across the cycle. The unload path fires correctly from the real lid path, not just manual invocation. |
|
Suggested hardening for the hook, running live on my 11,5 for two clean lid cycles (one genuine unload+reload with 4s reconnect, one correct stand-down on a real timeout with clean in-place resume after). Two changes over the PR version: interface down before rmmod with a 5x retry (the plain rmmod loses a race with NM mid-teardown and fails silently), and a health gate that skips the unload when firmware timeouts are already firing -- unloading then walked into a GPF in cfg80211 unregister (use-after-free on 0xdead), segfaulting modprobe and wedging wpa_supplicant into D. Note the gate reads journalctl -b -k (kernel facility only): without -k, sudo's own audit echo of the script text false-triggers it. Full file for adopt-as-wanted: #!/bin/bash
# Work around a brcmfmac/BCM43602 firmware bug where suspend/resume
# occasionally leaves the wifi message ring uninitialized (upstream #10332).
# Local hardening: the plain modprobe -r raced NetworkManager mid-teardown
# and failed silently, and worse, unloading while the firmware is already
# timing out wedges the stack (GPF in cfg80211 unregister, D-state tasks,
# aborted suspend). So: bring the interface down first, retry the unload,
# say so in the journal on any failure -- and skip the unload entirely when
# timeouts are already firing.
firmware_flaking() {
journalctl -b -k --no-pager --since "5 minutes ago" 2>/dev/null | grep -q "brcmf_msgbuf_query_dcmd: Timeout"
}
wifi_iface() {
local d
for d in /sys/class/net/wl*; do
[[ -e $d ]] && basename "$d" && return 0
done
return 1
}
case "$1" in
pre)
if firmware_flaking; then
logger -t brcmfmac-suspend "pre: firmware timeouts firing, leaving module loaded to avoid wedging suspend"
else
iface=$(wifi_iface) || true
[[ -n ${iface:-} ]] && ip link set "$iface" down 2>/dev/null || true
for _ in 1 2 3 4 5; do
modprobe -r brcmfmac_wcc 2>/dev/null
modprobe -r brcmfmac 2>/dev/null && break
sleep 1
done
if lsmod | grep -q "^brcmfmac "; then
logger -t brcmfmac-suspend "pre: module still loaded after retries, resume may fail"
fi
fi
;;
post)
modprobe brcmfmac
modprobe brcmfmac_wcc 2>/dev/null || true
;;
esac
exit 0 |
|
Third BCM43602 model, same signature: MacBookPro14,2, Lid-close S3 ~8 min, undocked. On resume: NetworkManager: An earlier resume the same boot had already reloaded firmware ( Does not exercise the hook — 4.0.3 does not ship it. Confirms the 12,1 / 11,5 timeout cascade on 14,2 via the real lid path. Happy to test the hook (including the v2 interface-down / timeout-gate hardening) if useful. Related but separate: T1 Touch Bar stayed dark on the same resume (t1bridge#18); not a brcmfmac problem. |
|
A fourth BCM43602 model with the same signature, and one consequence of the bug I have not seen quantified here. Machine. MacBookPro14,3 (15-inch 2017), BCM43602 Same failure. Lid closed 23:54, first suspend clean. Something woke the machine 26 minutes later; the resume itself completed, and two seconds after it the firmware stopped answering: What it costs when the lid simply stays shut. The reports above are short cycles — 8 minutes, a couple of lid closes. This one was left closed overnight, and because the lid is closed, logind re-requests suspend roughly every 30 seconds and hits the dead card every time:
So the machine never slept again all night. It was on AC here (no disconnect logged), so I cannot report a battery figure — on battery this is a flat discharge with the lid shut. Shutdown afterwards also hung: That turns "Wi-Fi is dead until reboot" into "the laptop also runs warm in a bag until morning", which seems worth having in the PR's own case for merging. The unload path is clean on 7.2.5. Since this fix depends on it, and a GPF in Interface returns and reassociates in 7 s, nothing in dmesg beyond the expected teardown noise. Tested with the firmware healthy, which is the common case this hook runs in — not the flaking case where the GPF was seen. One design note, not an objection. I went the other way here: a handler on
Preventive is the better fit for a shipped default. Mentioning it because the failure-gated shape may be useful as hardening: it gives a place to stand down when the reload itself fails, instead of repeating it. |
|
@garethevs3 — checking whether the hardened v2 is on your roadmap: interface down before rmmod with retry (plain rmmod loses a race with NM mid-teardown and fails silently), a health gate that stands down when firmware is already timing out, plus the GPF-on-unload finding above (unload during a timeout cascade oopses in cfg80211 unregister and wedges wpa_supplicant). Running live here across lid cycles. Happy to re-verify at head or spin the v2 into a suggestion commit if you'd rather review it as a diff. |
|
Reviewed at Where this one stands. It correctly identifies the failure, and the reports in this thread from three more BCM43602 models (11,5, 14,2, 14,3) confirm it is real. Of the five fixes, though, #7333 is the one that should land, and this one should not land beside it, because systemd runs every sleep hook together and two Wi-Fi resets on one machine would race. Codex was asked to choose among the five without being given my answer and also chose #7333. It can read this session, so its agreement is not guaranteed to be independent. What #7333 does that this one does not:
Not settled by any of the five: the GPF @rand0mdud3 hit in What happens next. Choosing between the competing fixes is the maintainer's decision, so this waits on them. @hanscnelson, @makoni and @rand0mdud3: a run of #7333's commit |
Remove brcmfmac-reload. Five open pull requests work around the same brcmfmac failure after S3, and only one should land: systemd runs every sleep hook at once, so two resets of one radio would race. The reviews on omacom#10332 and omacom#7333 pick omacom#7333. Unloading brcmfmac also tears the device down through brcmf_pcie_remove, the path where a P2P interface removal race in the driver has oopsed during sleep (reported on omacom#7333 and omacom#10332), so a second copy of that exposure here would not help. This pull request now covers Thunderbolt and USB-C only. The installer and the migration install thunderbolt-remove-rescan alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Checked again at The crash on unload now has a cause, and this hook is exposed to it. In my last comment the GPF @rand0mdud3 hit in The comparison still comes out the same. #11570 has dropped its Wi-Fi hook, which leaves #7180, #7333 and #12314 as the fixes competing with this one. Codex was asked again, without my answer, and again chose #7333, for the reasons in my last comment: it checks that the reset happened, reaches existing installs through a migration, and only touches Apple devices. It also agreed that the kernel race blocks all of them equally. It can read this session, so its agreement is not guaranteed to be independent. What happens next. This waits on the maintainer, who has to choose between the fixes, and on a |
Summary
brcmfmac's firmware on BCM43602 (2015-2017 MacBooks) occasionally fails to reinitialize its message ring after suspend/resume: every wifi ioctl times out (brcmf_msgbuf_query_dcmd: Timeout on response for query command, cascading into-5/-12errors) and Wi-Fi stays dead until a reboot.install/hardware/apple/fix-brcmfmac-suspend.sh, which installs asystemd-sleephook that unloads and reloads thebrcmfmacmodule around every suspend, forcing the same clean firmware download a cold boot already performs successfully, instead of relying on the flaky in-place resume path.fix-brcmfmac-supplicant.sh(14e4:43ba/43bb/43bc), not the broader chip list in that file — the 2018+ and T2-era chips have different suspend behavior and are already being tracked separately in Omarchy lid/sleep/suspend issue on MacBook (bug + solution to be tested) #4695.Test plan
14e4:43ba): observed the actual failure injournalctlafter a real sleep/wake cycle (firmware timeout cascade, requiring a reboot to recover).pre/postinvocations of the installed hook complete cleanly, thewlp3s0interface reappears, and NetworkManager reconnects within a few seconds each time.🤖 Generated with Claude Code
https://claude.ai/code/session_017XWKvdTCkjZXrGHPvDySZ4