Repository navigation
Conversation
|
Thanks, this is a useful recovery and the unit tests cover the retry shape well. A few problems before it can go in:
Testing: at this head the recovery path has no hardware run. The J616s recovery run was on the b13.1 tree before the rebase, and in the watchdog run the first start worked. The cold-after-reset and power-cycle branches have only run in the unit test. Please add:
M1/M2/M3 and T8152 never reach this path (src/nvme.c:826), so they need no rows. Assisted-by: LLM (Claude:Opus 5.5) |
|
The top commit on this branch ("gfya", from the policy workflow running in your fork) deletes Your code commits below it are unaffected. Assisted-by: LLM (Claude:Opus 5.5) |
|
Thanks. The workflow had run again on the branch and deleted the files a second time, so I merged I'm working through your 07:43 review next (reset only on |
|
Thanks for the review. Pushed db8c872:
J616s at this head, Stage 2 as an aura-try trial with the test-only hook:
All three booted to Linux with NVMe and the three displays. I have no J713 or J700, so those rows still need someone who has them. |
|
@fbalazsy checking open drafts today. To come out of draft, this still needs:
If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done. |
|
J713 (M4 MacBook Air, T8132, 27.2) data for this PR. We've been hitting the "ANS didn't start from off" strand on warm reboots (5 times on 11-27/28, always after a complete Linux shutdown; the Mac then sits in the Stage 2 USB proxy until a USB-C VDM reset). Two signatures, both read over the parked proxy:
I put your five code commits on current main with one more commit that also restarts a start which got HELLO but never reported any IOP power state. A firmware that reported a state or a BOOT_STATUS is still left alone. There are 4 more host cases, and the full suite passes. As a J713 trial (production Stage 2 rebuilt byte-identical + only this src diff) the normal path is 25/25 warm boots with |
|
J713 (MacBook Air 13" M4, T8132) row with this PR's code: no regression in 41 warm reboots. The failure this PR recovers from did not happen in any of them, so the reset path itself is still untested on the J713. Build: Stage 2 ( Boots: 41 one-shot
Not yet: a J713 boot where the first start from off gets no HELLO. #480 measured that failure on the J713 at 2 of 14 warm boots; it didn't come up in these 41. |
|
Cross-link: the kernel-side hibernation work that depends on this boot-side recovery is aurora-silicon/linux#2977. Without an unattended recovery from a watchdog reset taken while ANS was stopped for sleep, the hibernate/restore (S4) runtime validation there stays blocked, so this is the gating piece. |
pmgr_reset_held() is declared in every build but only built with SPTM_VIRT. A Stage 2 needs it to reset an idle ANS, which refuses a plain pmgr_reset(). Build it everywhere, and look the device up with pmgr_find_device_by_name() as pmgr_reset() does, so that a virtual child sharing its parent's name isn't picked. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
…ails A post-M4 ANS whose CPU was stopped without a reset since it last ran sends no HELLO after the run bit, then or later. A Stage 2 that meets it in nvme_ans_power_on() stops with "ANS didn't start from off; it stays down until a reboot" and parks in the proxy. On a J616s (T6040) the state survived a watchdog reset taken while Linux had ANS stopped for sleep, and every warm reboot after it; only a power-off cleared it. Make that start again from a reset ANS, as XNU starts it: stop the CPU, reset ANS alone through PMGR with its gate held on (pmgr_reset_held()), drop what is left in the mailbox, put the SART entries back, and start it warm (the HELLO the firmware sends unasked), then after another reset cold (INIT, then HELLO). If that fails too, power-cycle ANS and its PCIe block first and do the same once more. A start that granted the firmware buffers isn't retried. Nothing changes when the first start works. J616s, Stage 2 with this change as an aura-try trial behind an installed 1.0.0b13.1 Stage 1, with a test-only hook that idles ANS (acknowledged) and starts it from off again without its power-off or a reset: CPU status 0x6e and "did not receive HELLO"; after the reset 0x6a, HELLO, started in 0.12 s, and the boot went on to Linux. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
2945f30 ("pmgr: build pmgr_reset_held() outside the SPTM_VIRT build") also changed how pmgr_reset_held() finds its device: virtual entries became skipped. Its existing caller, the T8140 cold handoff, may then pick another entry than before, and that wasn't checked there. Keep the lookup as it was; the change only needs the function built everywhere. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
rtkit already records a start whose firmware sent no HELLO, for rtkit_boot_or_adopt(). Give callers an accessor, so that they can tell a firmware that never answered from one that answered and then failed a later step of its start. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
110acee ("nvme: post-M4: start ANS again from a reset when its start from off fails") resets ANS after any failed start from off. A start also fails when the firmware sent HELLO and the endpoint map but its power report didn't come in time, or when BOOT_STATUS didn't turn OK. Such a firmware is running its resume, may be doing NAND work around it, and must not be reset under it. Reset only when the failed start got no HELLO at all (rtkit_no_hello()); any other failure stays on the "stays down" path, as before that commit. The cold start from a reset used rtkit_boot(), whose wait for the power report has no limit: a firmware that says HELLO and never reports would hang the stage. Use rtkit_boot_timed() with the 6 s the warm start gives the same report. The comment no longer says where the sequence was seen: it is the normal RTKit start. Some machines name ANS's PMGR device ANS2, as nvme_ans_sleep_and_reset() notes; the reset now tries both names. The gate listed for /arm-io/ans is not used, since on T8140 it is the virtual APCIE_SYS_ST-V. Worst case added to a boot: the recovery runs only after starts that got no HELLO, each of which waits 1 s, so at most 4 s for the four retried starts, four held resets (a PMGR mode change and 10 us each) and one power cycle of ANS and its PCIe block. The last start then has the limits every start has (1 s for HELLO, 6 s for each power report, 1 s for BOOT_STATUS). There is no loop beyond the five starts. J616s (T6040), this Stage 2 as an aura-try trial behind an installed 1.0.0b13.1 Stage 1, with a test-only hook that idles ANS (acknowledged) and starts it from off again without its power-off or a reset: - warm after reset: CPU status 0x6e, "did not receive HELLO"; after the reset 0x6a, HELLO, started 0.12 s after the reset. - cold after reset (hook also skips the first reset): two starts with no HELLO, then the reset (0x6e -> 0x6a) and the cold start, started 0.12 s after the reset. - without the hook: the first start works and nothing else runs. Each boot went on to Linux with NVMe working. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
655d3ac to
d39fd85
Compare
A resume from hibernation (hib=1) hands to a kernel that must unfreeze its own devices before it can pet a watchdog. On a plain boot Stage 2 disarms the boot watchdog at the hand-off, so a step that wedges during the resume stays on screen until the power button instead of resetting. Arm WD2 in reset mode across the hand-off whenever this boot may resume from hibernation, the way a trial boot already keeps its own: the kernel's driver finds it running and keeps it fed on a good resume, and a wedged one resets. A plain boot without hib=1 still brings its own. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
|
J713 (MacBook Air 13" M4, T8132) at head
Evidence
|
A production Stage 2 must give Linux aura,hibernate-layout without a test payload line, or a normal boot cannot hibernate. Turn the layout on once the chip id is known. hib=0 still turns it off. hib=1 also marks a resume boot so the boot watchdog stays armed across that hand-off only; leaving it armed on every layout boot would catch a kernel that has not adopted it. The layout is still refused when the chip or the placement cannot have it. Signed-off-by: František Balázsy <fbalazsy@users.noreply.github.com>
|
This branch now publishes the hibernation layout on a production Stage 2 by default, so Linux can hibernate without a test payload line.
This pull request stays a draft. |
|
The ANS reset/recover work in this pull request is already on The hibernation-layout work that was later added here now lives in #653 ( Closing this pull request as superseded by #593 for ANS, with the hibernation follow-up in #653. |
Draft. A post-M4 Stage 2 that can't start ANS from off resets ANS and starts it again, instead of parking in the proxy.
Problem
nvme_ans_power_on()gives up after one warm start:ANS didn't start from off; it stays down until a reboot, thenNo valid payload foundand the proxy.On a J616s (T6040, 1.0.0b13.1 Stage 1) a watchdog reset taken while Linux had ANS stopped for sleep left ANS in that state:
rtkit(nvme): did not receive HELLOon the reset and on every warm reboot after it. Only a 10 s power-off brought it back. The firmware was stopped without a reset since it last ran, and such a firmware sends no HELLO after the run bit, then or later.Change
pmgr: build pmgr_reset_held() outside the SPTM_VIRT build. It was declared everywhere but only built with SPTM_VIRT. (Its lookup change is undone bypmgr: find pmgr_reset_held()'s device as before, so the T8140 cold handoff is unchanged.)rtkit: tell whether a failed start got no HELLO: an accessor for the existingno_hello.nvme: post-M4: start ANS again from a reset when its start from off fails, narrowed bynvme: post-M4: reset ANS only for a start that got no HELLO. When the first warm start got no HELLO at all, ANS is started again from a reset:rtkit_boot_timed(), 6 s for the power report).pcie_ans_power_off()/pcie_ans_power_on()) and repeat steps 1 to 3 once.A start that got HELLO and then failed (late power report, BOOT_STATUS) is not reset and stays down as before. A start that already granted the firmware buffers isn't retried. The reset tries
ANS, thenANS2. When the first start works, nothing changes.Worst case added to a boot: 4 s (four retried starts, each with the 1 s HELLO wait), four held resets and one power cycle of ANS and its PCIe block; the last start keeps the usual limits.
Only PMGR and the existing ANS/SART/PCIe paths are used. No new registers.
Testing
did not receive HELLO. After the reset: 0x6a, HELLO, started in 0.12 s, and the boot went on to Linux.ANS started from offon the first start. Each boot went on to Linux with the panel, Type-C DP and HDMI lit.tests/python/test_nvme_ans_warm_start.pycovers: warm after a reset, cold after a reset, after a power cycle, never, reset failing, buffers granted, and no reset when the firmware answered (BOOT_STATUS, late power report, after a reset, cold).test_nvme_adoption.pygets the new stubs.pytest tests/pythonhas no new failures: 819 passed against 816 on the base, with the same 15 failures and 10 collection errors on both, all from the local environment (missing proxyclient modules and tools).Related
This overlaps work that is already open:
nvme_ans_power_on(). If nvme: one STOPPED ANS handoff between boot stages on post-M4 chips #380 lands first, this rebases onto itsnvme_ans_reset. It is also a T6040 measurement of the held reset, which nvme: one STOPPED ANS handoff between boot stages on post-M4 chips #380 lists as unmeasured.