Skip to content

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

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

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

Conversation

@gig3m

@gig3m gig3m commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

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)

@RyanTheTide

Copy link
Copy Markdown
Contributor

The recovery itself looks careful. btcentauri is released first, functions 1 and 2 are removed before the reset (avoiding the stale-BAR fabric hang), the warm reset is given with the port down, the check runs 2 s later on a freezable workqueue and skips a paused transport, and it is capped at three restarts per 30 minutes. Two points before it leaves draft:

  • recovery (module parameter, default on) is a runtime switch. Since the cap already bounds a misbehaving firmware, I'd drop the parameter and keep the debugfs rom_boot entries for testing.
  • board->warm_reset is a per-board flag ("J813 only so far"). The thing that makes a board eligible is the ADT's pci-bridge0 function-warm_reset (bpli) being present and checked. If the boot loader passes that into the DT (or the driver reads it where it already reads the ADT-derived board data), every board that has it gets the restart once its reset is checked, without a table entry. Since the same key and argument are on the T6050 boards, a J714s row would show whether they can opt in.

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.

Assisted-by: LLM
Signed-off-by: Kyle Arrington <kyle@arrington.co>
@gig3m
gig3m force-pushed the centauri-t8142-recover branch from 8ab4ee3 to cfcac75 Compare November 21, 2026 13:57
@gig3m

gig3m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Both done in cfcac75a.

recovery= is gone. The debugfs rom_boot entries stay for testing. The commit message now says there's no runtime switch.

The board flag is gone too. A binding for this already existed: the T6050 boards describe the N1's warm reset on the root port, with apple,function-warm-reset (the SMC, key, argument) and apple,warm-reset-writes (pci/apple,pcie.yaml, read by pcie-apple and centauri/t6050). The T8142 driver now reads the same two properties from the root port above function 0, with the same parsing and limits. It restarts only when both are present and its port cycle knows the board, so a board that adds the properties without a port row can't tear the functions down first. J813's pci@0,0 gets them: <&smc 0x62706c69 0x1000000>, which is its ADT's function-warm_reset (the same key and argument as the J714s), and the J714s writes.

Two things I couldn't settle on my own:

  • J813's pcie0 is pci-host-ecam-generic, so apple,pcie.yaml doesn't cover that node and dtbs_check doesn't validate the properties there. A 200 ms wait passed unflagged. For now the N1 binding (net/wireless/apple,centauri.yaml) has a paragraph pointing at them. If you'd rather have them in a schema that selects this port, say where.
  • The loader could publish apple,function-warm-reset from the ADT for every board, but the ADT has only the key and argument, not the writes. So the writes would still sit in the DTS, as t6050-j714s-sleep-soc.dtsi has them today. Should aura publish the half it can?

J714s: this restart is in the T8142 driver, which doesn't bind on T6050 (its probe rejects a apple,t6050-pcie parent). The J714s's N1 runs centauri/t6050, which already reads these properties for its sleep path. So a J714s row wouldn't exercise this code, and opting T6050 in would be a change to that driver.

Tested on J813, with the same module both times:

  • With the properties in the DTB:
    • A fault that clears (rom_boot 6) gives "firmware fault cleared; no restart".
    • A stopped firmware (5) restarts in about 11 s: "warm reset through the SMC: 0", then stage 0 after the reset, then "restarted; Bluetooth function attach: 1".
    • Wi-Fi reassociated 20 s after the fault (3/3 pings), and Bluetooth stayed powered.
  • Behind a DTB without them: 5 is ignored with nothing logged, rom_boot 4 returns -EOPNOTSUPP, and Wi-Fi stays up.

Assisted-by: LLM (Claude:Opus 5.5)

@gig3m

gig3m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Replaced by #2711: the same change on a fresh branch, with only the human Signed-off-by in the commit. Closing this one.

Assisted-by: LLM (Claude:Opus 5.5)

@gig3m gig3m closed this Nov 21, 2026
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