Repository navigation
nvme: T8132: keep NVMe across warm reboots on the M4 MacBook Air - #305
Conversation
|
@RyanTheTide @DjDeveloperr FYI m4's installed from the current installer crash sometimes on wakeup/soft reboot without this |
|
Review note on
This also fixes #267 (J614c, 8 TB, RUN=0 cold start with no HELLO). The reporter's 3/3 cycles and the installed boot are in #275. |
|
Thanks for the 9-reboot run. Two small things besides the chip-list question already on this PR:
|
On J614c (T6041) the ANS firmware answers neither an RTKit power transition (rtkit_quiesce times out with "IOP power transition timed out") nor a start after power-off (no HELLO, ASC CPU running, pmgr domains on), so every handoff since adf5580 leaves Stage 2 without NVMe. A session left running with the controller enabled is adopted by the next nvme_init(), as T6050 already does: hand it on with RTKit untouched and only the I/O queue registers cleared, and let T6040/T6041 take the T6050 adopt path. Tested on J614c from the proxy, read-only: init from the iBoot session, read LBA 0, hand on, adopt, read again, 3/3 cycles with identical data; and a Stage 2 built with this change, chainloaded raw, booted through to the installed system. [erikwb: rebased onto main; the adopt condition, which main now spells nvme_ans_storage_gated(), resolves as nvme_ans_storage_gated() || nvme_post_m4_keeps_live(), so T6050 and T8142 are unchanged] Signed-off-by: Erik Bourget <erik@ebourget.net>
On the M4 MacBook Air (J713, T8132), Stage 1 powers ANS off after loading Stage 2 and Stage 2 starts it again from off. After a warm reboot that cold start intermittently gets nowhere, and Stage 2 is left without NVMe until a forced restart. Give T8132 the T6040/T6041 handling: Stage 1 hands its ANS session on running, with only the I/O queue registers cleared, and Stage 2 adopts it instead of starting ANS from off. A stage that asks for a quiesced ANS (nvme_quiesce_for_next) still gets one, on every chip that hands on live. Tested on a J713 with Stage 1 and Stage 2 built from this change on 1.0.0b13.1: every boot logs "handing the live ANS session on" in Stage 1 and "adopting the live post-M4 ANS session" in Stage 2, with no cold start. Linux takes the controller over as before, nvme0n1 and all partitions are present, and nine consecutive warm reboots came up the same way. Signed-off-by: Erik Bourget <erik@ebourget.net>
2b21d67 to
4935120
Compare
|
Thanks. Pushed: the rebased #275 commit now has a rebase note and my Signed-off-by, and the branch is on current main (format-check was failing on main's own s2r file). Let's land this one; #275 can close once it merges, as you suggested there. On the chip list, I kept it and added a comment on why it stops: T8152 keeps its quiesce path because its Linux driver neither adopts a live session nor restarts a stopped ANS, and T8140 keeps the power-off path, which works there, while live adoption by the next stage is untested. If your A18 Pro row shows T8140 survives a live handoff and adoption, I'll add it. An M4 Pro (T6040) warm-reboot row would also help, since only T6041 and T8132 have been run. |
|
A data point from a J773g for the warm-reboot NVMe failure this PR addresses: Stage 1's own log of it (the ANS firmware asserts during Stage 1's idle), and where in the code it comes from. Written by an AI agent from the owner's captures; the owner ran the hardware steps. Machine
What happensOn some warm reboots the ANS firmware crashes while Stage 1 idles it before the chainload. Stage 1 stops it, powers it off and hands Stage 2 the SART entries as usual. Stage 2 gets no HELLO and parks in the proxy. A reset of the SoC recovers it. Stage 1, firmware assert (6 captures; N was 3, 8, 8, 8, 21 and 24): The crash is reported 12 to 137 ms after Stage 2 after it (all 6, and one more failure whose Stage 1 log was not captured): Stage 1, timeout variant (1 capture, after Stage 2 after it: NumbersWarm reboots only, one machine. "Plain" means Stage 1 wrote nothing to NVMe. "Trial" means a boot through
This supports the missing shutdown as the cause. It does not prove it:
WhereLines on main.
Proposed fix (untested)Send the NVMe normal shutdown before the idle on the chainload path whether or not the stage wrote, as line 473 already does for T8142. Separately, an unacknowledged idle should not be handed on as "off, start warm". We have not run this. Stage 1 on this unit can only be replaced from Recovery with someone at the machine. This PR would take T8132 off this path by handing ANS on live. This report may still matter for T8140 and for any stage that powers ANS off. #266 saw the same What we can provide
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks. Ryan's points are settled. The rebased #275 commit has its note and your sign-off, and the comment above nvme_post_m4_keeps_live() (src/nvme.c:455-462) says why T8152 and T8140 stay off the list. That's the reason Ryan asked for, so the list is fine as it stands.
I read the live hand-on in nvme_shutdown(). It runs only when no later stage asked for a quiesced ANS (nvme_quiesce_for_next), it clears only the I/O queue registers, and the next nvme_init() adopts a session only if it reads BOOT_STATUS OK with no fatal status. techmore's J773g captures point the same way: every failure there is on the power-off path that this takes T8132 off.
CI is green on 4935120, and main hasn't touched src/nvme.c or the test since your base. Approving and merging. #275 can close once this is in, as you and Ryan agreed.
One note on the rows: main currently resets every T8132 at boot (#320's MCC check; the fix is #392). So a J713 or J773g warm-reboot row on main's Stage 2 has to wait for #392, and a failure before then isn't caused by this PR. After the merge, with a revert ready:
- the J713 warm-reboot loop on main plus #392;
- Ryan's M4 Pro (T6040) warm-reboot row, since only T6041 and T8132 have run, plus the A18 Pro check if T8140 should join the list.
|
Merged as a5ffc4d (CI green on 4935120, no base drift). Post-merge verification as in my review: the J713 warm-reboot loop on main plus #392 (main resets every T8132 at boot until #392 lands, so a failure before then isn't this PR), and Ryan's M4 Pro warm-reboot row. A revert is ready if it doesn't hold. #275 can close now, as agreed. |
The J713 console on aura#406 shows why the b14 candidate's chainload
reset the Mac. The Stage 2 ran normally, then crashed in its own PCIe
init. It had received nvme.sart= ("ANS is off") while ANS was still
live, so it called pcie_ans_power_on(), which on T8132 is a full
pcie_init(), and took a synchronous external abort. nvme_sart_entries()
reports any T8132 session as off, but nvme_shutdown() had handed that
session on live (T8132 is in nvme_post_m4_keeps_live(), since #305).
Ryan's one-boot probes settle the rest. Reporting the session as live
lets the Stage 2 adopt it, but then kboot's own T8132 pcie_init() (the
radio port) faults the same way. So on T8132 a live handoff to another
aura stage fails in the receiver whatever this stage reports. Dropping
T8132 from nvme_post_m4_keeps_live() (power off, pass nvme.sart=, as
every 1.0.0b13 stage does) passes into the configured Stage 2: root on
NVMe, 0 failed units, PMU counter 0.
The origin rule of the previous commit does not cover this: an
iBoot-loaded Stage 1 receives iBoot's live session and would still hand
it on live. So T8132 leaves nvme_post_m4_keeps_live(), on both sides: a
stage powers it off at the handoff, and a later stage doesn't adopt a
live T8132 session but stops it and starts it from off.
nvme_sart_entries() now also returns nothing for a session that
nvme_shutdown() handed on live, on any chip, so stale entries from an
earlier power-off never reach the next stage beside a live ANS.
T6040/T6041 keep their live handoff (the J616s row passed).
tests: the harness first, then the code. 23 and 26 (a T8132 iBoot
session) now power off and free the queues. 34 (a T8132 session handed
on live by a #305 stage) is cycled from off and goes on off. 35 (T6040,
adopted live, stale entries present) goes on live and reports no
entries. 23 failed before this change; 35 fails without the
nvme_sart_entries() change.
Signed-off-by: Diljit Singh <hey@djdev.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On T6040, T6041 and T8132 (nvme_post_m4_keeps_live()) a stage hands its ANS session on live at the chainload handoff, whatever its origin. That covers iBoot's session, which this stage gave its one RTKit handshake, and a live session an earlier stage handed on, which it adopted. aurora-silicon#305 tested both. It also covers a session this stage started from off, because the earlier stage had powered ANS off and passed its SART entries (nvme.sart=, every 1.0.0b11 to 1.0.0b13.1 Stage 1 on these chips). That case was never tested, and it is the one that fails. On a J713 a 1.0.0b13 Stage 1 ran a b14 candidate Stage 1 as an aura-try trial. The candidate started ANS from off with the entries, warm, read the ESP, and handed the session on live. The Mac reset right at the handoff, with the configured Stage 2 and with main's own. When the candidate had no Stage 2 to hand to, it rebooted cleanly. On a J616s, the same candidate adopted a live session from a 1.0.0b10 Stage 1 and handed it on live, and that boot passed. So the origin decides. A session that came running may go on live. One this stage started from off goes on as it came: powered off, its SART entries passed on, through the existing post-M4 power-off. Its earlier stage chose that, and the firmware has just shown it starts from off. The chip list still says where a live handoff is wanted; the origin says where it is allowed. The Linux handoff (nvme_keep_running_for_linux) is unchanged. U-Boot can't start ANS from off, and kboot already reserves every SART-allowed range and the retained heap for Linux. tests: two T8132 cases. One arrives off and must go on off, then start from off again; it failed before this change. One adopts a live session and must stay live. Signed-off-by: Diljit Singh <hey@djdev.me> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On an M4 MacBook Air (J713, T8132), a warm reboot sometimes leaves Stage 2 without NVMe. The Mac stops in Aura and only a forced restart brings it back. Stage 1 powers ANS off after loading Stage 2, and Stage 2's cold start of ANS intermittently doesn't come up. This is the same failure #275 fixes on T6040/T6041.
Stacked on #275. The first commit is #275 rebased onto main, authorship kept. Its only conflict was the adopt condition, which main now spells
nvme_ans_storage_gated(). It resolves asnvme_ans_storage_gated() || nvme_post_m4_keeps_live(), so T6050 and T8142 are unchanged. Please review the last commit here. If #275 merges first, this rebases down to that one commit.The last commit adds T8132 to
nvme_post_m4_keeps_live(). Stage 1 hands its ANS session on running, with only the I/O queue registers cleared, and Stage 2 adopts it. It also keeps the live branch out of the way when a stage asks for a quiesced ANS (nvme_quiesce_for_next), so that path behaves as on main for every chip that hands on live. The T8132 expectation intests/python/test_nvme_adoption.pychanges to match: a live handoff keeps its queues.Tested on a J713 (Mac16,12), with Stage 1 (enrolled from 1TR) and Stage 2 built from this change on the
aurapackage pin (5dcf62d). Every boot logsnvme: handing the live ANS session onin Stage 1 andnvme: adopting the live post-M4 ANS sessionin Stage 2, with no cold start. Linux takes the controller over as before, andnvme0n1and all partitions are present. Nine consecutive warm reboots came up the same way. Thenvme_quiesce_for_nextgate was added after that run; it doesn't change the J713 boot path. Local builds pass for clang Stage 1 and Stage 2, the SPTM_VIRT ESP variant, and gcc cross Stage 1 and Stage 2.pytest tests/pythonpasses excepttest_loadobjs, which fails on main too in this environment.This change was developed and tested by Claude (Anthropic), working with me on the J713.
🤖 Generated with Claude Code