Repository navigation
wifi: brcmfmac: drop carrier on disconnect and guard stale flowring creates - #4292
Conversation
…reates brcmf_cfg80211_disconnect() and brcmf_link_down() clear the VIF CONNECTED/CONNECTING status bits before issuing BRCMF_C_DISASSOC, so when the firmware subsequently delivers BRCMF_E_LINK down, brcmf_notify_connect_status() sees those status bits already cleared and skips brcmf_net_setcarrier(ifp, false). As a result, netif_carrier stays on and BRCMF_NETIF_STOP_REASON_DISCONNECTED is never set on the netdev. Two races follow: 1. On deep-sleep resume, brcmf_pcie_pm_leave_D3() sets BRCMF_BUS_UP and clears BRCMF_NETIF_STOP_REASON_BUS. With DISCONNECTED unset, netif_stop reaches 0 and wakes the TX queue on a disconnected interface right as brcmf_cfg80211_resume() runs BRCMF_C_DOWN / BRCMF_C_UP. 2. Any TX packet queued before or immediately after suspend schedules brcmf_msgbuf_flowring_create_worker(), which sends MSGBUF_TYPE_FLOW_RING_CREATE while firmware is down/MPC. Firmware rejects the request with status 4 (BCME_NOTUP) and tears down or traps when the host immediately frees the ring DMA buffer. Call brcmf_net_setcarrier(..., false) before BRCMF_C_DISASSOC in both brcmf_cfg80211_disconnect() and brcmf_link_down() (for STATION and P2P_CLIENT VIFs), and guard brcmf_msgbuf_flowring_create_worker() so any in-flight create work whose interface has already lost carrier deletes the pending flowring locally instead of issuing FLOW_RING_CREATE to down firmware. Add host unit and mutation tests covering all three guards. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Independent review of 422b1d8. Main moved to dacbc06 while I worked (20 commits); none touches this PR's files, so the merge tree is this head plus unrelated changes. One of them, #4285, changes net/wireless/sme.c (cfg80211 now drains queued disconnect events); it is cfg80211's side of the same disconnect, so the J773g row (on this head, without #4285) and the next J516s run on main cover the two together only after merge.
What it does. On a station or P2P-client disconnect, and in brcmf_link_down() (suspend without WoWL, interface down), the driver now drops carrier itself before DISASSOC. Before, the status bits were cleared first, so the firmware's later link-down event skipped brcmf_net_setcarrier(false), carrier stayed up and the TX queue could wake on a dead link after resume. The flowring create worker also refuses to create a ring for an interface without carrier and frees the pending ring locally.
Checked.
- Every
brcmf_link_down()caller (suspend,__brcmf_cfg80211_down, link-down event, leave IBSS): only STA/P2P-client vifs get the new carrier drop. AP/GO/IBSS keep their own carrier paths; AWDL and P2P-device vifs are untouched. The secondsetcarrier(false)in the link-down event path is harmless. - Carrier comes back on link-up (SET_SSID, or PSK_SUP with the firmware supplicant) before the host sends any EAPOL, and AP/GO turn it on in
start_ap, so the guard can't eat handshake frames. - The guard does what the existing
dma_alloc_coherentfailure path does (local delete, queued skbs freed). The worker runs on the same CPU's per-CPU workqueue while xmit holds BH, so the create-then-enqueue intx_queue_datacan't race the delete. - Shared code: brcmfmac on J516s, J773g, J714s, J700 (and M1/M2). No chip or SoC gate, no parameter, no new constant.
- Small note, no change needed: AWDL interfaces keep carrier off on main, so AWDL data sent with carrier off would now have its flowring create dropped. That fits the comment that carrier comes on once AWDL runs.
Local checks on this head (Mini/pc, work/c1637-4292-4293):
- W=1
cfg80211.o+msgbuf.o(J773g ship config, gcc 16.2): 0 warnings at this head, 0 at main. brcmf-disconnect-flowring-tests.py: 7/7. brcmf host-test family: 99/99 (main: 95/95; the PR adds 4 jobs).checkpatch.pl --strict: 0 errors, 0 checks (1 warning: MAINTAINERS for the new test file).- Hosted: host-tests pass; pr-text passes now (I added the Tested/Risk/Not yet lines to the description).
Hardware. The J516s run (work/j516s-s2r-ab-20261204/results) used kernel 7.3.0-j516s-s2rab: this PR + #4293 on main d2a4949, with cfg80211.c/msgbuf.c byte-identical to this head. 3/3 disconnect/reconnect, then 11 deep sleeps + 1 s2idle in one boot, Wi-Fi back in 5 s each, 0 BCME_NOTUP/flowring/trap/WARN lines. The saved logs don't show the 20 pkt/s TX load the description mentions. The J773g second-generation row (main arm + this head, 3 deep sleeps under 20 pkt/s TX, disconnect/reconnect before and after) is queued with the M4 lead: work/kit-j773g-c1637-4292-4293-20261204.
Verdict: approve. The code is better than before and doesn't change anything for AP/IBSS/AWDL. Merge after the J773g row passes. (Posted as a comment: GitHub doesn't let this account approve a PR it opened.)
|
J773g (M4 Mac mini, T8132, OS fw 27.2, Stage 2
|
What: Drop carrier during station and P2P-client disconnect before tearing down the flowrings. The flowring create worker discards a pending ring locally when the interface has lost carrier.
Tested: J773g at
422b1d8901bcpassed 3 pre-sleep and 1 post-wake disconnect/reconnect cycles and 3 deep sleeps under continuous TX, with no bad kernel or firmware lines. J516s passed 3 disconnect/reconnect cycles, 11 deep sleeps and one s2idle with the same driver files. The host test family passed 99/99.Risk: two-way door · brcmfmac disconnect and flowring handling across Mac generations.
Evidence
Head commit:
422b1d8901bconorigin/main(8ae72dc32d5b)Checkpatch:
scripts/checkpatch.pl --git HEAD~1..HEAD— 0 errors, 0 warningsHost tests (
tools/testing/brcmfmac):test_disconnect_carrier_flowring: 7/7 PASSbrcmfmachost tests: 99/99 PASSHardware verification (combined trial build carrying this exact patch on J516s M3 Pro):
BCME_NOTUP, 0 flowring errors, 0 firmware traps, 0 kernel warningsExact-head J773g test and build ID