Repository navigation
accel/ane: recover an H16 ANE after a hung request - #1706
Merged
Merged
Conversation
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]>
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.
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 samehung_stop/hung_settle_msparameters. It also stops a wedged T600x/T8103 engine from refusing system sleep.ane_h16_program.{c,h}: optionalops->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. Withhung_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=0keeps the old behaviour.ane_t6021_lifetime.h,ane_t6021_rtclient_main.c:hung_stopandhung_settle_msare 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.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.
hung_stop=0) healed by the next s2idleDuring the 39 s2idle cycles there was one
PS ane_sys: Failed to reach power state 0xfon 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-tests292/292, checkpatch --strict clean.🤖 Generated with Claude Code