Skip to content

wifi: brcmfmac: serialize firmware-offloaded replacement joins after suspend - #2163

Merged
RyanTheTide merged 5 commits into
aurora-silicon:mainfrom
satchlj:j613/bcm4388-resume-join-cancellation
Dec 1, 2026
Merged

RyanTheTide merged 5 commits into
aurora-silicon:mainfrom
satchlj:j613/bcm4388-resume-join-cancellation

Conversation

@satchlj

@satchlj satchlj commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What: Preserve wdev->u.client.ssid_len in cfg80211_connect() when a replacement connect for the same SSID returns -EBUSY, serialize replacement firmware-offloaded (SAE/PSK) station joins in brcmfmac with BRCMF_C_DISASSOC and a BRCMF_JOIN_CANCEL_TIMEOUT (1000 ms) barrier until firmware emits a terminal event, and reinitialize non-WoW ready station firmware (GET_PM / DOWN / UP / SET_PM) on resume. Drops the previous BCM4388 chip-ID gate, splits net/wireless/sme.c into its own commit, and extends brcmf-suspend-tests.py (restore-pm mutation).

Tested:

  • Host tests at 2115ca6e5001 (on main f5c98532ba34): brcmf-join-cancel-tests.py and brcmf-suspend-tests.py controls pass and all of their mutations (6 + 10, including restore-pm, resume-join and the new down-error-fence) are killed; the other brcmf-* host tests pass. LLVM=1 W=1 arm64 compile of brcmfmac/cfg80211.o and fweh.o: clean. checkpatch.pl --strict on the review fix: 0/0/0.
  • Same-base control on J613 (MacBook Air 13" M3, T8122) with linux-aurora 7.3.0.aurora1-43 (dc7c873addc8, includes #3169) and both userspace workarounds removed: 0/1 FAIL on forced scan-interrupted s2idle (iwd: connect-failed, status: 16, NetworkManager config -> failed (reason 'no-secrets')).
  • Prior equivalent full-fix build (5a8bb0c8, join-cancel barrier + non-WoW resume reinit) on J613 with workarounds removed: 30/30 forced scan-interrupted s2idle + 67/67 natural cycles (97/97 PASS, 0 failures).

Risk: two-way door · all brcmfmac Macs (cfg80211_connect() -EBUSY SSID preservation, firmware-offloaded station join cancellation, and non-WoW station resume DOWN/UP reinit).

Not yet: Exact-head J613 (MacBook Air 13" M3, T8122) hardware verification run at 2115ca6e5001. The prior equivalent build passed 97/97 on J613.

@satchlj
satchlj force-pushed the j613/bcm4388-resume-join-cancellation branch from 209d130 to 2d31212 Compare November 17, 2026 20:39
@satchlj

satchlj commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

host-tests failed on the first head because of this PR, not the test. The runner extracts brcmf_cfg80211_resume() into a standalone C fixture; the non-WoW reinitialization I had carried over used fields and firmware commands the fixture does not stub, so it stopped compiling before any assertion ran.

The amended commit (2d31212) drops that reinitialization (firmware down/up and power-mode restore on resume). It keeps the two parts that address the traced bug: preserving the pending SSID when the driver answers -EBUSY, and the BCM4388 SAE/PSK join-cancellation barrier. The test was not changed.

Locally: the suspend fixture passes all 33 controls and all six CI mutations hit their intended assertions; 394 of 394 host-test runs pass; strict checkpatch is clean; cfg80211.o and sme.o compile for ARM64 with LLVM 18.1.3 (C only).

What this changes about the evidence: the 400-cycle J613 run covered the older-base candidate including the reinitialization. This reduced port has not been booted, and it is not yet shown that the join changes alone are sufficient on hardware. The PR body is corrected to say so. A J613 row for this exact head will follow.

@satchlj

satchlj commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author
J613 candidate Forced scan request + suspend Natural suspend Result
integration/aurora dcce0e751c71 + exact #2163 head 2d3121207bfe + linux#2104 speaker-sense fix acdfc4c15316 11 pass, 1 fail (stopped at 12/30) 0/150 Failed the 30-second Wi-Fi recovery criterion

The Wi-Fi code was identical to 2d3121207bfe3d5cd83dac6f952d306af126f18f. The only added source change was the J613 speaker-sense polarity fix. Both userspace workarounds were absent for all 12 cycles. Cycle 12 resumed from s2idle, but association and traffic did not recover within the joint 30-second deadline. iwd reported four connect-failed, status: 16 events and NetworkManager reported Network.Connect failed. Neither target kernel warning appeared and no rescue ran during measurement.

The scan request was accepted before each forced suspend. The fallback harness did not verify an in-flight scan abort or barrier execution on the failed cycle. The natural phase was skipped after the failure. The older candidate's 100 forced + 300 natural result included non-WoW reinitialization and used a different base. This run shows that the reduced PR did not meet the recovery criterion on this J613. It does not isolate the cause of the reconnect failure.

Next: restore the reinitialization on resume (with the host fixture extended to cover it), and run a control on this same base without the PR, so the failure can be attributed. Please hold review of this head until that row is posted.

@satchlj
satchlj marked this pull request as draft November 17, 2026 23:18
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for posting the failed row plainly and asking to hold. Notes for the next version:

  1. cfg80211.c:2551 checks BRCM_CC_4388_CHIP_ID, but the race comes from the firmware supplicant: a replacement connect arrives while an offloaded SAE/PSK join is still running. The use_fwsup check below already selects that case. Could the chip test go, so every chip using firmware SAE/PSK offload gets the barrier?
  2. The 1000 ms wait for the terminal event: please say where the bound comes from (e.g. the firmware's join timeout), or name it with the reasoning.
  3. The net/wireless/sme.c change alters cfg80211 for every driver. It is easier to review as its own patch, also aimed at linux-wireless.
  4. We agree on the same-base control first. If firmware down/up on resume comes back, please show the control result that needs it.

Row for the next head on the J613: the control without the PR, then the PR with 30/30 forced and 150/150 natural cycles reconnecting within 30 s, no bss_not_found or port-authorization warnings, and no barrier timeouts. Without the chip test, we can add no-regression rows on M1 Pro and M2 (BCM4387).

@RyanTheTide

Copy link
Copy Markdown
Contributor

@satchlj checking open drafts today. To come out of draft, this still needs:

  • A test run at the current head on a Mac with the hardware it touches, then mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

@satchlj

satchlj commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Same-base control re-check on MacBook Air 13" M3 (J613, T8122) running linux-aurora 7.3.0.aurora1-43 (dc7c873addc8, which includes merged #3169 brcmfmac skip 500 ms down delay), without #2163 and without userspace workarounds:

  • Forced scan-interrupted s2idle cycle 1: FAIL (0/1)
    • Clean 5 s s2idle entry/exit via apple-pmu-rtc (rtc0), zero early wake.
    • brcmfmac kprobe trace confirmed scan_begin (n_ssids=1) → scan_return (err=0) → wifi_suspend → scan_end (aborted=1) → wifi_resume.
    • Immediately on resume, iwd failed reconnection with event: connect-failed, status: 16 across both BSSIDs (GDBus.Error:net.connman.iwd.Failed: Operation failed, NetworkManager config -> failed (reason 'no-secrets')), with no recovery within 30 s.
    • Restoring the userspace workarounds and restarting iwd + NetworkManager restored connectivity cleanly.

So merged #3169 does not resolve the scan-interrupted s2idle reconnect failure on J613; #2163 is still needed. Next step is building and running the #2163 patch on this same dc7c873addc8 base.

@satchlj satchlj changed the title wifi: brcmfmac: serialize BCM4388 replacement joins after suspend wifi: brcmfmac: serialize firmware-offloaded replacement joins after suspend Nov 28, 2026
@satchlj
satchlj force-pushed the j613/bcm4388-resume-join-cancellation branch 2 times, most recently from ff484ad to e0ddda0 Compare November 29, 2026 02:28
@satchlj
satchlj marked this pull request as ready for review November 29, 2026 02:28
@satchlj
satchlj requested review from a team and DjDeveloperr as code owners November 29, 2026 02:28

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FIX, then re-review at e0ddda09.

Blockers:

  1. Permanent vif->join_canceling lockout on race or timeout (drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:2542-2574, 5178-5195, 7867-7880):
    • brcmf_notify_connect_status() runs on the event workqueue without wiphy_lock. Between test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state) (L2566) and brcmf_set_join_canceling(vif, true) (L2544), the event callback can observe join_canceling == false, handle the old join's final terminal event, and clear BRCMF_VIF_STATUS_CONNECTING. brcmf_cancel_pending_join() then calls reinit_completion(), sets join_canceling = true, and sends BRCMF_C_DISASSOC to an already-idle firmware, which emits no further terminal event. wait_for_completion_timeout() then times out after 1000 ms and leaves vif->join_canceling = true.
    • Once vif->join_canceling stays true after any BRCMF_JOIN_CANCEL_TIMEOUT timeout (from that race, a lost/suppressed firmware event, or a subsequent non-WoW brcmf_cfg80211_resume() that sends BRCMF_C_DOWN/BRCMF_C_UP at L5185-5189 without clearing join_canceling), every subsequent brcmf_cfg80211_connect() enters brcmf_cancel_pending_join() via brcmf_join_canceling(ifp->vif), skips BRCMF_C_DISASSOC because join_canceling is already true, stalls under wiphy_lock for 1000 ms, and returns -EBUSY permanently until the interface is brought down (__brcmf_cfg80211_down).
    • Fix: (a) after reinit_completion() + brcmf_set_join_canceling(vif, true) (with ordering against brcmf_notify_connect_status()), re-check test_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state) and bail out with join_canceling = false if the old join already completed; (b) clear join_canceling (and any stale CONNECTING bit) when non-WoW brcmf_cfg80211_resume() runs BRCMF_C_DOWN/BRCMF_C_UP; and (c) provide a bounded recovery path when cancel times out (e.g., firmware DOWN/UP or resetting join_canceling once firmware is quiesced) instead of wedging all future connects in -EBUSY.
  2. Exact-head hardware verification (Not yet): Post the exact-head J613 (and second-Mac regression check if touching all brcmfmac chips) hardware row and green CI on the fixed head.

Checked: Full 5-file diff (net/wireless/sme.c, drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.{c,h}, tools/asahi/brcmf-suspend-tests.py, tools/asahi/run-host-tests.py), cfg80211_connect() -EBUSY SSID preservation, non-WoW GET_PM/DOWN/UP/SET_PM resume sequence, and brcmf_notify_connect_status() locking/event handling.

Evidence
  • net/wireless/sme.c:1538 (if (!wdev->connected && !(err == -EBUSY && old_ssid_len))): sound — cfg80211_connect() already verified SSID equality at L1453-1456 before calling rdev_connect(), and old_ssid_len is 0 once any prior cfg80211_connect_done() clears it, so ssid_len is preserved only while an earlier join is genuinely pending.
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:5178-5195: non-WoW GET_PM/DOWN/UP/SET_PM sequence and brcmf-suspend-tests.py restore-pm mutation look clean, aside from not clearing vif->join_canceling across BRCMF_C_DOWN/BRCMF_C_UP.
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:2542-2574: brcmf_join_canceling() has no escape hatch after a 1000 ms timeout except __brcmf_cfg80211_down(), and L2566 -> L2544 races with lockless brcmf_notify_connect_status().

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Thanks, all three parts of blocker 1 were real. Fixed in d3b50118, a new commit on top with no history rewrite.

  • (a) The race: the cancel is now armed with a full barrier before CONNECTING is tested. A join that ended through the normal path is not cancelled, whether it ended before the flag was set or during the wait (the timeout path re-checks CONNECTING). If that join connected, the link stays and the replacement gets one -EBUSY.
  • (c) Bounded recovery: a connect that finds an earlier cancel still pending sends BRCMF_C_DISASSOC again, where before it skipped it. If that second cancel also sees no terminal event, the join is taken as gone and join_canceling clears. So a silent firmware costs one -EBUSY, not a permanent one.
  • (b) Resume: the non-WoW brcmf_cfg80211_resume() clears join_canceling after BRCMF_C_DOWN, and fails a still-pending host connect once with cfg80211_connect_done().

Tests:

  • New tools/asahi/brcmf-join-cancel-tests.py: the real brcmf_cancel_pending_join() against scripted firmware events, 6 cases (normal, ended before arm, ended during the wait, connected during the wait, silent twice, retry with event). 4 negative controls (no-recheck, skip-retry-disassoc, retry-wedge, no-barrier-arm) each fail.
  • brcmf-suspend-tests.py gains the resume case and a resume-join control.
  • Both are registered in run-host-tests.py. cfg80211.o builds W=1 (LLVM arm64), and checkpatch --strict on the patch gives 0/0/0.

Blocker 2 is still open: the exact-head J613 row needs the test J613, which is down right now. The candidate boot plan will be rebuilt at this head.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH at d3b5011

The flag ordering, completion recheck and resume cleanup address the earlier wedge paths. On a second timeout the code now admits a replacement without a terminal event or a confirmed reset. Please establish that old join events are fenced before that admission, or retain the refusal until confirmed firmware recovery. Cover the late old event after a replacement is admitted, and retain the J613 runtime row.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Agreed, admitting on a second timeout was unfenced. Fixed in eaf3f53d, a new commit on top, by keeping the refusal until recovery is confirmed.

  • Second silent cancel: the station firmware is reset (GET_PM/DOWN/UP/SET_PM) while join_canceling is still set, so the event path keeps ignoring the old join, and the connect is still refused. The reset ends the join for certain, and join_reset records it.
  • Admission: a later connect admits a replacement only when brcmf_fweh_idle() holds, meaning no firmware event is queued or being handled. So no event of the old join can reach it.
    • Why not flush instead: brcmf_fweh_idle() takes only the event queue's own spinlock and work_busy(). Flushing the event worker from connect() could deadlock against the rtnl_lock that an interface event takes.
  • Resume: the non-WoW resume's DOWN fences the same way. A pending or cancelled join keeps the flag, the reset is recorded, and the next connect releases it on an idle queue, for any supplicant type.

Tests:

  • brcmf-join-cancel-tests.py now covers: reset on the second silent cancel; a late old-join event still queued (refused, no further firmware commands); release after the queue drains. Its 6 negative controls each fail, including admit-unfenced and no-reset.
  • brcmf-suspend-tests.py (47 controls) checks the resume fence, and its resume-join control fails as it should.
  • cfg80211.o and fweh.o build W=1 (LLVM arm64), and checkpatch --strict on the patch gives 0/0/0.

The J613 runtime row is kept in Not yet. The test J613 is down; the candidate boot will run it at this head.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: HOLD at eaf3f53d — code and host-test coverage are clean (both the earlier join_canceling lockout and unfenced second-timeout admission blockers are cleanly resolved); awaiting queued CI and the exact-head J613 hardware row.

Blockers:

  1. Exact-head J613 hardware verification at eaf3f53d (pending rubra availability) and green queued CI checks.

Checked: Full delta commit eaf3f53de6 (drivers/net/wireless/broadcom/brcm80211/brcmfmac/{cfg80211.c,cfg80211.h,fweh.c,fweh.h}, tools/asahi/{brcmf-join-cancel-tests.py,brcmf-suspend-tests.py,run-host-tests.py}), brcmf_fweh_idle() event-queue + worker ordering, brcmf_station_reset() / join_reset fencing across both second-timeout cancel and non-WoW resume, and commit Signed-off-by.

Evidence
  • Fencing and recovery verified (eaf3f53de6):
    • Second silent cancel (cfg80211.c:2539-2578): Instead of admitting a replacement without a terminal event, the second timeout calls brcmf_station_reset() (GET_PM/DOWN/UP/SET_PM) while join_canceling remains true, records vif->join_reset = true on success, and still returns -EBUSY. A subsequent connect admits only once brcmf_fweh_idle(ifp->drvr) confirms both event_q is empty and !work_busy(&fweh->event_work) (preventing any queued/in-flight old-join event from reaching the replacement).
    • Non-WoW resume (cfg80211.c:5247-5265): Arms join_canceling = true before BRCMF_C_DOWN whenever CONNECTING or join_canceling is active, records join_reset = true after DOWN succeeds, and fails a pending host connect once via cfg80211_connect_done().
    • Non-fwsup connect escape (cfg80211.c:2619): !ifp->vif->join_reset allows non-fwsup connects to pass through the reset fence once fweh is idle rather than staying blocked in -EBUSY.
    • Tests: Registered in run-host-tests.py with 6 killed mutations (no-recheck, skip-retry-disassoc, retry-wedge, no-barrier-arm, admit-unfenced, no-reset) plus brcmf-suspend-tests.py resume-join.
  • Remaining merge gate: Queued CI green and exact-head J613 hardware row at eaf3f53d.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

The host-tests failure on eaf3f53 comes from main, not from this PR. The only failing test is g17-compute-owed-stamp-tests (control and every mutation). It fails because rustc rejects the extracted harness: E0061: this function takes 0 arguments but 1 argument was supplied at owed.rs:1618. The same test fails the same way on plain main c3fbd23; I ran it locally. #3594 is the open fix for it. All brcmf tests pass, including brcmf-join-cancel-tests and brcmf-suspend-tests. readiness was cancelled behind it. I'll re-run once #3594 lands.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:wireless Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at 2115ca6e: not ready yet

Check Detail
CI at head ok 6 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 2115ca6e
Conflicts ok none
PR text ok Risk: two-way · all brcmfmac Macs (cfg80211connect() -EBUSY SSID preservation, firmware-offloaded station join cancellation, and non-WoW station resume DOWN/UP reinit).

Areas: area:gpu, area:wireless

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@satchlj
satchlj force-pushed the j613/bcm4388-resume-join-cancellation branch from eaf3f53 to abd2f57 Compare November 29, 2026 09:01
When cfg80211_connect() receives a replacement connect request for the
same SSID while an earlier join is still in progress and the driver
returns -EBUSY, clearing wdev->u.client.ssid_len drops the lookup key
needed when the earlier join completes.

Preserve wdev->u.client.ssid_len on -EBUSY when old_ssid_len was already
set, matching how a refused reassociation preserves the existing SSID.

Signed-off-by: Satya Benson <[email protected]>
When userspace issues a replacement connect while a firmware-offloaded
(SAE/PSK) station join is still in flight, starting a new join without
waiting for the prior join to terminate lets the old join's events
complete against the replacement request or wedge firmware
authentication.

Serialize replacement connects by sending BRCMF_C_DISASSOC for the old
target, suppressing stale connect/roam callbacks until firmware delivers
a terminal event (bounded by BRCMF_JOIN_CANCEL_TIMEOUT while holding the
wiphy lock), and returning -EBUSY if cancellation fails or times out so
cfg80211 keeps the pending join intact. Clear the cancel flag when the
interface goes down.

Signed-off-by: Satya Benson <[email protected]>
After a non-WoW suspend where the dongle stayed powered across sleep,
firmware can retain stale association and supplicant state that causes
the first post-resume join to fail with authentication errors.

On non-WoW resume of a ready station VIF, preserve the configured power
mode across a BRCMF_C_DOWN / BRCMF_C_UP cycle. Extend
brcmf-suspend-tests.py (including the restore-pm mutation) and register
it in run-host-tests.py.

Signed-off-by: Satya Benson <[email protected]>
brcmf_cancel_pending_join() could leave join_canceling set for good:

- The event path runs without the wiphy lock. If the old join's last
  event was handled just before the flag was set, the DISASSOC went to
  idle firmware, no terminal event followed and the wait timed out.
- After any timeout the flag stayed set, and every later connect skipped
  the DISASSOC, waited the full second again and returned -EBUSY until
  the interface went down.
- A non-WoW resume's DOWN/UP did not clear it either.

Now the cancel is armed with a full barrier before CONNECTING is tested,
and a join that ended (or connected) through the normal path, before the
flag or during the wait, is not cancelled. A connect that finds an
earlier cancel still pending sends the DISASSOC again; if that one also
sees no terminal event, the join is taken as gone, so one -EBUSY is the
most a silent firmware costs. The resume's DOWN ends any join: it fails
a pending host request once and clears the flag.

tools/asahi/brcmf-join-cancel-tests.py runs the cancel against scripted
firmware events, with four negative controls; brcmf-suspend-tests.py
checks the resume path.

Signed-off-by: Satya Benson <[email protected]>

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: HOLD at abd2f57 for current CI and the J613 hardware row.

Checked: The brcmfmac, wireless SME and focused join/suspend test blobs match eaf3f53. The current test runner still registers both suites and their timeout, reset and resume mutation cases. The prior code review carries to this head. Keep the current-head J613 validation and hosted checks.

@satchlj
satchlj force-pushed the j613/bcm4388-resume-join-cancellation branch from abd2f57 to efb853f Compare November 29, 2026 09:05
@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

I rebased onto main f5c98532ba34 to resolve the conflicts with e012a8c ("wait for the link down, not 500 ms, before a suspend"). It's conflict-only: the new head is efb853f901d0, the patches are otherwise unchanged, and git range-diff shows only the resolution hunks.

The resolutions:

  • cfg80211.h / brcmf_alloc_vif(): keep link_down next to join_cancel_done/join_canceling.
  • brcmf-suspend-tests.py: one struct completion stub and one reinit_completion; the vif stub carries both sets of fields.

The join-cancel and suspend controls pass, and all 15 of their mutations are killed (Linux host).

One interaction for the reviewer, deliberately left unchanged in this rebase. While a cancelled join is pending, brcmf_notify_connect_status() returns before the new complete(&vif->link_down). The suspend only waits on link_down for a CONNECTED vif, and a join is only cancelled while the vif isn't connected, so at worst a suspend falls back to the old 500 ms limit.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FIX, then re-review at efb853f9

Blockers:

  1. brcmf_cfg80211_resume() leaves join_canceling stuck true if BRCMF_C_DOWN fails (drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c L5247–L5256):
    • When BRCMF_VIF_STATUS_CONNECTING is set (pending == true) and join_canceling was false, L5250 arms brcmf_set_join_canceling(ifp->vif, true) before calling BRCMF_C_DOWN.
    • If BRCMF_C_DOWN returns an error (if (err) goto out; at L5253–L5254), join_canceling is never restored: join_canceling stays true, join_reset stays false, and BRCMF_VIF_STATUS_CONNECTING stays set.
    • As a result, brcmf_notify_connect_status() suppresses events for the live join, and for any non-SAE/PSK profile (!ifp->vif->join_reset && profile->use_fwsup != BRCMF_PROFILE_FWSUP_SAE && != BRCMF_PROFILE_FWSUP_PSK) every subsequent brcmf_cfg80211_connect() returns -EBUSY until interface down.
    • Fix: Save was_canceling = brcmf_join_canceling(ifp->vif) before arming and restore if (!was_canceling) brcmf_set_join_canceling(ifp->vif, false); when BRCMF_C_DOWN fails, and cover the BRCMF_C_DOWN error path with CONNECTING set in brcmf-suspend-tests.py.
  2. Complete green hosted CI and post the exact-head station resume + replacement-join hardware receipt at the updated head.

Checked:

  • Audited efb853f9 (MERGEABLE on main f5c98532) across cfg80211.c, cfg80211.h, fweh.c, fweh.h, brcmf-join-cancel-tests.py, brcmf-suspend-tests.py, and run-host-tests.py.
  • Rebase conflict resolution against e012a8c9 (link_down completion) is clean: link_down is waited on only for a connected VIF, while join_canceling applies only when unconnected.
  • The brcmf_station_reset() + join_reset + brcmf_fweh_idle() fence in brcmf_cancel_pending_join() avoids rtnl_lock deadlock while keeping join_canceling armed across the reset until fweh->event_q and fweh->event_work are idle, and __brcmf_cfg80211_down() clears both join_reset and join_canceling.
  • DCO Signed-off-by: present on efb853f9; no Apple material or policy issues.
Evidence
  • cfg80211.c L5247–L5256: brcmf_set_join_canceling(ifp->vif, true) runs before BRCMF_C_DOWN; if (err) goto out; bypasses join_reset = true and cfg80211_connect_done() without restoring join_canceling.
  • cfg80211.c L2618–L2621: non-SAE/PSK profiles require join_reset to enter brcmf_cancel_pending_join() and release join_canceling.

…g it

A second cancel that saw no terminal event admitted the replacement at
once. A late event of the old join could then still reach it.

Now that cancel resets the station firmware (GET_PM, DOWN, UP, SET_PM)
with join_canceling still set, so the event path keeps ignoring the old
join, and still refuses the connect. The reset ends the join for
certain. A later connect admits a replacement only once no firmware
event is queued or being handled (brcmf_fweh_idle()), so none of the
old join's events can reach it. brcmf_fweh_idle() takes only the event
queue's own lock; flushing the worker from connect could deadlock on the
rtnl lock an interface event takes.

The non-WoW resume's DOWN fences the same way: a pending or cancelled
join keeps the flag, the reset is recorded, and the next connect
releases it on an idle queue, whatever the profile's supplicant. A DOWN
that fails ends no join, so a join that was not already being
cancelled gets its events back.

brcmf-join-cancel-tests.py adds the reset, a late event still queued
after it, and the release on a drained queue, with the admit-unfenced
and no-reset negative controls; brcmf-suspend-tests.py checks the
resume fence and the failed DOWN, with the down-error-fence negative
control.

Signed-off-by: Satya Benson <[email protected]>
@satchlj
satchlj force-pushed the j613/bcm4388-resume-join-cancellation branch from efb853f to 2115ca6 Compare November 29, 2026 09:11
@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Blocker 1 is fixed at 2115ca6e5001, amended into the commit that added the resume fence.

  • brcmf_cfg80211_resume() records was_canceling before arming. If BRCMF_C_DOWN fails, it clears join_canceling again unless a cancel was already in progress. join_reset stays false, and CONNECTING stays set, because no join was ended.
  • brcmf-suspend-tests.py adds the failed-DOWN case for both a pending join (fence dropped, events pass, no connect_done) and an already-cancelling join (fence kept, no reset recorded). There's a down-error-fence negative control, registered in run-host-tests.py.
  • Linux host: 50 suspend controls pass; all 10 suspend mutations and 6 join-cancel mutations are killed. LLVM=1 W=1 arm64 cfg80211.o/fweh.o: clean. checkpatch --strict: 0/0/0.

Blocker 2 is still open. CI is re-running on the new head. The exact-head J613 hardware row is blocked: the test J613's remote-recovery cable needs reseating before it can run any risky trial.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: HOLD at 2115ca6 for hosted CI and the station resume and replacement-join hardware row.

Checked: On failed C_DOWN, the resume path now clears a cancellation fence it armed itself and retains a pre-existing cancellation. The fixture covers both states, and the new mutation removes the restoration to exercise the regression. The code finding at efb853f is addressed. Keep the current-head J613 receipt and hosted checks.

@satchlj

satchlj commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Hardware row at this head on J613 (MacBook Air 13" M3, T8122): 6/6 forced-scan s2idle cycles recovered in 0.5–1.0 s, then a hard reset during the 7th. So this row is not a pass.

Setup: main 972a5665 merged with this PR at 2115ca6e5001, #1490 16915f57, #3590 0f755337 and #3504 8e6a5b81. Both userspace workarounds were moved aside: the NetworkManager drop-in with wifi.iwd.autoconnect=false, and the system-sleep hook that restarts iwd after a wake. Each cycle: iwctl station wlan0 scan, wait until iwd reports the scan running, then rtcwake -m no -s 15 and systemd-suspend.service, then wait up to 30 s for IPv4 and a gateway ping.

Results:

  • Cycles 1–6: the scan was running at suspend, the suspend completed, and Wi-Fi was back in 0.52–0.99 s each time.
  • Cycle 7: PM: suspend entry (s2idle), then nothing more in the journal. The machine reset and came back on its default kernel, with no panic or pstore record.
  • For comparison, the same kernel without this PR and with the same workarounds aside recovered within 30 s in only about 1 cycle in 10 (default main-based kernel, the same evening).

Not yet / not attributed: the reset has not been reproduced at this head, and its cause is unknown. The same evening, the same forced-scan harness also gave resets and one missed RTC wake on kernels without this PR, always with the workarounds aside. With both workarounds in place, 20/20 cycles were clean on the default kernel. So one reset is not evidence against this change. A repeat at this head, with a reset-safe harness, is next.

@satchlj

satchlj commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Repeat at this head, same boot as the partial row above (2115ca6e in the same merged tree): 20/20 forced-scan s2idle cycles, with Wi-Fi back in 0.51–0.54 s each time, and no reset.

The setup was the same as before, with both userspace workarounds moved aside. The harness now stops at the first cycle whose Wi-Fi does not return, and reboots the machine itself if a cycle stalls for 3 minutes. Neither happened.

  • Every cycle had the scan running at suspend and woke on the RTC.
  • 21 PM: suspend entry (s2idle) for 20 cycles: one attempt aborted with Some devices failed to suspend, or early wake event detected during the NVMe context save, and its cycle then completed.
  • For comparison, the same evening's default kernel without this PR recovered within 30 s in about 1 cycle in 10 with the workarounds aside.

Tally at this head: 26 of 27 forced-scan cycles recovered in under 1 s; the other ended in the reset above. That reset is still unexplained and has not reproduced at this head. Resets and a missed RTC wake were also seen on kernels without this PR, always with the workarounds aside.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: MERGE at 2115ca6e5001

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6102231485).

Follow-ups (not blocking): hosted CI, J613 station resume + replacement-join row

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 2115ca6e5001 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 2115ca6 that the readiness check found (PR body or comment). CI: linux train L3 = main 429e7e1 + 28 approved PRs (candidate 45c2fa4b): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit dcp-fabric/dcp-topology/dcp-display/macsmc/spi-hid-apple/mt7932/asahi/sep pass; ave failed to build only because of #3153 (unused static helper under -Werror; #3153 held out) and passes with #3153 reverted from the candidate; host tests apple-dcp and apple-scaler-recovery pass. The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 433023d into aurora-silicon:main Dec 1, 2026
8 of 11 checks passed
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Follow-up on the reset in the 29 Nov row (6/6, then a reset in cycle 7). More J613 rows since then show that the hard reset is not specific to this PR: it also happens on main without it, and it did not happen with the WLAN function unbound. This PR's part, Wi-Fi coming back after a scan-interrupted suspend without the userspace workarounds, held in every cycle that completed.

MacBook Air 13" M3 (J613, T8122). Same harness as above: a scan is running at suspend, 15 s RTC wake, Wi-Fi must be back within 30 s, both userspace workarounds aside unless noted, and a run stops at its first failure.

Kernel Arm Result
A forced scan 13 recovered (0.51–1.52 s), reset in cycle 14
A forced scan 15 recovered (~0.5 s), reset in cycle 16
A forced scan, NM wifi.iwd.autoconnect=false kept 6 recovered (the last in 0.51 s), then a reset in cycle 6
A forced scan, CPU memory floor off 40/40 (0.51–1.51 s)
B forced scan 37 recovered, reset 9 s after the cycle-38 resume
B forced scan 2 recovered, reset 5 s after the cycle-3 resume
B forced scan, CPU memory floor off 10 recovered, reset 0.1 s after the cycle-11 resume
B no forced scan reset 0.08 s after the first resume (the first sleep after a WLAN rebind), then 60/60 from a clean boot
B WLAN function unbound from brcmfmac, Bluetooth bound 70/70, no reset
C forced scan no Wi-Fi after the first resume (iwd connect-failed, status: 16 on every BSS); reset about 30 s later, while the harness reloaded brcmfmac and restarted iwd
C resume, then a brcmfmac teardown reset at the first resume, twice, before the teardown ran
C forced scan, workarounds in place 60/60

What the resets look like: each came within about 15 s of a completed resume. Nothing reached the kernel log, and no soft-lockup, hung-task or oops panic fired (all three armed on A). The 33–66 s gap to the next boot fits a watchdog reset, not a panic (a deliberate panic with panic=30 takes 39 s here). The floor-off rows on B reset too, so the memory floor is not the cause.

Reading: the reset needs the WLAN function bound, and it occurs with and without this PR, so these rows don't attribute it to this change. With this PR, all 123 forced-scan cycles that completed got Wi-Fi back, in 0.5–1.5 s where timed. Without it, Wi-Fi never came back after the first resume.

Not yet: the 150-cycle natural-suspend phase. Warning and barrier-timeout counts for these runs are not available, because their per-cycle logs were not kept. The reset itself has no cause or fix yet.

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

Labels

area:gpu Area from CODEOWNERS (bot) area:wireless Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants