Skip to content

wifi: apple: centauri: keep the association through a deep sleep (WoWLAN) - #3921

Draft
m0d16l14n1 wants to merge 1 commit into
aurora-silicon:mainfrom
m0d16l14n1:feat/centauri-wowlan
Draft

m0d16l14n1 wants to merge 1 commit into
aurora-silicon:mainfrom
m0d16l14n1:feat/centauri-wowlan

Conversation

@m0d16l14n1

@m0d16l14n1 m0d16l14n1 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: let an N1 Mac keep its Wi-Fi association through a deep sleep when userspace arms WoWLAN. Today a deep sleep refuses to start while the station is associated, so cfg80211 leaves the network first and the Mac wakes up offline. The driver now advertises WoWLAN "any". Once it is armed (iw phy <phy> wowlan enable any), a deep sleep keeps the association and sends the firmware's associated host sleep state (1, where 3 is the unassociated sleep). That state also lets connection loss, disconnect, scan quota, keepalive and service wake events through to the host. At resume the driver drains the events that came in during the sleep and logs whether the association was kept. With WoWLAN not armed, and on s2idle, nothing changes. One commit on main.
Tested: J815 (MacBook Air 15" M5), with WoWLAN not armed only: one deep suspend of 30.7 s on a kernel carrying this patch. The firmware got the unassociated sleep (state=3 events=9), the sleep and wake handshakes returned 0, the station rejoined on channel 149 after the wake, and AWDL file transfers (AirDrop-like) worked before and after the sleep. 0 N1 driver errors, 0 WARN/BUG/Oops, 0 failed units (SELinux is not built on this image). Build: make W=1 drivers/net/wireless/apple/centauri/ at this head (arm64, with the KUnit tests on), no warnings; checkpatch --strict clean; run-host-tests.py --only centauri 22 of 22.
Risk: two-way door; N1 boards on the shared transport (J813, J815 and the other T8142/T8152 boards). Behaviour changes only once userspace arms WoWLAN. Armed, a deep sleep no longer leaves the network first. If the firmware drops the link during the sleep, the driver reports the disconnect at resume.
Not yet: the armed sleep itself (the firmware keeping the association through the sleep, which is what this PR is for); a wake started by the N1; other N1 boards. NetworkManager takes a WoWLAN device down and up again right after a wake, so under NetworkManager the Mac still rejoins after the wake even when the firmware kept the link. Other network managers have not been tried.

Details
  • wiphy->wowlan advertises WIPHY_WOWLAN_ANY only. No packet patterns, magic packet, GTK rekey or disconnect triggers are advertised, because the firmware is not given any.
  • .suspend (cfg80211) arms the associated sleep only for a deep sleep (pm_suspend_via_firmware()) with WoWLAN "any" set, the station connected, and no connect, scan, stop or paused transport in flight. Otherwise it returns 1, so cfg80211 disconnects first, as before. .resume clears the flag.
  • The device suspend accepts an associated station only when the sleep was armed. It sends host sleep state 1 with the 14-event list (the unassociated 9 plus connection loss, disconnect, scan quota, keepalive wake and service wake), and state 3 with the 9-event list as before otherwise. The debug line now prints the state.
  • At resume after an associated sleep, the control ring is drained before the log line, so a link lost during the sleep reaches cfg80211 right away. The log line reads "Wi-Fi slept associated (WoWLAN): resume rc=…, association kept/disconnected".
Evidence

Tested tree: the J815 nightly 7.3.0-aurora-j815-dev (built in Docker, clang 19). Its N1 code is main at fdad0c5804d8 plus #3462, an RSSI-threshold (CQM) commit that is not posted, test-only switches and debug files, and this patch. This patch there differs from this head only in context: the CQM op next to it in wifi_ops, and #3462's AWDL suspend and resume calls. No centauri or Bluetooth words were on the command line.

One deep suspend with awdl0 up and WoWLAN not armed (2026-12-02):

PM: suspend entry (deep)
apple_centauri 0000:01:00.0: Alpha firmware host sleep (state=3 events=9 tlv280=86): ret=0 status=0 exec=2
apple_centauri 0000:01:00.0: Alpha ACIPC host sleep: ret=0 status=3 exec=2 ipc=2
Timekeeping suspended for 30.687 seconds
apple_centauri 0000:01:00.0: Alpha ACIPC host wake: ret=0 status=0 exec=2 ipc=2
apple_centauri 0000:01:00.0: Alpha firmware host awake (state=0 events=91 tlv280=92): ret=0 status=0 exec=2
PM: suspend exit
PASS regress: no N1 driver errors since the kit started
PASS regress: 0 failed units

…LAN)

A deep sleep refused to start while the station was associated, so
cfg80211 left the network first and the machine came back offline until
the supplicant joined again. The firmware runs on through the sleep, and
its host sleep request has a state that keeps the association: 1, where
3 is the unassociated sleep.

Advertise WoWLAN "any". When userspace arms it, the wiphy suspend keeps
the association for a deep sleep (on s2idle nothing services the link,
so it still leaves first, as without WoWLAN), and the device suspend
sends the associated sleep state. It also lets the connection's loss,
the disconnect, the scan quota and the keepalive and service wake
events through to the host. At resume the events that came during the
sleep are drained, so a link lost in the sleep is reported at once, and
the log says whether the association was kept.

No packet patterns, magic packet or disconnect triggers are advertised:
the firmware is not given any.

Signed-off-by: Nick <nekreshen@yandex.ru>

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge (draft — solid approach, a couple of locking/state-cleanup items before undrafting and running the armed WoWLAN row).

Reviewed 17379d1a45da across drivers/net/wireless/apple/centauri/centauri_wifi.c (wifi_suspend()/wifi_resume(), alpha_host_power_send(), centauri_wifi_suspend(), centauri_wifi_resume(), and alpha_resume_locked()):

  • Unlocked read of wifi->wowlan_armed in wifi_suspend() (centauri_wifi.c:3629–3630): return wowlan && !wifi->wowlan_armed ? 1 : 0; reads wifi->wowlan_armed after mutex_unlock(&wifi->lock). Capture bool armed = ...; wifi->wowlan_armed = armed; under the mutex and return wowlan && !armed ? 1 : 0; after unlocking.
  • Keep wifi->wowlan_armed bounded to the sleep cycle: wifi_suspend() sets wifi->wowlan_armed = true and currently only wifi_resume() clears it. Also clearing wifi->wowlan_armed = false in centauri_wifi_resume() and on the error path of centauri_wifi_suspend() (alongside wifi->wowlan_sleep = false) avoids leaving wowlan_armed stale if a suspend fails or aborts early.
  • Minor clarity nit: alpha_host_power_send() keys sleep state 1 and host_sleep_events_wowlan off wifi->connected. That matches wifi->wowlan_sleep today because centauri_wifi_suspend() rejects connected non-WoWLAN sleeps, though keying on wifi->wowlan_sleep makes the invariant self-documenting.
  • Checked clean: CEN_HOST_EVENTS_LEGACY (85) covers the 14-byte host_sleep_events_wowlan table without truncation, drain(wifi) is called under wifi->lock matching link_work, and alpha_resume_locked() already re-wakes the netif queue and reschedules link_work when wifi->connected.
  • Remaining before approval: fix the unlocked read above, undraft so CI runs on the final head, and add the exact-head armed WoWLAN (state=1) sleep/wake hardware row (including the post-wake association / disconnect path).

This branch has not been deployed

No deployments
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