Skip to content

Fix Wi-Fi dying after suspend on BCM43602 MacBooks - #10332

Open
garethevs3 wants to merge 1 commit into
omacom:quattrofrom
garethevs3:fix-brcmfmac-suspend-bcm43602
Open

garethevs3 wants to merge 1 commit into
omacom:quattrofrom
garethevs3:fix-brcmfmac-suspend-bcm43602

Conversation

@garethevs3

Copy link
Copy Markdown

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/-12 errors) and Wi-Fi stays dead until a reboot.
  • It's intermittent by nature — the in-place PCIe resume path sometimes succeeds and sometimes doesn't — which is why it reads as "Wi-Fi randomly dies after sleep" rather than a consistent failure. Tracked upstream and unfixed since 2017: kernel.org bugzilla #196019, #197977.
  • Adds install/hardware/apple/fix-brcmfmac-suspend.sh, which 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 performs successfully, instead of relying on the flaky in-place resume path.
  • Scoped to the confirmed BCM43602 PCI IDs already used by 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

  • Verified on a MacBookPro12,1 (BCM43602, 14e4:43ba): observed the actual failure in journalctl after a real sleep/wake cycle (firmware timeout cascade, requiring a reboot to recover).
  • Confirmed the fix manually: repeated pre/post invocations of the installed hook complete cleanly, the wlp3s0 interface reappears, and NetworkManager reconnects within a few seconds each time.
  • Not yet verified on other BCM43602 Mac models (MacBookPro13,x) — PCI ID match should be equivalent, but flagging for anyone who can confirm.

🤖 Generated with Claude Code

https://claude.ai/code/session_017XWKvdTCkjZXrGHPvDySZ4

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
@sayem314

sayem314 commented Sep 5, 2026

Copy link
Copy Markdown

@robosayem review this pr

@robosayem robosayem left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Existing installs never see this: install/hardware/all.sh runs 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?
  2. Unlike the supplicant script, the lspci gate is not Apple-scoped (sys_vendor check 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.

@rand0mdud3

rand0mdud3 commented Sep 11, 2026 •

Copy link
Copy Markdown

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.

@rand0mdud3

Copy link
Copy Markdown

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.

@rand0mdud3

Copy link
Copy Markdown

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.

@garethevs3

Copy link
Copy Markdown
Author

Can confirm my fix is still working after a week of solid use. Haven't experienced a dropout since 👍

@rand0mdud3

Copy link
Copy Markdown

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.

@rand0mdud3

Copy link
Copy Markdown

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

@hanscnelson

Copy link
Copy Markdown

Third BCM43602 model, same signature: MacBookPro14,2, 14e4:43ba, Omarchy 4.0.3-1 (the sleep hook is not installed here), kernel 7.2.3-arch1-3.

Lid-close S3 ~8 min, undocked. On resume:

ieee80211 phy13: brcmf_msgbuf_query_dcmd: Timeout on response for query command
ieee80211 phy13: _brcmf_set_multicast_list: Setting mcast_list failed, -5
ieee80211 phy13: brcmf_c_set_cur_etheraddr: Setting cur_etheraddr failed, -5

NetworkManager: do-change-link: failure 5 (Input/output error), could not set MAC, then Couldn't initialize supplicant interface: Timeout was reached four times. Interface never reached activated again. Full shutdown/reboot recovered.

An earlier resume the same boot had already reloaded firmware (wlan0 renamed to wlp2s0, brcmf_inetaddr_changed: fail to get arp ip table err:-52). feature_disable=0x82000 is present (handshake quirk); it does not cover this S3 hang.

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.

@makoni

makoni commented Sep 17, 2026

Copy link
Copy Markdown

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 14e4:43ba, Apple subsystem 106b:0173, Omarchy on kernel 7.2.5-3-omarchy. The hook from this PR is not installed here.

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:

00:20:42  PM: suspend exit
00:20:44  brcmf_msgbuf_query_dcmd: Timeout on response for query command
00:20:44  _brcmf_set_multicast_list: Setting mcast_list failed, -5

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:

PM: suspend entry 2800
brcmf_pcie_pm_enter_D3 ... returns -5 2797
Failed to put system to sleep ... Input/output error 1399
first → last failure 00:21:36 → 12:18:25, 11 h 56 min

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: brcmf_cfg80211_set_power_mgmt: Unable to set pm timeout, (-12), then the reboot stopped progressing once journald was down and needed a power cycle.

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 brcmf_pcie_remove was reported above:

modprobe -r brcmfmac_wcc && modprobe -r brcmfmac && modprobe brcmfmac

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 OnFailure= of systemd-suspend.service that reloads the module only after a failed suspend, gated on brcmf_pcie_pm_enter_D3 ... returns -5 appearing in the kernel log within the last three minutes. Trade-off against this PR's approach, stated fairly:

  • unloading on every suspend pays the reconnect cost each time and walks the brcmf_pcie_remove path each time — which is where the GPF above was hit;
  • acting only on failure leaves the first suspend of an incident broken, and lands on that same path when the firmware is already flaking, so it does not dodge the hazard, only meets it less often.

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.

@rand0mdud3

Copy link
Copy Markdown

@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.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 805396c4e84a7b530122f15b3396b128525e5568 against quattro by Claude Opus 5.5, with Codex Medium as a second opinion. Both read this diff alongside the four other open pull requests that work around the same brcmfmac post-suspend failure: #7180, #7333, #11570 and #12314. Nothing was run on a worker for this one. The comparison below decided it, and a VM has no Broadcom radio to show the fix working anyway.

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:

  • install/hardware/apple/fix-brcmfmac-suspend.sh:34-35: the pre-sleep modprobe -r discards its errors and nothing checks that the module actually unloaded. When it loses the race with NetworkManager, as @rand0mdud3 saw on the 11,5, post reloads a module that was never removed, the firmware is not reset, and nothing is logged. Reset Apple BCM4350/BCM43602 Wi-Fi around sleep #7333 unbinds the PCI device through sysfs, which does not depend on the module's reference count, records each device before unbinding it, and rebinds from ExecStopPost so a failed or timed-out pre is still undone.
  • install/hardware/all.sh:42 runs only at install time, and there is no migration, so a BCM43602 Mac that already runs Omarchy never gets the hook. Reset Apple BCM4350/BCM43602 Wi-Fi around sleep #7333 ships a migration for existing installs.
  • Unloading brcmfmac acts on every device using the driver, and the gate has no Apple vendor check. Reset Apple BCM4350/BCM43602 Wi-Fi around sleep #7333 acts only on the matching Apple devices.

Not settled by any of the five: the GPF @rand0mdud3 hit in _cfg80211_unregister_wdev when tearing down firmware that was already timing out. A sysfs unbind still goes through brcmf_pcie_remove, so #7333 shares that exposure.

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 ff52b69a through a long lid-closed suspend on your Macs is what would move this forward. The install steps are in the review comment on #7333.

bjhinkle added a commit to bjhinkle/omarchy that referenced this pull request Oct 8, 2026
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]>
@omarchybot

Copy link
Copy Markdown
Collaborator

Checked again at 805396c4e84a7b530122f15b3396b128525e5568 against quattro by Claude Opus 5.5, with Codex Medium as a second opinion. The code has not changed, so nothing was run on a worker. Two things around it have changed.

The crash on unload now has a cause, and this hook is exposed to it. In my last comment the GPF @rand0mdud3 hit in _cfg80211_unregister_wdev was still unexplained. @makoni has since reproduced it on #7333 and traced it to a P2P interface removal race in brcmfmac itself. The upstream fix is "wifi: brcmfmac: fix P2P device removal race in brcmf_detach()" (08a3f02fea63). It is in wireless.git and marked for stable, but it is not yet in mainline or in the 7.2 kernel Omarchy ships. modprobe -r brcmfmac at install/hardware/apple/fix-brcmfmac-suspend.sh:35 goes through the same brcmf_pcie_remove → brcmf_detach teardown as #7333's unbind. So on today's kernel, any of these fixes can oops a machine on the way into suspend and leave it needing a hard power-off. That is worse than Wi-Fi staying dead until a reboot. The hook also ignores the sleep type in $2 (line 32), so it runs on s2idle and hibernate as well as S3.

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 linux-omarchy that carries the brcmfmac fix before any of them is safe to enable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants