Skip to content

nvme: apple: start a post-M4 ANS that a boot stage powered off - #1808

Draft
RyanTheTide wants to merge 2 commits into
mainfrom
nvme-apple/post-m4-start-from-off
Draft

RyanTheTide wants to merge 2 commits into
mainfrom
nvme-apple/post-m4-start-from-off

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Lets Linux start a post-M4 ANS (M4, M4 Pro/Max, T8140, T8142, T6050) that the previous boot stage idled and powered off. Until now it could only adopt a running session, so every stage before Linux had to hand ANS over live.

The contract

aura already does this between its own stages, and U-Boot reads the same property (aurora-silicon/u-boot#48): when a stage is done with a post-M4 ANS it shuts the controller down, idles the firmware, powers ANS and its PCIe block off, and writes the SART entries the firmware's buffers need on the ANS nvme node:

apple,sart-entries = /bits/ 64 <(index << 8 | flags) address size ...>;

What changes

  • soc: apple: sart: apple_sart_restore_entry() writes an entry back, reads it back and protects it like a boot loader's entry.
  • nvme: apple: when the probe finds ANS stopped (RUN clear) and the property present, the first reset work starts it from off:
    1. If the CPU isn't in its reset state (status bit 3) or the boot status still reads 0xde71ce55, the CPU was only stopped since it last ran, so ANS is reset through its PMGR reset first.
    2. The SART entries are written back.
    3. The firmware is started as after a power loss, with the warm path the T8140 sleep already uses (apple_rtkit_power_cycled_return()): no INIT, HELLO from the firmware, the endpoint map's last part masked to endpoint 0x20, no endpoint started again, IOP then AP power on.
    4. The controller is set up as on any start. A firmware that doesn't answer gets one more reset and start.

Without the property nothing changes: a running session is still adopted, and iBoot's session still gets its handshake. No boot stage writes the property for Linux yet (aura's boot= path still leaves ANS running), so this path stays unused until the stage before Linux powers ANS off.

Tested

  • arm64 defconfig + asahi.config with NVME_APPLE, APPLE_SART and WERROR, W=1: sart.o and apple.o build with no warnings. checkpatch --strict: nothing but the trailer form.
  • Not yet run on hardware. Next: a J616s (T6040) boot with an aura that powers ANS off for boot=, then the T8140 when it's available, and an M1 Pro/M2 regression boot (pre-M4 doesn't take this path).

RyanTheTide and others added 2 commits November 13, 2026 21:18
A boot stage that powers a post-M4 coprocessor off loses its SART
entries with the power, while the firmware keeps the buffers they
cover. The stage passes the entries on, and the next owner has to
write them back before the run bit.

Add apple_sart_restore_entry(). It writes one entry, reads it back, and
marks it protected like an entry the boot loader left, so Linux never
clears it and apple_sart_is_inherited_region() covers it.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
aura idles a post-M4 ANS when it is done with it, powers it and its
PCIe block off, and passes the SART entries on in apple,sart-entries
(three 64-bit cells per entry: index << 8 | flags, address, size).
U-Boot starts ANS from that state. Linux could only adopt a running
session, so every stage before it had to hand ANS over live.

When the probe finds ANS stopped and apple,sart-entries present, the
first reset work now starts it from off: reset ANS if its CPU isn't in
its reset state or its boot status survived the power cycle, write the
entries back, and start the firmware as after a power loss (no INIT,
the endpoint map's last part masked to endpoint 0x20, no endpoint
started again). The controller is then set up as on any start. A
firmware that doesn't answer gets one more reset and start.

Without the property nothing changes: a running session is adopted and
iBoot's session gets its handshake as before.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
m0d16l14n1 added a commit to m0d16l14n1/linux that referenced this pull request Nov 15, 2026
RyanTheTide: nvme: apple: start a post-M4 ANS that a boot stage powered off
m0d16l14n1 added a commit to m0d16l14n1/linux that referenced this pull request Nov 15, 2026
…merges

aurora-silicon#1941 brought a second copy of struct dcp_s2r_layout (this tree had it from
the J815 sleep work); aurora-silicon#1808 names nvme's sleep_traced, which this tree calls
sleep_coproc (with sleep_untested, from the aurora-silicon#1477 rework).

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Early note on this draft (no full review yet):

  1. drivers/nvme/host/apple.c:1721-1768: when the firmware doesn't answer, the loop resets and starts it a second time ("one more reset and start"). That is a retry over an unexplained failure. Find out why the first start can fail (for example, the CPU state check at :1724 missing a case) and make the first start deterministic, or fail the probe with the observed status so the cause is visible.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing for now: no boot stage powers ANS off before Linux yet, so this path can't run; it can come back with that stage and a hardware row.

@RyanTheTide RyanTheTide reopened this Nov 22, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Reopened and kept as a draft; the comment above lists what it still needs before review.

This branch has not been deployed

No deployments
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