Skip to content

wifi: cfg80211: send the held-back scan message of a stale request - #2110

Open
LiamRay11 wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
LiamRay11:j804/cfg80211-stale-scan
Open

LiamRay11 wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
LiamRay11:j804/cfg80211-stale-scan

Conversation

@LiamRay11

Copy link
Copy Markdown

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

  • On NETDEV_DOWN, cfg80211 completes the scan with ___cfg80211_scan_done(rdev, false). That parks the result message in rdev->scan_msg 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. That work is the only place that sends and clears rdev->scan_msg.
  • The message stays forever, and nl80211_trigger_scan(), cfg80211_conn_scan() and the internal scans return -EBUSY while it is set.

The fix

Queue scan_done_wk from 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.

  • What ran: kernel 7.3.0 built from integration/aurora bf423bf0e with 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 a read-only NVRAM partition. Those nodes were needed to reach the root filesystem and SSH.
  • Booted through aura on the installed root filesystem. A systemctl reboot from this kernel (watchdog restart) returned to the installed system.

Results for this PR (smoke test only):

  • After a pm_test=devices suspend cycle, Wi-Fi stayed connected, a rescan listed 39 networks, and there were 0 CTRL-EVENT-SCAN-FAILED / -16 messages.
  • pm_test=devices does 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=-16 until 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.o builds with W=1 without warnings.

integration/aurora has since moved to 677be395b; this branch still merges into it without conflicts.

Notes for reviewers

  • NETDEV_DOWN also warns when a driver has not finished its scan, so the trigger here is partly a driver that does not abort its scan on ndo_stop. The cfg80211 state is still wrong afterwards: one late cfg80211_scan_done() should not wedge the wiphy.
  • This is core wireless code. It may belong on linux-wireless as well as, or instead of, this fork.

🤖 Generated with Claude Code

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 sithglan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants