Repository navigation
wifi/Bluetooth: apple: centauri: fix scan lock stalls, abort sync, and BT ring drain - #3120
Conversation
…stop scan_profile27() on T6050 and scan_worker() on T8142/T8152 held wifi->lock across the multi-second scan polling loop. Any concurrent cfg80211 station query (such as NetworkManager or iw link polling while holding wiphy->mtx) blocked on wifi->lock for the entire scan, stalling nl80211 operations including scan abort and causing -EBUSY failures on rapid rescan or connect. In addition, scan abort/timeout paths returned without waiting for the firmware's 0x80000005 stop completion event, allowing stale completions to terminate a subsequent scan early, and connect_worker() could latch a stale disconnect event drained during host_setup_commands(). Release wifi->lock around the polling sleep in both drivers' scan loops while re-checking stopping, command_failed, sleep/pause flags and Alpha stage before touching the transport. Skip synchronous firmware link-status queries in T6050 fill_station() while a scan is active so station queries return cached signal and live counters without contending with off-channel dwells. Synchronize command 65537 scan stops with a bounded wait for 0x80000005 (treating status 342 as already stopped), and drain and clear stale connect/disconnect event flags right before sending the join command in connect_worker(). Signed-off-by: Diljit Singh <[email protected]>
Unlike the polling btcentauri transport, btcentauri_t6050 relies on MSIs and TX submission kicks to run cen_io_work(). cen_io_work() snapshotted each RX ring tail once and drained at most CEN_RX_SLOTS entries without checking whether more descriptors had arrived during drain or whether a non-empty TX queue could now publish into a freed TX ring slot. Under advertising bursts or coalesced interrupts, unread events or queued frames could sit in the rings until an unrelated wakeup. Re-check all open RX ring tails and pending TX queues with available ring space before leaving cen_io_work(), rescheduling io_work when work remains. Add host unit tests and negative controls in tools/asahi/centauri-scan-tests.py covering both Wi-Fi scan lock/stop synchronization and Bluetooth ring drain rescheduling. Signed-off-by: Diljit Singh <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at e0d3171c5b11
Blockers:
drivers/net/wireless/apple/centauri/centauri_wifi.c:916-921,1022-1033anddrivers/net/wireless/apple/centauri/t6050/centauri_wifi.c:1143-1149,1269-1278: On the final iteration of the wait loop, whenjiffies >= deadlineright aftermutex_unlock(&wifi->lock); usleep_range(1000, 2000); mutex_lock(&wifi->lock);, the loop exits without re-checkingstopping,transport_paused,command_failed,host_sleep_sent, orreadl(wifi->a.bar + 8) != 2(and without one finaldrain(wifi)), then immediately callsscan_stop_chunk(wifi, done).scan_stop_chunk()callscommand(wifi, 65537, NULL, 0)directly, and neithercommand_control()(centauri_wifi.c:737-766) norcommand_reply()(t6050/centauri_wifi.c:764-810) checksREAD_ONCE(wifi->stopping)orreadl(wifi->a.bar + 8) != 2before publishing a TX descriptor, advancingcommand_head, writingindex_write, and ringingwritel(1, wifi->a.bar + 0x1004)(int6050/centauri_wifi.c:812-814,command_reply()then faults the transport after already ringing the doorbell). Fix: guard the entry ofscan_stop_chunk()in both drivers with the samestopping/transport_paused/command_failed/host_sleep_sent/readl(wifi->a.bar + 8) != 2check before callingcommand(wifi, 65537, NULL, 0), and re-check state (and drain once) after the timeout loop exits before issuing the stop/warning.drivers/net/wireless/apple/centauri/centauri_wifi.c:958,1031-1033:scan_worker()discards the return value ofscan_stop_chunk(wifi, done)on chunk timeout, leavingret == 0. Ifscan_stop_chunk()returned-EIO(becausestopping,transport_paused, orbar + 8 != 2triggered during its unlocked wait) or-ETIMEDOUT, the outerfor (chunk = 0; chunk < chunks && !ret; chunk++)loop proceeds directly to the next chunk and callscommand(wifi, 65551, scan, scan_size)without checkingstopping,transport_paused, orscan_abort. Fix: captureret = scan_stop_chunk(wifi, done)(or propagate non-zero errors/timeouts) and checkstopping/transport_paused/scan_abortbefore starting each chunk.drivers/net/wireless/apple/centauri/centauri_wifi.c:993-998,1007-1020: If the chunk already sentcommand(65537)at line 1012 (stopped = true, extendingdeadlineby 1000 ms to wait for0x80000005), andwifi->scan_abortbecomestruebefore0x80000005arrives,if (!stopped)skips waiting for the in-flight stop completion and breaks immediately with-ECANCELED, leaving0x80000005unconsumed for the next scan. Fix: factor out the post-stop wait forwifi->scans_done != doneso the abort path still waits for the already-issued stop's0x80000005completion (stopping early ifstopping/transport_paused/bar + 8 != 2).- PR readiness metadata: the J714s hardware evidence row currently cites
7.3.0-m5-censcanwithout the exact head commit SHA (e0d3171c), which is whypr-readinessis failing.
Checked: full source audit of drivers/net/wireless/apple/centauri/centauri_wifi.c, drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c, drivers/bluetooth/btcentauri_t6050.c, and tools/testing/selftests/drivers/net/apple/centauri-scan-tests.py; checked lock-drop concurrency windows, teardown/suspend races, ring drain safety, and zero board/model gating.
Evidence
drivers/bluetooth/btcentauri_t6050.c(cen_rx_pending(),cen_tx_ready(),cen_io_work()) audited clean:cen_aux_start()opens required rings 2 & 8 wheneverbt->runningis set,cen_io_work()checks!bt->running || transport_pausedunderbt->lock, andcancel_work_sync()tears down cleanly on close/suspend/remove.- In both Wi-Fi drivers, the
do { ... mutex_unlock(); usleep_range(); mutex_lock(); } while (time_before(jiffies, deadline));pattern creates a post-sleep exit path with no state check beforescan_stop_chunk()ringsBAR + 0x1004viacommand(65537). - In
centauri_wifi.c:1031-1033, ignoringscan_stop_chunk()'s return value allowsscan_worker()to enter the next chunk after-EIOor-ETIMEDOUT.
… wait Address post-sleep unlock window races across both the T6050 and shared Centauri Wi-Fi scan loops: - Guard scan_stop_chunk() entry in both drivers with the transport state check before issuing command 65537, and re-check transport state plus one final drain() after the scan/stop wait loops exit at deadline. - In shared centauri_wifi.c scan_worker(), propagate scan_stop_chunk() errors/timeouts to ret and check transport/abort state before starting each subsequent chunk. - Factor out scan_wait_stop() in shared centauri_wifi.c so an abort arriving after command 65537 was already sent still waits for the in-flight 0x80000005 completion unless the transport stops. - Extend tools/asahi/centauri-scan-tests.py to cover all three races against both drivers' production functions and add negative controls. Signed-off-by: Diljit Singh <[email protected]>
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE.
Blockers: none.
Checked: Re-reviewed commit 1620c5f2a3fb across drivers/net/wireless/apple/centauri/centauri_wifi.c, drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c, drivers/bluetooth/btcentauri_t6050.c, and tools/asahi/centauri-scan-tests.py, verified all four prior blockers are resolved, executed tools/asahi/centauri-scan-tests.py --negative-controls at this exact head, and confirmed all 3/3 CI checks (host-tests, readiness, pr-text) are green.
Evidence
- All prior blockers resolved at
1620c5f2a3fb:scan_transport_stopped()now guardsscan_stop_chunk()entry beforecommand(65537)in both drivers, and both wait loops re-check transport state plus run a finaldrain(wifi)after exiting at deadline.centauri_wifi.cscan_worker()checksscan_transport_stopped()andscan_abortbefore each chunk, propagatesret = stopped ? -ETIMEDOUT : scan_stop_chunk(wifi, done), and computesinfo.abortedfrom!!ret || scan_abort || stopping.centauri_wifi.cabort handling now callsscan_wait_stop(wifi, done)whenstopped == trueso an in-flight65537stop still consumes its0x80000005completion (exiting early with-EIOif transport stops).- PR readiness metadata updated cleanly (
readiness / readinessandpr-text / pr-textboth green).
- Local host-test & negative-control run (
tools/asahi/centauri-scan-tests.py --negative-controlsat1620c5f2a3fb):wifi-production: PASS,shared-wifi-production: PASS,bt-production: PASS.- All 9/9 negative controls (
scan-holds-lock-in-sleep,station-queries-fw-during-scan,timeout-skips-stop-wait,abort-ignores-342,t6050-stop-skips-entry-guard,shared-timeout-drops-stop-ret,shared-abort-skips-inflight-stop-wait,bt-drops-rx-reschedule,bt-drops-tx-reschedule) correctly rejected.
- CI at head
1620c5f2a3fb: 3/3 green (host-tests,readiness / readiness,pr-text / pr-text).
|
@satchlj Addressed all 4 review items in follow-up commit
|
Resolve the scan_worker conflict with aurora-silicon#3120's scan stop guards: a stopped transport asks for recovery only when the driver isn't stopping or paused and Alpha isn't at its run stage. Signed-off-by: Nick <[email protected]>
Risk: two-way · Apple N1 / Centauri Wi-Fi and Bluetooth (T6050, T8142, T8152)
What:
Fixes live-reproduced Wi-Fi scan flakiness and a Bluetooth ring-drain stall window across Apple Centauri / N1 drivers:
wifi->lockduring scan polling & skip firmware link queries mid-scan (drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c,drivers/net/wireless/apple/centauri/centauri_wifi.c):scan_profile27()(T6050) andscan_worker()(shared T8142/T8152) previously heldwifi->lockacross the entire multi-second scan while sleeping inusleep_range(1000, 2000). Any concurrentcfg80211query (wifi_get_station()/iw link/ NetworkManager signal polling) tookwiphy->mtxand blocked onwifi->lockfor seconds, stallingnl80211scan aborts and rapid re-triggers (-EBUSY).wifi->lockaroundusleep_range(1000, 2000)and re-check teardown/transport state (stopping,command_failed,host_sleep_sent/transport_paused, BAR status) after re-acquiring the lock before callingdrain(), before starting each chunk, onscan_stop_chunk()entry, and after wait loops exit at deadline.fill_station(), skip synchronous firmwarequery_link_status()whilewifi->scan_requestis active, returning the cached signal and live netdev counters immediately.t6050/centauri_wifi.c,centauri_wifi.c):scan_stop_chunk()(andscan_wait_stop()in sharedcentauri_wifi.c) so command65537scan stops on abort and timeout wait up to 1000 ms for the firmware's0x80000005completion event (treating firmware status342as already stopped), including whenscan_abortarrives after a stop was already sent (stopped == true), and propagate stop errors/timeouts instead of continuing to the next chunk.connect_worker()on both drivers, drain and clearconnect_event/disconnect_eventafterhost_setup_commands()immediately before issuing join command131072so a stale pre-join disconnect event cannot abort a new association with-ENOTCONN.io_workwhen ring work remains (drivers/bluetooth/btcentauri_t6050.c):cen_io_work()previously took a singlecen_tail()snapshot per ring with a fixedCEN_RX_SLOTSbudget and returned without re-checking whether new RX descriptors arrived or TX slots freed up.cen_rx_pending()andcen_tx_ready()checks before exitingcen_io_work(), reschedulingio_workwhenever open RX rings (aux, LE ring 10, HCI event ring 7) have unread descriptors or non-empty TX queues have free slots.tools/asahi/centauri-scan-tests.py, registered intools/asahi/run-host-tests.py):scan_transport_stopped,scan_stop_chunk,scan_profile27,fill_station), shared Wi-Fi (scan_transport_stopped,scan_wait_stop,scan_stop_chunk,scan_worker), and T6050 Bluetooth (cen_rx_pending,cen_tx_ready,cen_io_work) and exercises lock release, station queries mid-scan, guarded stop entry / timeout exit, chunk error propagation, post-stop abort wait, and BT RX/TX rescheduling, plus 9 negative controls.Tested:
1620c5f2a3fbea582596d94fd3a0480f7a6cecb9:python3 tools/asahi/run-host-tests.py --only centauri— 18/18 passed (including 9/9 negative controls incentauri-scan-tests.py).scripts/checkpatch.pl --strict --git origin/main..HEAD— 0 errors, 0 checks (0 warnings on1620c5f2a3fb).J714s, commit1620c5f2a3fbea582596d94fd3a0480f7a6cecb9, kernel7.3.0-m5-censcan2with MTE on, SEP active, default cmdline; baseline7.3.0-m5-cdirect15; verified running module SHA256s matchmodule-manifest.txt):wlp1s0f0/hci0)7.3.0-m5-cdirect15)7.3.0-m5-censcan2,1620c5f2a3fb)iw linkduring active scan (5×)-49 dBm)scan abort+ immediate re-trigger (5×, 0.1–3.0 s)-EBUSY(-16)scan flushpassed (0-EBUSY, 17–18 BSSes)any) Wi-Fi + BTWelcome 89), post-wake Wi-Fiscan flushrc=0 (14 BSSes) + BTbtmgmt find -lrc=0 (38 unique)Filter_Duplicates=0) + HCI pingsdmesg)7.3.0-m5-censcan2(1620c5f2a3fb):vulkaninfo+gpubench-vk compute.lightpassed before (108.99 us) and after (108.64 us), 0 faults.J714sESP byte-identically to7.3.0-m5-cdirect15, verified GPU alive, cleaned temporary build/module artifacts, and releasedhw.