Repository navigation
accel/ane: boot the H16 engine again when its startup stalls - #1066
Merged
Merged
Conversation
On the J616s (T6041) the H16 firmware stops part way through startup on about one boot in ten. After READY and the IPC table it serves two to four SHAREDMALLOC requests, then posts nothing more and never answers the first startup command. The driver waits out the 3 s command timeout, quarantines the engine and holds it until reboot, so the boot has no /dev/accel. The point where it stops varies from boot to boot, nothing on the host side differs (IRQ status clear, the next ring slot empty), and a reboot clears it: 23 of the 215 J616s boots in the journal hit it, on every kernel we have run there. Answer a startup timeout at bring-up with a verified restart, at most twice: power the engine off, check that the cpu, mpm, td and base domains each reported an OFF transition, power it on, restore the DAPF records, RVBAR and the verified preload DATA, and boot the firmware again from the preload. This is the path a cold system sleep already takes, now shared through ane_h16_power_cycle(). The pool, IPC and heap are reused and the shared allocations carried over, so the firmware's requests on the second boot are served from the same memory. Nothing is unmapped while the stalled firmware may still hold it. The sys domain is the parent of the other four and stays on at runtime while another consumer holds it, so it is not part of the check. Without a verified power-off, a restart budget or the preload copy, a timeout ends in quarantine as before. Also print the firmware's own text log when startup times out, so the next stall shows where the firmware got to. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A startup restart powers the engine off before it checks that the domains went off. When that check fails, or the engine does not power up again, the restart returns an error and the boot is quarantined, and the quarantine reads the scratch and DART registers for its report. On an engine whose domains are off those reads go to unclocked MMIO. Power the engine up again when the reset cannot be verified, so the report reads a live engine, and let the backend tell the boot code whether the engine is powered: when it is not, the quarantine skips its register reads and keeps only the firmware log, which is in memory. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The H16 firmware stall that the bring-up restart answers also hits the cold boot after system sleep. On the J616s (T6041) the eighth s2idle wake of a stock boot timed out in startup the same way: the resume failed, the engine was quarantined, and every later system sleep was refused until reboot. Move the bounded restart loop into ane_h16_startup_restarting() and use it from both places. Bring-up keeps its budget in the boot state; the cold boot after sleep gets a fresh budget of the same size on every wake, so a restart spent at bring-up or on an earlier wake does not use it up. The restart is the same verified power cycle, preload boot and carried shared allocations as at bring-up. The resume line now also reports how many restarts the wake took. Two KUnit cases: a boot after sleep that stalls twice restarts twice on its own budget and completes, and one that stalls past the budget is handed back to the resume path, which quarantines as before. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
marked this pull request as draft
November 7, 2026 04:50
A coprocessor can stop in a state that only a power-off of its domain clears, while other devices in that domain hold it on at runtime. The ANE on the J616s (T6041) is one: its firmware sometimes stops part way through startup, and its DARTs keep the ANE sys domain on. A runtime power cycle of the four ANE subdomains does not clear the stop, while system sleep, which also turns the sys domain off, does. Add apple_pmgr_ps_cycle(), which power gates a domain and turns it on again without changing genpd's view of it. The caller owns every device in the domain and keeps them idle, and every subdomain must already be off. Domains owned by firmware or inherited on are refused. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A startup restart power cycles the cpu, mpm, td and base domains. The sys domain, their parent, stays on at runtime under the ANE DARTs. On the J616s (T6041) a natural firmware startup stall survives that: in two stalls on s2idle wakes, all four restarts failed again, the first reaching READY but never publishing the IPC table and the second not reaching READY. Re-ringing the doorbells every 250 ms gets no answer either. System sleep turns sys off as well, and the cold boot after it starts the firmware cleanly. Do the same in a restart: once the four subdomains have reported OFF, power gate sys through apple_pmgr_ps_cycle() and turn it on again. The DARTs keep their SID0 state across it, as they do across system sleep. If the cycle fails, the engine is powered up again and the restart ends in quarantine as before. On the J616s, 40 s2idle wakes with this gave 5 natural startup stalls. Each was cleared by one restart (wake about 3 s), the open program was replayed, a fresh LOAD after the 40 wakes gave identical output, there were 0 DART faults and SELinux reported 0 AVCs. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
marked this pull request as ready for review
November 7, 2026 06:52
RyanTheTide
added a commit
that referenced
this pull request
Nov 7, 2026
Brings aurora-wip up to the tested release branch: CTXR execmem (#985, #1079), KFIX speaker sleep and resume fixes (#1077, #1080), JPEG v2 (#1072), Jonathan's G17 and USB work (#1073-#1076), brcmfmac flowring count (#1081), ANE H16 startup restart (#1066) and the Touch ID per-prompt match (#904). Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On the J616s (T6041, M4 Pro) the H16 ANE firmware stops part way through startup on about one boot in ten. After READY and the IPC table it serves two to four SHAREDMALLOC requests, then posts nothing more and never answers the first startup command. The driver waits out the 3 s command timeout, quarantines the engine and holds it until reboot, so that boot has no
/dev/accel. The stop point varies from boot to boot, nothing on the host side differs (IRQ status clear, next ring slot empty), and a reboot clears it.This change answers a startup timeout at bring-up with a verified restart, at most twice:
sysis their parent and stays on at runtime while another consumer holds it);ane_h16_power_cycle();Without a verified power-off, a restart budget or the preload copy, a timeout ends in quarantine as before. A startup timeout now also prints the firmware's own text log.
A second commit keeps a failed restart from reading an unpowered engine. When the reset cannot be verified the engine is powered up again, and a new optional
powered()op lets the quarantine skip its scratch and DART register reads while the domains are off. It keeps only the firmware log, which is in memory.A third commit gives the cold boot after system sleep the same restart. The stall hits there too: on the eighth s2idle wake of a stock fleet18 boot, startup timed out, the resume failed, the engine was quarantined, and every later system sleep was refused until reboot. The loop moved into
ane_h16_startup_restarting(). Bring-up keeps its budget in the boot state, and each wake gets a fresh budget of the same size. The resume line now also reports how many restarts the wake took.Five commits. The first three touch only
drivers/accel/ane/. The fourth addsapple_pmgr_ps_cycle()todrivers/pmdomain/apple/pmgr-pwrstate.c(new headerinclude/linux/soc/apple/pmgr-pwrstate.h). It power gates a domain and turns it on again under its consumers, without changing genpd's view, and refuses when a subdomain is on or the domain is owned by firmware or inherited on. The fifth uses it in the verified restart. Seven new KUnit cases inane-h16-boot:Hardware evidence (J616s, 7.3.0-aurora-fleet17 with these modules, one-shot boots)
/dev/accel. The rate comes in bursts: 4 of 9 boots before this work, 0 of 25 in a later loop on another lane's test kernel. One stock fleet18 boot stalled on its eighth s2idle wake instead, and every system sleep after it was refused.-p3messages, SELinux enforcing with 0 AVCs.ane_h16_power_cycle()path, boot b5121a14, ANE up on the first attempt): MobileNet 16/16, p50 0.663 ms. One sleepcheck plus two s2idle cycles ran the same handle after each wake with identical output. Firmware was ready 14-15 ms after resume, and a fresh LOAD after two cycles gave identical output. 0 DART faults and 0 AVCs.Checks
checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.drivers/accel/aneanddrivers/pmdomain/apple, 0 warnings.🤖 Generated with Claude Code