Skip to content

nvme: apple: restart a pre-M4 ANS that the previous stage left running - #23

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
fix/nvme-apple-recover-ans
Oct 30, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
fix/nvme-apple-recover-ans

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

After some reboots of the M1 Pro (T6000) and the M2 (T8112), U-Boot cannot bring the NVMe up, so the Mac cannot boot Linux. Retrying from the U-Boot prompt fails the same way.

Cause

aura Stage 1 hands the ANS over by asking it to sleep, stopping its CPU and resetting it. Since aura 1.0.0b1, the sleep request sometimes runs past its 1 s bound. The firmware finishes its GC bitmap rebuild and saves its context first, which takes 0.4 to 0.55 s on the M2 by its own log. When the request runs over, Stage 1 logs rtkit(nvme): IOP power transition timed out and resets the ANS with CPU_CTRL.RUN still set. The late answer may still be queued in the mailbox.

apple_nvme_boot() then sets RUN on a CPU that is already running and sends INIT. apple_rtkit_boot() requires HELLO as the first message, so it fails, and every later probe does the same. The aura side is fixed in aurora-silicon/aura (fix/ans-shutdown-handoff). This PR lets U-Boot recover with the Stage 1 that is already installed, which needs a 1TR visit to replace on these machines.

Change

This is the same recovery Linux's apple-nvme runs before it restarts the coprocessor:

  • If RUN is already set at probe, drop queued messages, clear RUN, wait 1 ms, drop anything that arrived meanwhile, then reset the block with its PMGR reset (resets in the DT).
  • If RUN is clear, still drop stale messages.
  • If the firmware still does not start (no HELLO, or no boot status), stop and reset once more and retry before giving up.
  • A clean handoff takes the same path as before.
  • Post-M4 (adopt/wake) is untouched.

Tests

  • test/py/tests/test_apple_nvme_restart.py runs on the host with --noconftest. It builds the driver's real apple_nvme_boot() against a model ANS that sends HELLO only after a fresh start and keeps its last message in the FIFO. It covers a clean handoff, a timed-out sleep with RUN set, a stale message, one failed start and a dead firmware. If the stop is removed from either path, the timed-out case fails.
  • Host build (aarch64-elf-gcc 16.2, the review-fix .config): clean, u-boot-nodtb.bin 701,720 B.
  • Not yet run on hardware. The Neo only exercises the unchanged post-M4 path. The real check is an M1 Pro or M2 reboot loop, and that test plan is with the lead.

🤖 Generated with Claude Code

After some reboots of the M1 Pro and the M2, U-Boot cannot bring the
NVMe up and the Mac cannot boot. The previous stage (aura Stage 1) asks
the ANS to sleep, stops its CPU and resets it. When the sleep request
times out, the CPU is left with RUN set and the reset lands under it,
possibly with the late answer still queued in the mailbox. U-Boot then
sets RUN on a CPU that is already running and asks for INIT, but the
first message is not HELLO, so apple_rtkit_boot() fails. Every later
probe does the same.

Finish the stop the previous stage could not, as Linux does before it
restarts the coprocessor: when RUN is already set, drop queued
messages, clear RUN, drop anything that arrived meanwhile and reset the
block through its PMGR reset. A stopped ANS still gets its stale
messages dropped. If the firmware does not start, do that once more and
try again before giving up. A clean handoff takes the same path as
before.

test/py: a host model of the ANS (HELLO only after a fresh start, a
FIFO that keeps what it last sent) covers a clean handoff, a timed out
sleep with RUN set, a stale message, one failed start and a dead
firmware. Dropping the stop from either path fails it.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RyanTheTide
RyanTheTide merged commit d70694a into aurora-wip Oct 30, 2026
2 checks passed
@RyanTheTide
RyanTheTide deleted the fix/nvme-apple-recover-ans branch October 30, 2026 12:25
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.

1 participant