Repository navigation
Conversation
When a netdev goes down while its driver is still scanning, NETDEV_DOWN completes the scan for cfg80211 with ___cfg80211_scan_done(rdev, false). That parks the result message in rdev->scan_msg, to be sent once the driver is done, and, because the driver still owns the request, only marks the request stale. When the driver later calls cfg80211_scan_done(), the stale path frees the request and returns without queueing scan_done_wk, the only place that sends and clears rdev->scan_msg. The message then stays forever, and nl80211_trigger_scan(), cfg80211_conn_scan() and the internal scans all fail with -EBUSY while it is set: no scan or connect works on that wiphy until the driver is reloaded. Queue scan_done_wk from the stale path as well, so the parked message is sent. Since a run queued this way may find that the message has already gone out and a newer scan is in progress, make the work function return when there is no message to send and the current request has not yet been completed by the driver. Seen on a MacBook Pro (M6, J804) with the Centauri driver, on an earlier base (integration/aurora f5fa539): NetworkManager takes the interface down for a lid-close sleep while a wpa_supplicant scan runs, and after the wake every scan failed with "CTRL-EVENT-SCAN-FAILED ret=-16" until reboot. With this change (and scan abort and interface-down handling in that driver), Wi-Fi reconnected within 2 s after each of two lid sleeps, with no failed scan. Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sithglan
left a comment
There was a problem hiding this comment.
Test report, 2026-11-17: Apple Mac mini M6 (J873g/T8152, board 0x24). PR revision tested: 517dd2f1d5602720d72b0b6d7eca3ce6d9a58012.
Host validation used the combined #2105–2108/#2110–2112 series (54742c617db4 on 677be395b9d2) with Clang 22. All changed driver objects built with W=1 and no new warnings; two pre-existing DART unused-helper warnings were unchanged.
net/wireless/scan.o built with Clang 22 and W=1 with no new warnings. This patch was also applied to the separate M6 hardware-test kernel; Wi-Fi scans completed successfully, returning 10 and 19 BSS entries in the two smoke runs.
The scan-versus-NETDEV_DOWN / held-back stale-request race was not deliberately triggered. This is build and ordinary scanning smoke coverage, not a reproduction of the race or proof that every ordering is fixed.
Summary
A generic cfg80211 fix. If a netdev goes down while its driver is still scanning, every later scan and connect on that wiphy fails with -EBUSY until the driver is reloaded.
The bug
___cfg80211_scan_done(rdev, false). That parks the result message inrdev->scan_msgand, because the driver still owns the request, only marks the request stale.cfg80211_scan_done(), the stale path frees the request and returns without queueingscan_done_wk. That work is the only place that sends and clearsrdev->scan_msg.nl80211_trigger_scan(),cfg80211_conn_scan()and the internal scans return -EBUSY while it is set.The fix
Queue
scan_done_wkfrom the stale path too, so the parked message is sent. A run queued this way may find that the message is already gone and a newer scan is running, so the work function now returns when there is no message to send and the current request has not been completed by the driver.Testing
On hardware: MacBook Pro 14-inch (M6, J804), 2026-11-16, tested by LiamRay11.
bf423bf0ewith all nine J804 linux PRs merged (t8152-mailboxes, dart-gen3, dt-board, centauri, g18-fast-retire, cfg80211-stale-scan, smc, cs42l84-jack, and an NVMe PR that is not sent yet), plus retest-only device-tree changes that are not part of these PRs: SSD nodes (ANS mailbox, SART, NVMe), PCIe port 0 with the N1 Wi-Fi, the USB0 gadget console, and aread-onlyNVRAM partition. Those nodes were needed to reach the root filesystem and SSH.systemctl rebootfrom this kernel (watchdog restart) returned to the installed system.Results for this PR (smoke test only):
pm_test=devicessuspend cycle, Wi-Fi stayed connected, a rescan listed 39 networks, and there were 0CTRL-EVENT-SCAN-FAILED/ -16 messages.pm_test=devicesdoes not take the interface down during a running scan, so it does not reproduce the lid-sleep race this fixes. That kernel did not carry the Centauri scan-abort changes either.Earlier, with the Centauri driver on an older base (integration/aurora f5fa539): NetworkManager takes the interface down for a lid-close sleep while a wpa_supplicant scan runs. Without the fix, every scan after the wake failed with
CTRL-EVENT-SCAN-FAILED ret=-16until reboot. With the fix, Wi-Fi reconnected within 2 s after each of two lid sleeps. That run also had the Centauri scan-abort and interface-down handling, which is not upstream and not in this PR.Checks on this base:
net/wireless/scan.obuilds withW=1without warnings.integration/aurora has since moved to
677be395b; this branch still merges into it without conflicts.Notes for reviewers
ndo_stop. The cfg80211 state is still wrong afterwards: one latecfg80211_scan_done()should not wedge the wiphy.🤖 Generated with Claude Code