Skip to content

accel/ane: boot the H16 engine again when its startup stalls - #1066

Merged
RyanTheTide merged 5 commits into
integration/aurorafrom
ane/h16-startup-restart
Nov 7, 2026
Merged

RyanTheTide merged 5 commits into
integration/aurorafrom
ane/h16-startup-restart

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Status (11-07 17:55): proven on the final code. Test kernel 7.3.0-aurora-fleet19eng1 is integration b8ae494 (the fleet19 source) plus this branch. On the J616s, 40 s2idle wakes gave 3 natural startup stalls, and all 3 were recovered by one restart: firmware ready about 3.0 s after resume, the open program replayed, and a fresh LOAD after 40 wakes gave identical output. There were 0 failed resumes, 0 refused sleeps, 0 sys-cycle failures and 0 DART faults. 22 one-shot bring-up boots all had /dev/accel on the first try, with no natural stall.
The earlier test build, which did the same sys power gate with a direct register write on fleet17, recovered 10 of 10 natural stalls in 80 wakes. Without the sys cycle, 0 of 4 restarts recovered.
The cause itself is still open. 3 of those 10 stalls followed PS ane_sys: Failed to reach power state 0xf (now 0xb4f) at the resume power-on: clock-gated with BUSY, the missing-upstream case that pmgr already waits out for T6000 GFX. That is a follow-up; this series recovers the stall either way.

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:

  • power the engine off and check that the cpu, mpm, td and base domains each reported an OFF transition (sys is their parent and stays on at runtime while another consumer holds it);
  • 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();
  • reuse the pool, IPC and heap and carry the shared allocations over, so the second boot's requests are served from the same memory. Nothing is unmapped while the stalled firmware may still hold it.

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 adds apple_pmgr_ps_cycle() to drivers/pmdomain/apple/pmgr-pwrstate.c (new header include/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 in ane-h16-boot:

  • a stalled startup restarts and completes;
  • the budget bounds the cycles;
  • an unverified power cycle is not followed by another CPU release;
  • with no budget, a timeout ends as before;
  • a restart that leaves the engine off quarantines without touching its registers;
  • a boot after sleep that stalls twice restarts on its own budget;
  • one that stalls past the budget goes back to the resume path, which quarantines.

Hardware evidence (J616s, 7.3.0-aurora-fleet17 with these modules, one-shot boots)

  • Before: the J616s journal holds 285 boots with an H16 startup. 24 of the 258 on stock kernels hit the startup timeout, fleet16, fleet17 and fleet18 included, and 22 of those boots had no /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.
  • Forced stall: a test-only build that drops the first startup doorbell. It gave the 3 s timeout, then the verified power cycle; the second boot completed in 15 ms and reused all four shared allocations. MobileNet v2 16/16 twice, p50 0.567/0.632 ms, 0 DART faults, no -p3 messages, SELinux enforcing with 0 AVCs.
  • After: see the status above. Natural stalls on s2idle wakes are recovered: 3 of 3 on the final code and 10 of 10 on the test build. In 15 + 11 + 22 bring-up boots on the restart modules, the ANE came up first time every time.
  • Cold sleep (the shared 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.
  • W=1, arm64 clang, fleet19 config: drivers/accel/ane and drivers/pmdomain/apple, 0 warnings.
  • ANE KUnit (kunit.py, x86_64 QEMU, KASAN+UBSAN): 212/212 on both the boot and transport configs (base 205 plus the 7 new cases). pmgr-pwrstate KUnit (arm64): 10/10.

🤖 Generated with Claude Code

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
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
RyanTheTide marked this pull request as ready for review November 7, 2026 06:52
@RyanTheTide
RyanTheTide merged commit 727c75e into integration/aurora Nov 7, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the ane/h16-startup-restart branch 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
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