Skip to content

wifi: apple: centauri: restart a stopped N1 firmware without a reboot - #2711

Draft
gig3m wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
gig3m:centauri-t8142-recover-v3
Draft

gig3m wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
gig3m:centauri-t8142-recover-v3

Conversation

@gig3m

@gig3m gig3m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Replaces #2648: the same commit (cfcac75a's tree), without the Assisted-by commit trailer.

On my J813 (MacBook Air 13" M5, macOS 27.2 stub) the N1 firmware stopped twice while the machine was awake, about five hours after boot each time (11-19 and 11-20). A background scan ends rc=-5 partway through (12 and 13 of 38 channels), wpa_supplicant disconnects in the same second, and from then on every command returns -ENOSPC because the firmware no longer drains the command ring. The firmware writes nothing to its cras region. Until now only a reboot brought Wi-Fi back.

This lets the driver restart the chip itself.

The restart

  • btcentauri is released and the firmware's buffers are freed.
  • Functions 1 and 2 are removed. After the reset the chip is back in its single-function ROM personality, and a read through a stale function's BAR hangs the fabric: on my J813 the Mac hard-reset with nothing logged.
  • The port cycle runs with the N1's warm reset, given while the port is down. PERST# alone leaves the firmware running in stage 2; after the warm reset it reads stage 0.
  • Then the probe's boot steps, and the Beta function is attached again.

Which boards

  • The warm reset comes from the root port's DT node, with the properties the T6050 boards already use (pci/apple,pcie.yaml, read the same way as pcie-apple does): apple,function-warm-reset names the SMC and the key (the ADT's pci-bridge0 function-warm_reset), and apple,warm-reset-writes gives the writes.
  • A board restarts only when its root port has both and the driver knows its port. Without them the driver never resets the chip.
  • J813's DTS gets them: <&smc 0x62706c69 0x1000000> (its ADT's function-warm_reset, the same key and argument as the J714s) and the J714s writes. The N1 binding notes them.

When it runs

  • The Wi-Fi code reports the signs where it already sees them: the scan loop's and command_control()'s Alpha-stage checks, a full command ring, and a command timeout.
  • A report queues a check 2 s later on an ordered, freezable workqueue. It restarts only if the firmware is still stopped and the transport isn't paused for a system sleep.
  • At most three restarts in 30 minutes. There's no runtime switch.
  • debugfs rom_boot 4 restarts by hand; 5 and 6 test the path as a stopped firmware and as a fault that clears.

Also: status now reads under boot_lock, so no BAR read lands in a restart's port cycle, and APPLE_CENTAURI now depends on MFD_MACSMC.

Tested on J813

  • With the properties in the DTB, a spurious fault (6) is ignored: "firmware fault cleared; no restart".
  • A stopped firmware (5) restarts the chip in about 9 s; Wi-Fi reassociates about 20 s after the fault and Bluetooth comes back (Bluetooth function attach: 1).
  • The fourth stop within 30 minutes is refused.
  • Behind a DTB without the properties, 5 is ignored with nothing logged and 4 returns -EOPNOTSUPP.
  • Reading firmware_crash and status throughout a restart doesn't hang.
  • Normal boot with the change, and a 30 s deep sleep after a restart (Wi-Fi 3/3 pings, Bluetooth up after the wake).
  • Not yet: a firmware that stopped by itself going through the automatic path. Before the detection was in, the same restart sequence brought Wi-Fi back on a running chip three times.

Known limit: removing function 0 under the PCI rescan lock (sysfs remove, host unbind) while a restart runs deadlocks: remove waits for the restart, which waits for the rescan lock. The debugfs boot steps already have the same shape.

Builds clean with W=1 on integration/aurora (5b596e6e377a). dt_binding_check passes for the N1 binding. On J813, dtbs_check reports only an alias warning that was already there. It doesn't validate the new properties, because J813's pcie0 is pci-host-ecam-generic.

Assisted-by: LLM (Claude:Opus 5.5)

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 <kyle@arrington.co>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Nice work. Keying the restart on the root port's warm-reset properties, so a board without them never resets the chip, is the right shape. Points from a read of the head:

  1. Fixed 2 s waits in centauri_recover(). The two msleep(2000) (after the ROM boot and after the second port cycle) are guesses at how long the chip takes. Polling the execution stage at BAR+0x8000 with a bound (readl_poll_timeout, as the debugfs path already checks for stage 4 before its port cycle) would wait as long as each chip needs, and fail clearly when it doesn't get there.

  2. A failed restart leaves Wi-Fi down with no further attempt. warm_reset()'s result is dropped in centauri_port_cycle(). Once centauri_free_boot() has run, c->ipc is NULL, so the worker returns early on every later request. Any failure after the teardown (SMC write, stage != 0, ROM boot) means silence until the driver is reloaded. Two suggestions: check that the SMC device and its drvdata are there before tearing anything down, and pass warm_reset()'s error back so the log names the step that failed.

  3. The parser duplicates pcie-apple's. warm_reset_parse() copies the reading of apple,function-warm-reset / apple,warm-reset-writes from pcie-apple.c. A shared helper (or one exported from pcie-apple) would keep the two readers from drifting if the binding changes.

  4. Known limit (remove under the rescan lock vs. the worker): fine as documented for a draft, but worth fixing before this leaves experimental. Removing the device from sysfs during a restart is a plausible user action.

Rows: the automatic path on a firmware that stopped by itself (as you list). Also one J714s/J716c boot, since their root ports already carry both properties. Even if centauri doesn't bind there, it shows nothing new runs.

Assisted-by: LLM (Claude:Opus 5.5)

@gig3m

gig3m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

I'm stepping back from this one. The branch stays up and maintainer edits are enabled, so take it, rework it, or close it as you see fit. The code is GPL-2.0 under my Signed-off-by; use it however helps.

Assisted-by: LLM (Claude:Opus 5.5)

@gig3m

gig3m commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Natural-hang row, for whoever picks this up: the firmware stopped on its own on my J813, and the automatic path restarted it.

Setup. The recovery code is the same as this head (cebbad40), on my daily kernel: integration/aurora abc61919 plus local J813 sleep patches, with the DT properties in the DTB. The command line is not the default: it has the sleep test parameters, including apple_centauri.alpha_sleep_untested=1.

What happened (2026-11-21, 10 h 31 min after boot, machine awake):

18:35:38 Wi-Fi scan finished: rc=-5 channels=6 of 38 beacons=96
18:35:38 firmware fault (scan: Alpha stage); checking again in 2 s
18:35:38 wpa_supplicant: CTRL-EVENT-DISCONNECTED reason=1
18:35:40 firmware stopped; restarting the N1
18:35:40 recovery: stage 0x2, releasing the firmware's buffers
18:35:41 warm reset through the SMC: 0
18:35:41 recovery: stage 0x0 after the warm reset
18:35:47 Alpha Wi-Fi firmware running; IPC handshake complete
18:35:49 restarted; Bluetooth function attach: 1
18:36:00 wpa_supplicant: CTRL-EVENT-CONNECTED, DHCP lease
  • The scan failed the same way as the two hangs in the description, and the check 2 s later restarted the chip.
  • Wi-Fi had an address again 22 s after the fault, and Bluetooth came back with it.
  • One restart, no refusals, and no fault in the 13 hours after it, which included a 10-hour lid-closed deep sleep. Wi-Fi and Bluetooth worked after the wake.

Not clean: about 5 minutes of access-point hopping after the restart.

  • Until 18:41:19, wpa_supplicant kept trying to go back to the access point it had been on before the fault.
  • Each try ended with Association request to the driver failed and the firmware rejecting command 0x20000 (firmware_status=333). wpa_supplicant then joined another access point of the same network.
  • That happened 6 times, each with a gap of a few seconds. At 18:41:19 it got back onto the original access point and stayed there.
  • Before the fault, that boot had connected once and never moved.
  • I haven't shown the cause. One guess: the original access point kept the old association, which ended without a deauth, until its idle timeout, about 5 minutes after the fault.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Still needed: nothing on integration/aurora at daa9e2d restarts a stopped N1 firmware on T8142, and cebbad4 merges onto that tip without conflicts. The author has handed the branch over, so it needs someone to carry it. Open from the review: the two fixed 2 s waits in centauri_recover() (poll the execution stage with a bound), a failed restart that leaves Wi-Fi down with no further attempt and drops the warm reset's result, and the warm-reset property parser copied from pcie-apple. The natural-hang row on a J813 (Wi-Fi back 22 s after the fault) was taken with sleep test parameters on the command line; a row on the default command line is still needed. #2191 adds a similar self-recovery to the T6050 N1 driver, so the fault detection is worth sharing between the two.

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