Skip to content

accel/ane: recover an H16 ANE after a hung request - #1706

Merged
RyanTheTide merged 3 commits into
integration/aurorafrom
fix/ane-h16-hung-request
Nov 12, 2026
Merged

RyanTheTide merged 3 commits into
integration/aurorafrom
fix/ane-h16-hung-request

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

A request that never completes on the M4 Pro (T6041, H16 backend) quarantines the session. The engine then stayed unusable until reboot: every later LOAD and EXECUTE failed with -EIO, and a system sleep did not help, because the cold boot on resume never ended a session quarantine. This applies the T8112 hung-job recovery (#1693) to the H16 path, with the same ane_t6021_restart_run() sequence and the same hung_stop / hung_settle_ms parameters. It also stops a wedged T600x/T8103 engine from refusing system sleep.

  • ane_h16_program.{c,h}: optional ops->hung(), called once when the session quarantines. Programs closed while quarantined go on a held list with their memory; ane_h16_session_recovered() ends the quarantine after a new firmware boot and gives that memory back (it used to leak until reboot).
  • ane_h16_backend.c: recovery work. RUN cleared, hung_settle_ms, cpu/mpm/td/base powered off through genpd with the DARTs held and each verified off, sys cycled on its own, firmware booted again from the preload, open programs replayed. No reset is asserted. Requests wait for it to finish. With hung_stop=1, system sleep powers a quarantined engine off without the firmware and boots it cold on resume when every domain went off. Recovery is flushed before sleep and blocked during it. hung_stop=0 keeps the old behaviour.
  • ane_t6021_lifetime.h, ane_t6021_rtclient_main.c: hung_stop and hung_settle_ms are shared by both paths.
  • ane_drv.c (ane.ko): a wedged engine no longer refuses system sleep. Its partitions go off with the sleep, and resume tries one more recovery unless the wedge is final.
  • KUnit: program_hung_recovery_test.

Results

J616s, one-shot kernel = fleet67 (c6c15ac) + #1680 + #1693 + this change, SELinux enforcing. Deliberate hang: a rule-built exp 128x128 program (EXECUTE times out after 3.0 s). Good job: MobileNetV1 224, 16 images, top-1 against the reference.

before (fleet67) after
hung request session quarantined until reboot 12 hangs: 11 recovered at runtime in 112-123 ms, 1 (hung_stop=0) healed by the next s2idle
MobileNet after a hang LOAD -EIO, also after 2 s2idle top-1 16/16 after every recovery
hang then s2idle rc 0, ANE still dead 11/11 rc 0, ANE works after
s2idle overall 39/39 rc 0, ANE resume ok every time
MobileNet p50 (x200) 0.275 ms 0.278 ms, top-1 16/16
DART faults, AVC, failed recoveries 0, 0, 0

During the 39 s2idle cycles there was one PS ane_sys: Failed to reach power state 0xf on a plain wake (the ANE resumed after one startup restart). The same line also appears on kernels without this change.

M1 Pro, fleet67 + ane.ko = fleet67 + #1660 + this change (runtime swap): three hangs recovered, the fourth gave the final wedge, then s2idle 3/3 rc 0 with the wedge kept (before: every s2idle -16). Stem relL2 2.18e-4, p50 135.7 us. 0 DART faults, 0 AVC.

KUnit arm64 (ane + fw + pm suites, KASAN): 266 tests, 265 pass. The one failure, ane-h16-program program_add128_slots_test, also fails on unmodified integration/aurora with the same config. run-host-tests 292/292, checkpatch --strict clean.

🤖 Generated with Claude Code

On the M4 Pro (T6041, H16 backend) a request that never completes
quarantines the session. The engine then stayed quarantined until
reboot, and ane_h16_sleep_prepare() returned -EBUSY for it, so every
system sleep was refused for the rest of the boot.

Recover it with the restart sequence the T8112 path uses for a hung
job (ane_t6021_restart_run(), unplanned) and the same hung_stop and
hung_settle_ms parameters:

- The session calls a new optional ops->hung() once when it
  quarantines, and the H16 backend queues a recovery. It clears RUN,
  waits hung_settle_ms for the engine to drain, powers the cpu, mpm,
  td and base domains off through genpd with the DARTs held on and
  checks each one went off, cycles sys on its own, boots the firmware
  again from the preload and replays every open program behind its
  handle. The H16 wrapper status cannot prove a stop, so the verified
  power-off stands in for that proof. No reset is asserted. New
  requests wait in ane_h16_session_enter() until it finishes.
- A program closed while the session is quarantined goes on a held
  list with its memory, since the old firmware may still read it.
  ane_h16_session_recovered() ends the quarantine once the new
  firmware is up and gives that memory back. Such a program used to
  leak until reboot.
- With hung_stop set, system sleep accepts a quarantined instance: its
  engine is powered off without the firmware (DARTs held until the
  domains are off) and booted cold on resume if every domain reported
  an OFF transition while asleep. Otherwise it stays quarantined.
- Runtime recovery is flushed before, and blocked during, system
  sleep.

hung_stop=0 keeps the old behaviour: quarantined until reboot, sleep
refused.

KUnit: program_hung_recovery_test checks that ops->hung runs once, the
held program is released by the recovery, and the open program is
replayed and runs again.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
After a job hangs and recovery fails or gives up (three hangs in a row
with no good job between them), ane.ko keeps the engine wedged until
reboot. Runtime suspend vetoes gating while wedged, and system sleep
goes through pm_runtime_force_suspend(), so every s2idle failed with
-EBUSY for the rest of the boot.

Give ane.ko its own system sleep callbacks. Suspend notes that the
engine is wedged and lets runtime suspend gate it: its partitions go
off with the sleep, before its DART suppliers, which is the power-off a
recovery cycle performs anyway. On resume an engine whose recovery may
still help gets one more ane_tm_recover() attempt, as from the reset
file. A final wedge stays until reboot, but no longer blocks sleep.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
A hung request quarantines only the H16 session, not the boot, so
ane_h16_sleep_prepare() never refused sleep for it. With hung_stop=0
that stays as it was: the sleep goes ahead and the quarantine is kept.
Only a boot quarantine refuses sleep, as before.

The cold boot after sleep now ends a quarantine only when the sleep
took a quarantined engine down (hung_stop=1), and runtime recovery
always does. Behaviour with hung_stop=1 does not change.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 12, 2026 16:37
@RyanTheTide
RyanTheTide merged commit ed1de9f into integration/aurora Nov 12, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the fix/ane-h16-hung-request branch November 12, 2026 16:37
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