Skip to content

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

Open
m0d16l14n1 wants to merge 5 commits into
aurora-silicon:mainfrom
m0d16l14n1:feat/centauri-wowlan
Open

m0d16l14n1 wants to merge 5 commits 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. On a board whose DT marks the N1 control function with wakeup-source, the driver advertises WoWLAN "any" (a host wake trigger in cfg80211). No board sets it yet: Wi-Fi cannot wake these Macs so far (see Not yet), so until a board does, nothing changes. Once it is advertised and 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. Three commits on main: the feature, the wakeup-source binding, and the gate.
Tested: at head 6d4e2d31d95d (merge of main f02bd68a08cb plus the wakeup-source gate): make ARCH=arm64 LLVM=1 W=1 drivers/net/wireless/apple/centauri/ builds with no warnings, run-host-tests.py --only centauri 22 of 22. No hardware row at this head yet; the rows below were taken at 17379d1a45da, which advertised WoWLAN without the DT gate, so they stand for a board with wakeup-source set. J815 (MacBook Air 15" M5), nightly13: main 59c55677a7a8 + this PR at 17379d1a45da + the other open J815 PRs. Armed (iw phy wowlan enable any): the firmware got the associated sleep (state=1 events=14), slept 39 s, resume returned 0 and the association was kept (same access point, gateway answers, 0 supplicant disconnects, NetworkManager never went to sleeping). Unarmed, the same boot: unassociated sleep (state=3 events=9), 29 s, rejoined after the wake. Awake, the firmware test wake event (0x20) arrives 5 s after the request. Scan 37 (2.4 GHz) + 21 (5 GHz) networks, link VHT80 NSS2, gateway ping 0 % loss. 0 N1 driver errors, 0 failed units, 0 new kernel errors vs the previous boot, 0 WARN/BUG/Oops. Earlier: 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). No board DT sets wakeup-source yet, so no Mac changes behaviour with this PR alone; on a board that sets it, 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: a wake started by the N1: with the test wake event set during an armed sleep the Mac did not wake (2 tries, 32 s and 3 s, both ended by a trackpad touch, wake source MTP.DOCK.CHANNELS.AP0.IRQ), so waking the host from Wi-Fi needs the platform wake path and is not part of this PR. That is why the board DTs do not set wakeup-source yet; a hardware row at this head with the property added by hand; other N1 boards; network managers other than NetworkManager.

Details
  • wiphy->wowlan advertises WIPHY_WOWLAN_ANY only, and only when the control function's node has wakeup-source (documented in apple,centauri.yaml). Without it the wiphy has no WoWLAN support and iw phy <phy> wowlan enable any is refused. 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).

@m0d16l14n1
m0d16l14n1 marked this pull request as ready for review December 4, 2026 02:08
@m0d16l14n1
m0d16l14n1 requested review from a team as code owners December 4, 2026 02:08
@github-actions github-actions Bot added blast:m5 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at 6d4e2d31: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no approved by aurora-silicon-review, but GitHub does not count it yet (code owner from Core, Omarchy Mac or Aurora Maintainers needed, or approval went stale)
Requested changes ok none
Hardware row at head ok comment at 6d4e2d31
Conflicts ok none
PR text ok Risk: two-way · N1 boards on the shared transport (J813, J815 and the other T8142/T8152 boards). No board DT sets wakeup-source yet, so no Mac changes behaviour with this PR alone; on a board that sets it, 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.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

Return the arming decision captured under the Wi-Fi lock. Clear the
arming bit on device resume and on either suspend refusal path.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Pushed 4265c100cffa on top of the existing branch. The cfg80211 callback returns the arming decision it read under the mutex. The device clears the flag on resume and on both suspend refusal paths.

On the merge tree with main be72f78e54d6, make ARCH=arm64 LLVM=1 W=1 drivers/net/wireless/apple/centauri/centauri_wifi.o built cleanly. python3 tools/asahi/run-host-tests.py --only centauri passed all 22 checks, and strict checkpatch passed on the fix. The armed and unarmed N1 hardware checks still need this head.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed changes-requested A reviewer requested changes (bot) labels Dec 4, 2026
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 4, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at 4265c100cffa8aef3e22e5b2e176588146b1a69f.

Failure: The wiphy accepts wowlan enable any even though Wi-Fi cannot wake this platform. include/net/cfg80211.h:5880–5884 defines WIPHY_WOWLAN_ANY as a host wake trigger. centauri_wifi.c:3604–3633 advertises and accepts it, and the PR's J815 test reports two attempts where the firmware wake event did not wake the host. Both sleeps ended with a trackpad touch. Expose that trigger only when the wake path works.

Checked: The supplied armed and unarmed rows demonstrate the association retention change. I also checked cfg80211's handling of the driver's fallback return and the PCI suspend/resume path.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@m0d16l14n1 This branch now conflicts with main (1da341136110) in:

  • drivers/net/wireless/apple/centauri/centauri_wifi.c

Could you forward-merge main into this branch (normal git merge, no rebase/force-push)? If you haven't had a chance within 24 hours, a maintainer can forward-merge main on top for you.

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

# Conflicts:
#	drivers/net/wireless/apple/centauri/centauri_wifi.c
A board whose N1 can wake the host from system sleep marks function
zero with the standard wakeup-source property. The native driver offers
WoWLAN only there.

Signed-off-by: Nick <nekreshen@yandex.ru>
WoWLAN "any" is a host wake trigger: the device keeps running and wakes
the host on activity. The association is kept through a deep sleep, but
no N1 board wakes the host from Wi-Fi yet: on the J815 the firmware's
test wake during an armed sleep did not wake the machine.

Advertise WoWLAN only when the control function's node has
wakeup-source, so cfg80211 accepts "wowlan enable any" only where the
wake path exists. Without it the wiphy has no WoWLAN support and a deep
sleep leaves the network first, as before.

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

Copy link
Copy Markdown
Contributor Author

Merged main (f02bd68a08cb) with a normal merge, no force push; head is now 6d4e2d31d95d. In the centauri_wifi_suspend() conflict I kept both sides: main's disconnect_pending refusal and the WoWLAN arming check.

For the review at 4265c100: WoWLAN "any" is now advertised only when the N1 control function's DT node has wakeup-source (added to apple,centauri.yaml). No board DT sets it, because Wi-Fi cannot wake these Macs yet. On every current board wowlan enable any is therefore refused, and a deep sleep leaves the network first, as before. A board turns it on with the property once its wake path works.

At this head: W=1 build of drivers/net/wireless/apple/centauri/ with no warnings, and run-host-tests.py --only centauri 22/22. The armed and unarmed rows still need this head, with the property added by hand.

@github-actions github-actions Bot removed merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 5, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 6d4e2d3

Checked: The control PCI function advertises WIPHY_WOWLAN_ANY only when its device node has wakeup-source. With the property absent the wiphy has no WoWLAN capability and nl80211 returns EOPNOTSUPP. The extracted registration and refusal checks pass under GCC and Clang. The revised Centauri schema passes dt-doc-validate and accepts compiled control nodes with and without the flag while rejecting an undeclared property. The PR adds the binding without enabling it on a board. The forward merge retains the pending-disconnect refusal and clears the armed state when suspend aborts.

@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Dec 5, 2026
@m0d16l14n1

Copy link
Copy Markdown
Contributor Author

Hardware: J815 (MacBook Air 15" M5) · tree containing head 6d4e2d31d95d unchanged, plus J815 integration patches (e4e1c593b995, kernel #11, boot 155e3365) · PASS, the unarmed path.

The J815 DT has no wakeup-source on the control function, so this is the "nothing changes" case:

  • iw phy lists no WoWLAN support.
  • Two deep sleeps (a timed wake after 23.2 s and a key wake after 315.4 s). Before each one the station left the network (locally generated deauth, reason 3). After each wake it was associated again within 3 s (VHT80, 5 GHz).
  • Regression: suspend_stats success 2, fail 0; 0 failed units; the only Wi-Fi kernel errors are the known of_irq_parse_pci -22 lines at probe; 1 new kernel error line in the run, isp_sys is on: 0x23ff from the sleep controller, not Wi-Fi.

Not covered: the armed path. No board sets wakeup-source yet.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 5, 2026

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

blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants