Repository navigation
wifi: apple: centauri: restart a stopped N1 firmware without a reboot on J813 and J815 (carries #2711) - #3123
Conversation
On J813 the N1 firmware can stop while the machine is awake. A background scan sees the Alpha execution stage leave 2 and ends with -EIO, and every later command finds the command ring full. Nothing brought Wi-Fi back short of a reboot: PERST# alone, through the existing port cycle, leaves the firmware running. Restart the chip from the driver: - Release btcentauri and free the firmware's buffers. - Remove functions 1 and 2. The reset returns the chip to its single-function ROM personality, and a read through a stale function's BAR afterwards hangs the fabric. - Cycle the port with the N1's warm reset, given while the port is down. The chip comes back in stage 0. - Run the probe's boot steps, then attach the Beta function again. The warm reset comes from the root port's DT node, with the properties and parsing the T6050 boards already use (bindings/pci/apple,pcie.yaml): apple,function-warm-reset names the SMC and the key (the ADT's pci-bridge0 function-warm_reset), apple,warm-reset-writes the writes. A board restarts only when its root port has both and its port cycle is known; without them the driver never resets the chip. J813 gets them: key 'bpli', the same key and argument as the T6050 boards, with the T6050 writes. The Wi-Fi code reports the signs where it already sees them: the scan loop's and command_control()'s stage checks, a full command ring and a command timeout. A report queues a check 2 s later on an ordered, freezable workqueue, which restarts the chip only if the firmware is still stopped and the transport is not paused for a system sleep. At most three restarts in 30 minutes. There is no runtime switch; a board without the DT properties doesn't restart. debugfs rom_boot 4 restarts by hand, 5 and 6 test the fault path as a stopped firmware and as a fault that clears. The status file now reads under boot_lock, so no BAR read lands in a restart's port cycle. The driver now depends on MFD_MACSMC. Known limit, shared with the debugfs boot steps: removing function 0 under the PCI rescan lock (sysfs remove, host unbind) while a restart runs deadlocks. Signed-off-by: Kyle Arrington <[email protected]> Signed-off-by: Nick <[email protected]>
A PCIe root port names its endpoint's warm reset with "apple,function-warm-reset" (the SMC and the key) and "apple,warm-reset-writes" (each value and the wait after it). The T6050 host reads them in pcie-apple, and the N1 restart on T8142 needs the same: a second copy of the parser would drift from the first. Add apple_smc_warm_reset_parse(), apple_smc_warm_reset_put() and apple_smc_warm_reset() to the SMC driver, and use them in the T6050 host. The host's checks and messages are unchanged: at most four writes, no wait above 100 ms, a device link to the SMC for the noirq write, and no reset without both properties. Signed-off-by: Nick <[email protected]>
…led restart Review of the N1 restart: - The restart slept 2 s after the ROM boot and 2 s after the second port cycle. The ROM boot already returns once the image is loaded (stage 4), as the boot step does, and the boot steps run the port cycle right after it, so the first wait goes. After the port cycle the IPC start needs stage 1: poll for it, for at most 5 s, and fail with the stage it read otherwise. - The warm reset's result was dropped. centauri_port_cycle() now takes where to store it, brings the link up either way, and returns the link's result, so the restart can tell a refused reset (link up: try again) from a lost link (nothing more to do). - A failed restart left Wi-Fi down with no further attempt. With the link up, the worker tries again 10 s later, within the same limit of three restarts in 30 minutes. With the link down it says so and stops. - The warm reset is read with the SMC driver's parser, shared with the T6050 host, instead of a copy. Signed-off-by: Nick <[email protected]>
The J815 ADT gives pci-bridge0 the same function-warm_reset as J813 (SMC key bpli, argument 0x1000000), so the N1 driver can restart a stopped firmware here too instead of leaving Wi-Fi and Bluetooth down until a reboot. Without these properties centauri_recovery_request() returns early and debugfs rom_boot 4/5 do nothing on this board. Signed-off-by: Nick <[email protected]>
Function 2 (Bluetooth) appears with the IPC start's bus rescan, before Beta's firmware runs, so btcentauri cannot take it then. Only the restart path attached it afterwards; on a cold boot nothing in the kernel did and hci0 came up only when a userspace script reloaded btcentauri (51 s after boot on J815 boot feb7dfb0, against ~15 s for Wi-Fi). After the IPC start step and after a restart, wait up to 10 s for Beta's firmware (exec stage 2, IPC unowned: the state btcentauri checks), then attach the function. The restart path's immediate attach could race the same firmware start; it now uses the same helper. btcentauri's early probe was logged as two errors on every boot; the state is expected, so log it at info level and return -ENXIO, which the driver core does not report as a failed probe. Signed-off-by: Nick <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J815 (MacBook Air 15" M5) row at
The fixed sleeps are gone: firmware stop to post-reset stage 1 is now 1.7 s (232.928 to 234.628); the earlier run, with the two On |
Resolve the scan_worker conflict with aurora-silicon#3120's scan stop guards: a stopped transport asks for recovery only when the driver isn't stopping or paused and Alpha isn't at its run stage. Signed-off-by: Nick <[email protected]>
The scan worker now asks for a recovery when Alpha leaves its running stage (from main). The host model of the worker has no recovery path, so give it a counting stub and keep the scan tests building. Signed-off-by: Nick <[email protected]>
|
J815 (MacBook Air 15" M5) row at the new head Candidate:
Cold boot: Beta HCI registered at 14 s, kernel attach 1 ok, 0 failed. Wi-Fi: factory MAC (= DT), gateway ping ok; Bluetooth: factory address (= DT), scan ok. One deep sleep with no timer, woken by a key on the built-in keyboard after about 10 minutes (boot Regression on the same boot, after the wake: 0 SELinux denials (SELinux off), 0 failed units, 0 new kernel errors vs the previous boot, 0 WARN/BUG/Oops. |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 822a1dd7369c
Blockers: none
Checked: full diff across macsmc warm-reset helper, pcie-apple refactor, centauri recovery and port cycle paths, btcentauri probe behavior, DT bindings and board DTS, scan test stub, and live CI
Evidence
- Verified
apple_smc_warm_reset_parse/put/apple_smc_warm_resetextraction indrivers/mfd/macsmc.c(with clean error-pathput_devicecleanup and microsecond bounds checking) and matching refactor indrivers/pci/controller/pcie-apple.c. - Verified
centauri_recover()tears down function 2 (btcentauri), frees IPC buffers, removes functions 1 and 2 underpci_lock_rescan_remove(), cycles the port with the SMC warm reset, reboots from ROM, and re-attaches Beta viacentauri_attach_beta()on an ordered freezable workqueue (centauri_wq) with a 3-restarts-per-30-min circuit breaker and cleandisable_delayed_work_sync()teardown incentauri_remove(). - Verified
centauri_status_show()takesboot_lockto avoid BAR reads across link resets, andcrash_fileis created once to avoid debugfs lock inversion underboot_lock. - Live CI green (26/26 checks passed, 0 pending, 0 failed) with exact-head J815 hardware verification recorded on the PR.
|
J813 (MacBook Air 13" M5) row at
Not tested: a natural firmware stop on this head. Assisted-by: LLM (Claude:Opus 5.5) |
|
PASS on a 14-inch MacBook Pro (J714s, M5 Pro/T6050, G17S B1), kernel Candidate The merged heads were #2906 Wi-Fi was connected and Bluetooth The sleep check used deep The command line matched the default. SELinux was disabled. |
What: restart a stopped N1 firmware (Wi-Fi + Bluetooth) from the driver instead of leaving both down until a reboot, on J813 and J815. This carries #2711 (Kyle's commit unchanged; he handed the branch over) plus the fixes from Ryan's review of it, the J815 warm-reset DT, and a Bluetooth attach once Beta's firmware runs, which also fixes Bluetooth coming up late on a cold boot.
Tested: J815 (MacBook Air 15" M5) at
822a1dd7369c(this head:maina60fef7 merged in, plus the centauri-scan host-test stub), in the batched candidatem0d16l14n1/linuxj815/prtest-r7d70fd05 (maina60fef7 + the open T8142 sleep, N1 and J815 PR heads, unchanged): PASS.rom_boot 5(stopped firmware): restarted, Wi-Fi back and Bluetooth powered in 18 s, 0 HCI timeouts; stop to post-reset stage 1 in 1.7 s (191.207 to 192.931; 5.8 s with the old fixed sleeps). Cold boot: Beta HCI registered at 14 s by the kernel attach (1 ok, 0 failed). Wi-Fi (up 5 s after the wake) and Bluetooth (LE mouse still connected) back after a 604 s deep sleep woken by a key. Regression: 0 SELinux denials (SELinux off), 0 failed units, 0 new kernel errors, 0 WARN/BUG/Oops. The previous head227c89b69b65had the same results onj815/prtest-r4/-r6.Risk: two-way door. J813 and J815 restart only when the firmware has stopped (at most 3 restarts in 30 min). The T6050 host's warm reset now goes through the shared SMC parser; same checks, same writes, no T6050 row yet.
Not yet: a J813 row at this head; a T6050 row for the shared parser (
mfd: macsmccommit); a natural (not injected) firmware stop on J815.Details
Commits:
wifi: apple: centauri: restart a stopped N1 firmware without a reboot: wifi: apple: centauri: restart a stopped N1 firmware without a reboot #2711 atcebbad40, unchanged (Kyle Arrington).mfd: macsmc: Parse and give a PCIe endpoint's warm reset: one parser forapple,function-warm-reset/apple,warm-reset-writes, used by the T6050 host in pcie-apple and by the N1 driver, instead of the copy wifi: apple: centauri: restart a stopped N1 firmware without a reboot #2711 added (review point 3).wifi: apple: centauri: wait for the restart's stages, and retry a failed restart:msleep(2000)are gone (review point 1). The ROM boot already returns at stage 4, and the boot steps run the port cycle straight after it. After the port cycle the restart polls for stage 1, for at most 5 s. On the earlier J815 run, stage 1 was already there when the port came up (285.685), and the old code then slept until287.715;centauri_port_cycle()returns the link's result and stores the warm reset's separately, so a refused reset (link up) is retried 10 s later within the same 3-in-30-min limit, and a lost link is reported and left alone (review point 2).arm64: dts: apple: t8142-j815: Describe the N1 warm reset, as on J813: the J815 ADT'spci-bridge0function-warm_resetnames the same SMC key (bpli) and argument as J813; same writes as J813's node.wifi: apple: centauri: attach Bluetooth once Beta's firmware runs: function 2 appears with the IPC start's rescan before Beta's firmware runs, so btcentauri refused it and nothing in the kernel tried again. After the IPC start and after a restart, the driver now waits (20 ms poll, 10 s at most) for Beta's exec stage 2 with the IPC unowned, then attaches the function. btcentauri's early probe is logged at info level and returns-ENXIO.Ryan's review: #2711 (comment) (points 1-3 above). #2711 can be closed in favour of this PR once it is reviewed.
Evidence
At
227c89b69b65(boot65e8a168),rom_boot 5:Cold boot, same head:
Beta HCI registered at 15 s; kernel attach: 1 ok, 0 failed.Earlier run, before the review fixes:
Earlier J815 run (
main2943fff + the J815 PRs, #2711 atcebbad40+ commits 4 and 5, boot ab3dfc4a),rom_boot 5:Cold boot, same run:
Beta HCI registered at 14 s; kernel attach: 1 ok, 0 failed.