Repository navigation
wifi: apple: centauri: t6050: keep N1 firmware, Bluetooth, and Wi-Fi alive across deep sleep - #2718
Conversation
|
Strong result. Taking away the cold N1 boot on every wake, with the warm-reset path kept as the fallback, is the right design, and the per-pass table is clear. An adversarial read of aebdeba:
Rows besides (1): one deep sleep with Wi-Fi associated and an Assisted-by: LLM (Claude:Opus 5.5) |
…ve sleep apple_pcie_t6050_sleep_up() unconditionally ran the endpoint SMC warm reset (bpli) before training the link on every wake. When the N1 endpoint keeps its firmware alive across firmware sleep via ACIPC host-sleep, issuing bpli on wake destroys the live firmware and forces a cold ROM re-boot. Keep the wake warm reset enabled by default for every state the endpoint driver does not explicitly claim (unbound, probe failed, teardown sleep, or suspend not reached), and export apple_pcie_t6050_sleep_keep_alive() so an endpoint driver that successfully entered firmware host-sleep can opt out of the wake warm reset for that sleep cycle. The flag is cleared on the next PM_SUSPEND_PREPARE and by apple_pcie_t6050_sleep_reset(). Signed-off-by: Diljit Singh <hey@djdev.me>
… deep sleep On T6050 Macs, macOS keeps the N1 radio powered and running firmware across deep sleep, preserving PCI functions 0..2, Bluetooth, and Wi-Fi association (median 0.44 s wake-to-gateway reply across 14 sleeps on J714s), and reserves the SMC bpli warm reset for crash recovery. Previously, apple_centauri_t6050 and btcentauri_t6050 tore down Wi-Fi, Bluetooth, and IPC on every firmware sleep and replayed bpli before and after sleep, forcing PCI removal, rescan, ROM firmware boot, and full Wi-Fi re-association on every wake. Match macOS's healthy sleep path so the N1 firmware, Bluetooth, and STA association survive deep sleep (without claiming magic-packet or disconnect host-wake triggers that are not yet programmed into firmware; J714s macsmc currently takes wifibt-only wakes as dark wakes): - Run the ACIPC host-sleep handshake on Beta (BAR0 + 0x1078), Alpha (firmware command 6 host-power sleep + BAR0 + 0x1024), and Control (BAR0 + 0x9078), polling each function's peripheral_info sleep_status at context + 0x70 to 3 on suspend and <= 1 on wake. - Pause TX/RX ring producers and drain in-flight Alpha data TX within a 100 ms bound before entering host sleep; if TX descriptors are still in flight at the deadline, return -EBUSY so suspend falls back to the existing DMA-fenced warm-reset teardown rather than sleeping with DMA in flight. - Save PCI config state and live firmware PCI IDs on Control/Alpha (fn 0 switches in-place from ROM 0x1900 to firmware 0x1901 after boot, and fn 1's empty dev_pm_domain skips PCI core save/restore), opt out of the pcie-apple wake warm reset via apple_pcie_t6050_sleep_keep_alive(), place fn 0..2 into D3hot with PME_En before PME_Turn_Off, and verify each function against its pre-sleep/probed PCI ID while restoring config, MSI vectors, bus mastering, and memswap registers on resume. - Advertise only WIPHY_WOWLAN_ANY and check wowlan->any in wifi_suspend() so cfg80211 can keep the STA association across suspend when generic WoWLAN is armed (host-power state 1 when associated, state 3 LPNA when disconnected), without advertising unbacked magic-packet or disconnect wake triggers to userspace. - Preserve the existing teardown + bpli warm-reset + re-enumeration path strictly as automatic fault recovery if any function fails sleep/wake or firmware traps. - Update the Centauri Wi-Fi, Bluetooth, and recovery host tests to cover WoWLAN trigger checks and ACIPC keep-alive suspend/fallback paths. Signed-off-by: Diljit Singh <hey@djdev.me>
aebdeba to
b8fce26
Compare
|
Addressed all four points in
Re-verified on MacBook Pro M5 Pro (J714s, T6050)
Host verification on |
|
Checked 261a2e0 + b8fce26. All four points are fixed:
No remaining concerns from my side at b8fce26. On selection: nothing new keys on the SoC, board or firmware version. The keep-alive runs when the N1 functions bind by PCI ID (106b:1900/1901/1903) and the host port is the one whose DT carries the warm-reset properties ( Assisted-by: LLM (Claude:Opus 5.5) |
|
A correction to the selection note in my last comment. I wrote that the keep-alive is keyed on "the host port whose DT carries the warm-reset properties". That is not quite right. Assisted-by: LLM (Claude:Opus 5.5) |
|
DjDeveloperr, a K116s (16-inch M5 Pro, firmware 27.2) resets when it enters deep sleep with Wi-Fi still associated on a kernel that has this change. With Wi-Fi taken down before the entry it sleeps and wakes as before. Kernel:
On both resets the panel stayed dark past the alarm and the machine then restarted by itself, the first time about two minutes after the entry. Nothing reached the journal after the entry and pstore is empty; I had no serial capture attached, so I can't say whether it died going down or coming up. The same raw Bluetooth is off on this machine. #2191's commits needed two test fixture conflicts resolved against this change; its driver hunks applied cleanly. I can run a build of your choosing on the K116s (with a serial capture next time) if you have a patch or want specific lines logged. |
Summary
On T6050 Macs, macOS keeps the N1 radio powered and running firmware across deep sleep, preserving PCI functions 0..2, Bluetooth, and Wi-Fi association (measured median 0.44 s wake-to-gateway reply across 14 deep sleeps on J714s, 0 dropped ping sequences), and reserves the SMC
bpliwarm reset for crash recovery.Previously,
apple_centauri_t6050,btcentauri_t6050, andpcie-appletore down Wi-Fi, Bluetooth, and IPC and replayedbplibefore and after every firmware sleep, forcing PCI removal, bus rescan, ROM cold boot (~3.3 s), and full Wi-Fi reassociation on every wake.This 2-commit series matches macOS's healthy sleep/wake path with no runtime switches or board gates, keeping N1 firmware, Bluetooth, and STA association alive across deep sleep (without claiming magic-packet or disconnect host-wake triggers that are not yet programmed into firmware; J714s
macsmccurrently takeswifibt-only wakes as dark wakes):PCI: apple: T6050: allow endpoint to skip wake warm reset on keep-alive sleep(261a2e063cc5).suspendnot reached).apple_pcie_t6050_sleep_keep_alive()so an endpoint driver that entered firmware host-sleep can opt out of the wake warm reset for that sleep cycle (cleared at the nextPM_SUSPEND_PREPAREand byapple_pcie_t6050_sleep_reset()).wifi: apple: centauri: t6050: keep N1 firmware and Wi-Fi alive across deep sleep(b8fce260d6be)BAR0 + 0x1078), Alpha (firmware command 6 host-power sleep +BAR0 + 0x1024), and Control (BAR0 + 0x9078), polling each function'speripheral_infosleep status (context + 0x70) to3on suspend and<= 1on wake.-EBUSYso suspend falls back to DMA-fenced warm-reset teardown rather than sleeping with DMA in flight.0x1900to firmware0x1901after boot; fn 1's emptydev_pm_domainskips PCI core save/restore), callapple_pcie_t6050_sleep_keep_alive(), place fn 0..2 into D3hot withPME_EnbeforePME_Turn_Off, and verify each function against its pre-sleep/probed PCI ID while restoring config, MSI vectors, bus mastering, and memswap registers on resume.WIPHY_WOWLAN_ANYand checkwowlan->anyinwifi_suspend()socfg80211keeps the STA association across suspend when generic WoWLAN is armed (host-power state 1 when associated, state 3 LPNA when disconnected), without advertising unbacked magic-packet or disconnect triggers.bpliwarm-reset + re-enumeration path as automatic fault recovery if any function fails sleep/wake or firmware traps.tools/asahi/centauri-{wifi-pm,bt-arena,recovery}-tests.pyto cover WoWLAN trigger gating and ACIPC keep-alive suspend/fallback paths.Testing
Host verification (
261a2e063cc5+b8fce260d6be)scripts/checkpatch.pl --strict --no-tree: 0 errors, 0 warnings, 0 checks on both commits.pcie-apple.o,btcentauri_t6050.o,centauri_ipc.o,centauri_pci.o, andcentauri_wifi.o.tools/asahi/centauri-wifi-pm-tests.py --negative-controls: PASS (production + 8 negative controls, includingwowlan-ignores-trigger)tools/asahi/centauri-bt-arena-tests.py --negative-controls: PASS (production + probe + 5 negative controls)tools/asahi/centauri-recovery-tests.py --negative-controls: PASS (baseline + ownership + remove-interleaving + 7 negative controls)tools/asahi/centauri-physical-recovery-tests.py: PASStools/asahi/radio-{pm,sleep-fence,sleep-power,sleep-snapshot}-tests.py: PASSHardware verification on MacBook Pro M5 Pro (J714s, T6050)
7.3.0-m5-n1k6(integration/aurora a84637dca209+ this PR headb8fce260d6be), default cmdline, SEP writes on, 5 × real deep sleeps (30 s PMU RTC alarm).iw phy phy0 wowlan enable magic-packetanddisconnectboth rejected (-EINVAL);iw phy phy0 wowlan enable anyaccepted.01:00.0/1/2, and Bluetooth (Powered: yes) alive with 0 PCI remove/rescan, 0bpliwarm resets, and 0 spuriouswifibtwakes (MBSW 00 00 00 00 00 00 00 00on all 5 sleeps);pcie-appleport 0 link up in 116–119 ms on keep-alive wakes and 282 ms (with defaultbpliwarm reset) whenapple_centauri_t6050was unbound.10.0.0.1):exit_to_devexit_to_discexit_to_conseq_gapwow=any,mem---exit+0.13 s(seq 32->33, 3.97 ms RTT)iwevent, BTPowered: yeswow=any,mem---exit+0.16 s(seq 32->33, 3.77 ms RTT)iwevent, BTPowered: yeswow=any,mem+ 138.35 Mbps UDP TX stream (198,096 tx pkts / 285.5 MB into suspend)---exit-0.05 s(seq 34->36)iwevent, BTPowered: yeswow=off,logind--(pre-sleep)exit+5.10 sbpli), BTPowered: yesapple_centauri_t6050unbound,mem---pcie-applewake warm reset ran cleanly (status 0x9b001001,01:00.0 [106b:1900]visible)4.7 sfrom device probe (scans=0).centauri/btcentauriwarnings or errors.Assisted-by: LLM (Claude:Opus 5.5)