Repository navigation
Conversation
On H17 a request that never completes quarantines the session (h16_fail()), and the backend has no ops->hung: every later LOAD fails with -EIO until reboot. A system sleep does not help either. The sleep path sends a STOP the hung firmware never answers, powers the engine off on the deep path and boots it again from the preload on resume, but nothing ends the session's quarantine, so the new firmware sits unused. macOS restarts the firmware after a request timeout: it powers the engine off, going on when the firmware never answers the stop, starts it again cold and reloads the open programs. The H16 and T8112 paths do the same. Do it on H17, at runtime and across a system sleep: - ops->hung queues a recovery. It closes the session, polls every ANE DART port for idle (up to 100 ms per port) so no DMA is cut off mid-flight, and powers the engine off under the firmware with the power-down a sleep and a park already use: sub-block, PWGATE and its ack, CPU, then ANE_SYS through genpd, which deactivates the DARTs right before it goes off. The firmware is not asked to stop, and no new register is written. Outside a sleep, busy DART ports or a stuck power word fail the runtime recovery and leave recovery to the next system sleep instead of deferring to a deep path that does not come. - A system sleep with a quarantined session (or one the closing gate release quarantines) powers the engine off the same way, without the futile STOP, and takes the deep path as the failed STOP made it do. - Runtime suspend checks the session before and after closing it and returns -EBUSY without permanently quarantining the backend, leaving a quarantined session to the recovery work or the next system sleep. Nothing the old firmware could reach is reused until it is proven gone: after our power-down began, genpd must report ANE_SYS off with its PMGR actual state (bits 7:4) reading off, nothing may hold ANE_SYS or the child power states again, and the ANE CPU and sub-block power states must read off now (PMGR, readable in any power state). We hold ANE_SYS until the power-down puts it, so no earlier OFF can count. Only then does the cold boot clear and reuse the pool, IPC ring, heap and heap tail, copy TEXT and DATA from the kernel-held preload again (their digests checked), and does ane_h16_session_recovered() end the quarantine and give back the memory of programs closed while it lasted; the open programs are then replayed behind their handles. The power-up before the boot repeats the cold PMGR, PWGATE and DART checks of every boot. Without that proof the session stays quarantined, its memory held, and the next sleep tries again; a resume that cannot prove it does not boot the engine at all. A boot or replay that fails after the proof quarantines the engine until reboot, as any failed boot does. debugfs ane-h17/<dev>/ gains recoveries and recover_failures. Signed-off-by: Bartosz Nitka <niteria@gmail.com>
Every runtime recovery of a quarantined H17 session powers the engine off under its firmware and boots it again, at once and as often as the session is quarantined. On the J700 a client that kept loading programs past the shared quota had its session quarantined again 0.6-1.2 s after each recovery: eight recoveries in six seconds, each a forced ANE_SYS power cycle, and right after the eighth the whole SoC locked up (no network, a hard reset needed). Single recoveries had worked all day. Limit them. The first recovery in a 60 s window runs at once; each later one in the window waits 1 s after the one before, twice that for every recovery already in the window, at most the window. A sixth hang within the window stops runtime recoveries: the engine stays quarantined, requests fail with -EIO and nothing reaches it, until a system sleep powers it off and boots it again (which also resets the limit). While a recovery waits out its backoff the session stays quarantined the same way; a sleep drops the waiting recovery and recovers the engine itself. Recoveries are logged with their place in the window, a backoff and the stop each once; debugfs recover_limited counts refused recoveries. The storm above would have recovered at 0, 1, 3, 7 and 15 s and stopped at its sixth hang. The limit is a pure state machine in ane_fw_cold.h. KUnit: the storm's timeline, backoff doubling and its cap, the sliding window, the burst bounds, a clock that went back, and reset. Signed-off-by: Bartosz Nitka <niteria@gmail.com>
A runtime recovery booted the engine again as soon as genpd reported ANE_SYS off: the proof was followed by the cold boot's power-up at once, so the domain stayed off for about a millisecond. Every other power cycle of this engine keeps it off for seconds (an idle park for at least its autosuspend delay, a system sleep for the whole sleep). On the J700 a storm of eight such recoveries in six seconds, each with ANE_SYS back on within a millisecond, ended in a SoC lockup. Record when genpd's OFF proved the hung engine gone and keep ANE_SYS off for 100 ms from then before the proof is checked and the engine booted again. The recovery log line gives the time waited. KUnit: the wait from the OFF, with no OFF recorded, one in the future, and no minimum. Signed-off-by: Bartosz Nitka <niteria@gmail.com>
After a recovery's cold boot the session reopened at once: open programs were replayed and waiting requests went in right after the firmware's startup commands, with nothing checked of the engine the power cycle left behind. On the J700, after the eighth recovery of a storm a waiting client sent LOAD and CREATE within a millisecond of the reopen; its log ends at the third LOAD, where the SoC locked up. Before the replay and before the session reopens, serve what the new firmware posts (its own SHAREDMALLOCs) until it has been quiet for 100 ms (at most a second more), then read the engine: ANE_SYS and the ANE CPU power state on, no DART fault, and the transport not failed. The sub-block power state and CE are not judged: the running firmware gates the engine itself. Requests wait in ane_h16_session_enter() meanwhile, as during the rest of the recovery. An engine that reads anything else fails the recovery and is quarantined, with what it read logged. A system sleep that recovers a quarantined engine takes the same step. KUnit: the health check, field by field; and at the session level, what the gating relies on: while a recovery waits out its backoff the quarantined session refuses requests with -EIO and no traffic; while it runs, a client's LOAD waits, also through the cold boot and the replay, and goes through on the new firmware only once the session reopens. Signed-off-by: Bartosz Nitka <niteria@gmail.com>
DjDeveloperr
approved these changes
Nov 24, 2026
DjDeveloperr
left a comment
Contributor
There was a problem hiding this comment.
Formal §1–§6 pre-PR review at verified head 3963bf32061eeadc813163dee370cdf80ae51348.
- Code, concurrency & safety (§2–§3):
- Bounded per-port DART-idle polling (
ane_fw_dart_idle_wait, 100 ms/port) before cutting power prevents mid-flight DMA abort; busy DARTs or stuck power words safely abort runtime recovery and defer to deep system sleep. - Positive off-proof (
ane_fw_hung_gone():hung_downrelease ->GENPD_NOTIFY_OFF+ane_fw_sys_offacquire/release ->hung_off_at+ live PMGR CPU/sub-block check) ensures no pool/IPC/heap/DATA or closed-program memory is reused while old firmware could still touch it. - Runtime PM and sleep interaction are deadlock-free:
ane_fw_recover_work()runspm_runtime_get_noresume()+pm_runtime_barrier()beforeb->lock,ane_fw_staged_runtime_suspend()returns-EBUSYcleanly while quarantined, andPM_SUSPEND_PREPARE/ane_fw_staged_exit()callcancel_delayed_work_sync(&b->recover)outsideb->lock. - Circuit breaker (
5in60 s,1 sdoubling backoff capped at window, reset on sleep),100 msANE_SYSoff hold, and100 mspost-boot quiet settle + health check (ane_fw_recover_settled()) are cleanly separated into pure KUnit-tested helpers (ane_fw_cold.h).
- Bounded per-port DART-idle polling (
- §1 / §4 / §6: Zero model/board gating, zero new module parameters, all 4 commits carry human author/committer + human
Signed-off-by:only (0 AI trailers),checkpatch.pl --strict0/0/0,W=10 warnings,host-testsSUCCESS(MERGEABLE/CLEAN). - §5: KUnit
270/270+ live J700 exact-head default-cmdline test covering runtime recovery, open-program replay, 6-hang burst cap/backoff, sleep recovery + limit reset, post-reset recovery, idle park (1024/1024 exact max_ulp=0,0failed units,0unexpected errors).
Approved for the merge train.
Assisted-by: LLM (Gemini 4 Neon)
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.
Problem
On H17 ANE, a request that never completes quarantines the session (
h16_fail()), and the backend has noops->hunghandler: every laterLOADfails with-EIOuntil reboot. System sleep does not clear it either — the sleep path sends aSTOPthe hung firmware never answers, powers the engine off on the deep path and cold-boots it from the preload on resume, but never ends the session quarantine so the freshly booted firmware sits unused.This replaces draft PR #1768 on top of
integration/aurora(which now includes runtime PM / idle parking from #1863), incorporating @RyanTheTide's review feedback:hung_stop,hung_settle_ms,recover_burst,recover_window_s,recover_backoff_ms,recover_off_ms,recover_quiet_ms).ane_fw_dart_idle_wait(), 100 ms per port) so DMA is not cut off mid-flight.ane_fw_staged_runtime_suspend()returns-EBUSYfor a quarantined session without callingpm_runtime_mark_last_busy()or permanently quarantining the backend, and runtime recovery hands the device back to runtime PM idle parking once recovered.Change
Four commits on
drivers/accel/ane/(ane_fw_cold.c,ane_fw_cold.h,ane_fw_cold_test.c,ane_h16_program_test.c):accel/ane: h17: recover a hung engine instead of keeping it until rebootops->hungto queue recovery work (ane_fw_recover_work()), closing session admission, polling every ANE DART port for idle (up to 100 ms per port), and powering the engine down using the existing sleep/park power-down sequence (sub-block, PWGATE + ack, CPU,ANE_SYSvia genpd; no new MMIO writes). Busy DART ports or a stuck power word fail runtime recovery and leave recovery to the next system sleep.ane_fw_hung_gone():GENPD_NOTIFY_OFFafter power-down began withANE_SYSPMGR actual state off, no active power references, and CPU + sub-block PMGR off) before clearing pool/IPC/heap/heap_tail, reloading digest-checked preload TEXT/DATA, ending session quarantine (ane_h16_session_recovered()), and replaying open programs behind their handles.STOP, request deep sleep, prove off on resume, cold boot and replay) and return-EBUSYfromane_fw_staged_runtime_suspend()while quarantined.recoveriesandrecover_failuresindebugfs/ane-h17/<dev>/.accel/ane: h17: limit hung-engine recoveriesane_fw_cold.hwith fixed circuit-breaker policy (max 5 recoveries in a 60 s sliding window, doubling backoff starting at 1 s) to prevent an ANE_SYS power-cycle storm from locking up the SoC (reproduced on J700 at 8 recoveries in 6 s). A 6th hang within 60 s keeps the session quarantined (-EIO) until the next system sleep, which recovers the engine and resets the limit.recover_limitedindebugfs/ane-h17/<dev>/.accel/ane: h17: keep a hung engine off before booting it againANE_SYSoff hold afterGENPD_NOTIFY_OFFbefore re-powering the engine during runtime recovery (matching normal power-cycle hysteresis rather than ~1 ms back-to-back cycles).accel/ane: h17: let a recovered engine settle before requestsANE_SYS/CPU PMGR on, zero DART error bits, and healthy transport (ane_fw_recover_settled()) before replaying open programs and reopening the session.Fixed constants rationale
ANE_FW_HUNG_DRAIN_MS(100 msper DART port): matches macOS's DART-idle check before power-down with bounded polling so in-flight DMA finishes beforeANE_SYSis cut.ANE_FW_RECOVER_BURST/ANE_FW_RECOVER_WINDOW_S/ANE_FW_RECOVER_BACKOFF_MS(5in60 s,1 sdoubling backoff): crash-loop circuit breaker sized below the J700 storm failure threshold (8 rapid cycles in 6 s locked up the SoC) while allowing transient hangs to recover immediately.ANE_FW_RECOVER_OFF_MS(100 ms): minimumANE_SYSoff-time hysteresis so runtime recovery does not bounceANE_SYSback on within ~1 ms.ANE_FW_RECOVER_QUIET_MS(100 ms): post-boot firmware settle quiet period before replaying programs and admitting waiting clients.Testing
Local checks & unit tests
scripts/checkpatch.pl --strict --git 056cd33ebfde..HEAD: 0 errors, 0 warnings, 0 checks across all 4 commits.W=1builds ofdrivers/accel/ane/(CONFIG_DRM_ACCEL_ANE=y,=m, and!CONFIG_PM): 0 new warnings.drivers/accel/ane/boot.kunitconfig): 270/270 passed (including 7 new tests:ane_cold_hung_gone_test,program_sleep_gate_quarantine_test,ane_cold_recover_storm_test,ane_cold_recover_backoff_test,ane_cold_recover_off_test,ane_cold_recover_settled_test,program_recover_gate_test).tools/asahi/ane-tm-transient-fault-tests.py: PASS.Live hardware testing — MacBook Neo (J700 / T8132)
Booted
7.3.0-pr-bdf20d05f7b4cleanly on the default kernel command line (zero ANE/debug boot params, zero out-of-tree patches) via a one-shot test entry (pr-ane-hung-recover), then restored baseline gen 69 afterwards.400000000.anestartssuspended(recoveries=0,recover_failures=0,recover_limited=0).add1024(1024/1024 exact, 0 ulp), triggered hang on a second fd (ETIMEDOUTin 3.00 s) → runtime recovery completed in229 ms(off 82 ms,101 msquiet settle,1 programs replayed,recovery 1 of 5 within 60 s) → same openadd1024fd ran0.81 ms,1024/1024 exact, 0 ulp→ closing fd cleanly stopped firmware (status 0x6e) and parked (suspended).rtcwake -m mem -s 8: deep sleep cleanly parked on resume (resume ok: parked until the next request), reset recovery window, and unparked + replayedadd1024(18.75 ms,1024/1024 exact, 0 ulp).backs off 733 ms), 5/5 (backs off 4745 ms);add1024bit-exact (1024/1024 exact, 0 ulp) after every recovery.5 recoveries within 60 s: no more runtime recoveries; quarantined until the next system sleep,recover_limited=1,recover_failures=0); subsequentH16_EXECimmediately failed with-EIO.rtcwake -m mem -s 12while quarantined: deep sleep ran (hung engine powered off for system sleep (0)), resumed withquarantined engine recovered by system sleep; recovery limit reset(firmware ready 117 ms,1 programs replayed), and the still-openadd1024fd ran0.49 ms,1024/1024 exact, 0 ulp.227 ms,off 81 ms,recovery 1 of 5 within 60 s, 0 ms backoff),add10240.50 ms,1024/1024 exact, 0 ulp, then cleanly parked (suspended). Final counters:recoveries=8,recover_failures=0,recover_limited=1.0 failed systemd units,0 AVC / SELinux N/A(lsm=landlock,yama,bpf),0 unexpected ANE/DART/PMGR kernel errors(only the intentional burst-cap line at hang 6).Full J700 live test output and ANE/sleep dmesg excerpt
Still to run
ane_fw_cold.cpath with zero model gating.Pre-PR Checklist
Signed-off-byonlycheckpatch.pl --strict: 0 errors, 0 warnings, 0 checksW=1arm64 builds (=y,=m,!CONFIG_PM): 0 new warningsboot.kunitconfig, 270/270) and live J700 hardware test pass with baseline restoredAssisted-by: LLM (Gemini 4 Neon)