Repository navigation
nvme: post-M4: shut the controller down normally before ANS goes off - #432
Conversation
|
Blockers: 1.
What I checked and found sound at 5e5ccd6:
HW row: on 5e5ccd6, Stage 1 then Linux, at least 20 cold boots each on J773g/J713 (T8132), T8140 (J700), M4 Pro (T6040/T6041, from-off restart), M5 (T8142 and T6050), J873g (T8152, Linux started from the quiesced ANS, NVMe root mounts) and one M1-M3 Mac. Pass: 0 "IOP crashed"/"didn't acknowledge idle"/"shutdown timed out" lines, every next-stage ANS start succeeds, then 0 AVC, 0 failed units and 0 new kernel errors. Also one J616s ESP self-boot that reaches XNU's ANS start, if the quiesce branch keeps the shutdown. |
5e5ccd6 to
2aa0035
Compare
|
Updated
Assisted-by: LLM (Gemini:4 Neon) |
|
Re-checked at 2aa0035 (the real commit under the trailing github-actions "gfya" commit).
Still missing: rows at 2aa0035. Stage 1 then Linux, 20+ cold boots each on J773g/J713 (T8132), T8140, one M4 Pro/Max (the from-off restart), M5 (T8142, T6050) and one M1-M3 Mac. Pass: 0 "IOP crashed", 0 "didn't acknowledge idle" and 0 "shutdown timed out" lines; the new power-off line shows controller/idle times; every next-stage ANS start succeeds; 0 failed units and 0 new kernel errors. The T8152 and ESP-handoff rows are no longer needed, since that path is unchanged. Assisted-by: LLM (Claude:Opus 5.5) |
Since 37acfb5 a post-M4 stage that only read the drive disables the controller and idles the firmware without a normal shutdown (CC.SHN). The firmware then does its shutdown work under the RTKit idle, and that idle can fail. On a J773g (M4 Mac mini, T8132), 14 of 57 1.0.0b13 Stage 1 boots, each of which only read the ESP, ended with either rtkit(nvme): IOP crashed! ... rtkit(nvme): IOP died during shutdown nvme: ANS didn't acknowledge idle, stopping it anyway (4 boots; the firmware's crash report counted 16 or 48 commands still open and no shutdown) or an idle that wasn't acknowledged within its 5 s (10 boots; the clean boots' idles took up to 5.1 s). After either, the next stage found ANS's CPU stopped instead of in its reset state, and its start of ANS from off failed until a reboot. iBoot does the normal shutdown: at Stage 1 entry the controller read CC=0x474000 (CC.SHN normal, CC.EN clear) on every one of those boots. Do the normal shutdown first in nvme_ans_power_off() on every non-T6050 chip, whatever the stage did with the drive, dropping the T8142-only special case while leaving nvme_shutdown()'s quiesce path untouched (so T8152 Linux boots and ESP HV handoffs keep their proven read-only quiesce path). A shutdown that doesn't finish still goes on to the disable, as nvme_ans_power_off() did; the queues are deleted by then. T6050 keeps macOS's suspend shutdown. The power-off line now gives the controller and idle times, so a slow handoff shows which step took it. test_nvme_adoption expects the normal shutdown before every post-M4 power off of a stage that only read, and no normal shutdown on read-only quiesce. Signed-off-by: Diljit Singh <hey@djdev.me>
ca0c4f5 to
dd29252
Compare
|
@RyanTheTide Dropped the trailing Remaining: Stage 1 → Linux cold-boot rows (20+ boots each) at Assisted-by: LLM (Gemini:4 Neon) |
|
J773g (T8132), November 30. The installed Stage 1 at I tested this head and its parent in RAM behind the installed Stage 1. Each cycle started ANS, read the GPT and 1 MiB of the ESP, verified the data and powered ANS off. All nine saved SART entries were passed on entry.
At the PR head the controller shutdown and disable took 541–564 ms, and the RTKit idle took 10 ms on each cycle. The two failed starts timed out before this image ran its first shutdown. The control also completed every shutdown it reached, so the installed Stage 1 failure rate with this patch is still unmeasured. A diagnostic build of this head extended only the warm IOP report wait to 20 s and logged its duration. Six of seven fresh boots received the report in 70 ms. On the remaining boot, ANS sent HELLO and its endpoint map. RTKit reported an IOP crash 10.074 s into the wait, with CPU status 0x68 and all nine SART entries present. The inherited session supplied no crash text, so the reason inside the firmware is unknown. Extending the deadline did not recover that failure. Each test returned to verified saved stock. The PR remains a draft. |
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: HOLD at dd29252a
Blockers:
- Missing enrolled-Stage-1 cold-boot evidence on J773g/J713 (
T8132) atdd29252a: in the RAM test behind installed 1.0.0b13, both parentdff1235d(30/30) anddd29252a(10/10) had 0 bad idles, so the installed Stage 1 ANS-idle failure rate against the7/72baseline is still unmeasured. - Remaining post-M4 cold-boot rows requested in the prior review (
T8140,T6040/T6041from-off restart path, andT8142/T6050Stage 1 → Linux) are not yet captured atdd29252a(unless a maintainer explicitly defers them to the release gate).
Checked:
- Scope (
+25/-10acrosssrc/nvme.candtests/python/test_nvme_adoption.py):nvme_ans_power_off()now runsnvme_ctrl_shutdown()unconditionally beforenvme_ctrl_disable()on non-T6050chips and logs controller vs. idle elapsed milliseconds. - Path isolation verified against live
main(src/nvme.c):nvme_ans_power_off()is only called from post-M4 paths (src/nvme.c:780,842,1078);M1–M3(NVME_T8103) is untouched (and J516s M3 Pro regression passed through chainloaded Stage 1).T6050keeps itsnvme_ctrl_suspend()branch unchanged;T8142already rannvme_ctrl_shutdown()unconditionally.nvme_shutdown()'s quiesce branch (normal_shutdown = nvme_wrote || nvme_type != NVME_T8132) is untouched, preserving the read-only quiesce path forT8152Linux boots and ESP HV handoffs.- Shutdown timeout remains bounded (5 s in
nvme_ctrl_shutdown(), continuing intonvme_ctrl_disable()andrtkit_idle()as before).
- Unit tests & CI:
tests/python/test_nvme_adoption.pyverifiesshutdown_callson read-only power-off andshutdown_calls == 0on read-only quiesce; all 18 hosted CI checks pass atdd29252a.
Evidence
- Mechanism confirmation (J773g RAM test at
dd29252a):10/10read/shutdown cycles completed with0bad idles; controller shutdown + disable took541–564 msandrtkit_idle()dropped to10 mson every cycle (compared with up to5.1 s/5 stimeouts withoutCC.SHN). - Separate startup crash: The 1/7 diagnostic warm IOP power-report crash (
CPU status 0x68at10.074 s, before the first candidate shutdown) is tracked separately in#613and is not introduced by this patch. - Code audit: No logic, timeout, format-specifier, or regression defects found in
src/nvme.catdd29252a.
DjDeveloperr
left a comment
There was a problem hiding this comment.
MERGE at dd29252a4454bf123b03413d3b07f8b7221c31d6. No blocking findings.
I traced all three callers of nvme_ans_power_off(). On the affected path, an enabled controller now gets a bounded normal shutdown before disable and RTKit idle, including after a read-only stage. Read-only quiesce still skips normal shutdown, and T6050 still uses suspend.
Test evidence
All eight focused NVMe tests passed locally at this commit. The updated adoption test caught the missing shutdown against the parent. CI passed. On J773g the candidate completed 10/10 read and power-off cycles after one successful start. The other two starts failed before the candidate issued a shutdown. J516s booted stock Linux through the candidate. The J773g failure rate with the candidate installed as Stage 1 remains unmeasured and is still part of release testing.
|
Hardware results at
The J773g installed-Stage-1 baseline had 7 ANS-idle failures in 72 boots. The candidate's installed-Stage-1 cold-boot rate is still unmeasured. The intermittent ANS startup crash is tracked in #613. |
Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: HOLD at 93c97843
Blockers:
- CI checks are still queued at
93c97843.test(46505860288),build(46505860581),stage1-size(46505860415), andesp-stage2-size(46505860240) are still queued (format-check,pr-text,aurora-agent-policy, andpr-readinesspassed). - Enrolled-Stage-1 cold-boot hardware proof remains open. As noted in the PR body's
Not yet:section and the prior review atdd29252a, J773g/J713 (T8132) cold boots with this image enrolled as Stage 1 (measured against the7/72ANS-idle failure baseline) and the remaining post-M4 cold-boot rows (T8140,T6040/T6041) are still pending; in the RAM test behind installed 1.0.0b13, both parent (30/30) and candidate (10/10) had 0 bad idles.
Checked:
- Merge commit
93c97843(Merge main into djdev/ans-normal-shutdown): confirmedsrc/nvme.candtests/python/test_nvme_adoption.py(+25/-10) are byte-identical todd29252awith no conflict drift. nvme_ans_power_off()executes bounded normal shutdown (nvme_ctrl_shutdown()) beforenvme_ctrl_disable()andrtkit_idle()on all non-T6050 post-M4 chips regardless ofnvme_wrote, leaves T6050's suspend path and read-only quiesce untouched, and logs controller/idle durations cleanly viaticks_to_msecs().
Evidence
- Queued runs at
93c97843:46505860288(test),46505860581(build),46505860415(stage1-size),46505860240(esp-stage2-size). - Passing runs at
93c97843:46505860282(format-check),46505874200(pr-text),46505918554(aurora-agent-policy),46505860799(pr-readiness).
There was a problem hiding this comment.
Verdict: MERGE at 93c97843710d
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Merge commit 93c97843 (Merge main into djdev/ans-normal-shutdown): confirmed src/nvme.c and tests/python/test_nvme_adoption.py (+25/-10) are byte-identical to dd29252a with no conflict drift.
nvme_ans_power_off()executes bounded normal shutdown (nvme_ctrl_shutdown()) beforenvme_ctrl_disable()andrtkit_idle()on all non-T6050 post-M4 chips regardless ofnvme_wrote, leaves T6050's suspend path and read-only quiesce untouched, and logs controller/idle durations cleanly viaticks_to_msecs().
Follow-ups (not blocking): queued CI; enrolled Stage 1 cold-boot rows on T8132/T8140/T6040
|
Merging at |
What: Request a normal NVMe controller shutdown before powering ANS off on the post-M4 path. This lets the controller finish shutting down before RTKit idles the firmware.
Tested: At
dd29252a, J773g (M4 mini) completed 10/10 shutdown cycles in RAM after a successful start. J516s (M3 Pro) booted stock Linux through the chainloaded candidate Stage 1 and returned to verified saved stock.Risk: Two-way door · shared Stage 1 code on all Macs. The changed power-off path runs on post-M4 systems that power ANS off between stages.
Not yet: J773g cold boots with this image enrolled as Stage 1. The prior installed-Stage-1 baseline was 7 ANS-idle failures in 72 boots. The separate startup failure is tracked in #613.
Since
37acfb50, a post-M4 stage that only read the drive powers ANS off without an NVMe normal shutdown (CC.SHN):nvme_ans_power_off()disables the controller and idles the firmware directly. The firmware then does its shutdown work under the RTKit idle, and that idle can fail.What changes
nvme_ans_power_off()performs the normal shutdown (CC.SHN) before disabling the controller on every non-T6050 chip, whatever the stage did with the drive, dropping the T8142-only special case.nvme_shutdown()'s quiesce branch andnvme_wroteare unchanged, so T8152 Linux boots and ESP quiesced handoffs keep their proven read-only quiesce path.nvme_ans_power_off().nvme_ans_power_off()already did. The queues are deleted by then.ANS powered off, N SART entries kept (controller X ms, idle Y ms).Why
On a J773g (M4 Mac mini, T8132) running an installed 1.0.0b13 Stage 1, 14 of 57 boots failed the RTKit idle after the ESP reads:
rtkit(nvme): IOP crashed!...IOP died during shutdown). Its crash report counted 16 or 48 commands still open, with no shutdown.After either failure, ANS's CPU was stopped instead of in its reset state, and the next stage's start of ANS from off failed until a reboot. iBoot does the shutdown: the controller read CC=0x474000 (CC.SHN normal, CC.EN clear) at Stage 1 entry on all 57 boots.
Testing
test_nvme_adoptionexpects the normal shutdown before every post-M4 power off of a stage that only read, and no normal shutdown on read-only quiesce. It fails on main and passes here alongsidetest_nvme_poisoned_io.