Skip to content

accel/ane: add bounded timeout recovery for H13 and owned H14 - #692

Closed
RyanTheTide wants to merge 8 commits into
integration/aurorafrom
fix/ane-hang-recovery
Closed

RyanTheTide wants to merge 8 commits into
integration/aurorafrom
fix/ane-hang-recovery

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

A timed-out ANE job currently leaves the engine quarantined and its resources pinned until reboot. H13 recovery force-suspends suppliers while their consumer remains active, which can keep parent domains powered; its log incorrectly promises that module reload restores service.

H13 now uses one job deadline across fault drains and a serialized runtime-PM reset: suspend the consumer, finish supplier suspension, require physical PMGR and attached-genpd power-off (including SYS_CPU), resume and re-arm the task manager. The failed job returns its original error. Live BO mappings survive for resubmission; preserved mappings and the exceptional module reference are released only after verified recovery. Speculative retained-error-register writes and the misleading reload message are removed.

The Linux-owned H14 legacy profile stops its owned ASC CPU, cycles domains through genpd, verifies physical power-off, and restores a cached pristine image through the existing fenced boot sequence. READY/DONE, ChMan, host ACK and CONFIG_GET must validate before quarantine clears. Old firmware arenas and closed BOs retain metadata until restart succeeds; existing resource limits still charge retained arenas. Opaque kernel program/process IDs cannot alias reused firmware IDs, so clients reload programs after reset. Borrowed firmware, RTKit mode and later-generation ownership remain fenced. H14's existing active-firmware/domain lifetime references remain; this does not claim normal H14 module unload while firmware is active.

Validation:

  • Both drivers and recovery test objects compile for arm64.
  • 9/9 KUnit tests pass in QEMU: real runtime-PM links and error unwind, plus identifier non-reuse/exhaustion.
  • Final H13 fleet12-compatible module builds pass with the exact running-kernel config.
  • The deterministic fixture generator confirms normal compiler refusal and produces the pinned public-encoder hang candidate. The explicit ABI 1 test keeps original fds/mappings, requires three timeouts and sixty fresh bit-exact outputs, poisons logical output lanes, and checks boot identity and module references.

Silicon qualification is pending. The M1 Pro experiment awaits exclusive controller approval; no recovery-without-reboot result is claimed yet. H14 restart also needs hardware qualification. This PR remains draft and is not ready to merge.

Suspend the ANE consumer before its domain suppliers, verify the engine islands actually power off, and restore its runtime PM reference on every exit. Avoid the system-sleep force helpers and speculative retained task-error writes. Keep DMA backing and the exceptional module pin until recovery is verified.

Use one deadline across H13 fault drains and H14 command ACK/finish waits. Add an explicit destructive H13 recovery test and a deterministic fixture generator using the licensed public compiler. Document the remaining H14 firmware ownership and stale-ID work; H14 reset remains quarantined.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Share the runtime-PM cycle independently of task-manager MMIO and test it against real runtime-PM supplier links. Cover repeated and single-domain cycles, consumer and supplier suspend errors, a missing off acknowledgment and resume failure, including restoration of the caller reference.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
The packaged tools contain a static libane, so a ctypes test cannot rely
on a system shared library. Use the documented ABI 1 buffer and submit
ioctls directly. Keep both fds, GEM handles and mappings alive across all
three resets, pin both public fixture hashes, and provide device-free
container validation before the destructive run.

Also depend on DRM_ACCEL for traversal of the PM KUnit test directory.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Exercise the malformed convolution with fp16 one inputs so the test
requests MAC work rather than relying on an all-zero activation path.
The input and weight bytes are deterministic; only the add fixture is
used as a numerical oracle.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
The SET window covers the engine islands but not their SYS_CPU parent.
DART suppliers suspend asynchronously after the ANE consumer drops its
references. Require every attached genpd, including SYS_CPU, to report
off before resuming the consumer; otherwise that resume can race the
DART idle work and keep the task-manager register file powered.

Use only the genpd provider API and always-accessible PMGR reads. A
shared domain that cannot turn off leaves recovery failed and preserves
the DMA safety pin.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Change the add inputs for each call and poison its 64 logical output
lanes before submitting. Zero the unused padding, which need not be
written by the engine. Comparing the complete tile with the oracle now
rejects a stale completion even when the previous call was correct.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Fence commands and buffer creation, stop only the Linux-owned ASC CPU,
and power-cycle every domain through the same runtime-PM transaction.
Verify the physical PMGR states and repeat the probe access gates before
restoring the cached pristine image and the existing fenced boot flow.
Require READY/DONE, ChMan validation, host ACK and CONFIG_GET before
accepting work again. Unsupported ownership profiles remain quarantined.

Retain metadata for closed firmware-visible BOs and old boot/MALLOC
arenas. Reclaim old resources only after validated restart; charge
retired arenas to the existing limits and bound failed-boot retention.
Release the old CPU pin only after quiescence and acquire its replacement
before any boot write. The existing domain-link lifetime pin remains.

Use opaque kernel program/process IDs, independent of reused firmware
wire IDs. Invalidate the cache across restart without resetting the
allocator, so clients reload rather than executing a stale identifier.
Add KUnit non-reuse/exhaustion checks and matching reset diagnostics.

Validated on buildbox: arm64 driver objects and 9/9 KUnit tests in QEMU.
H14 silicon qualification is still required; no H14 hardware was changed.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide RyanTheTide changed the title accel/ane: repair runtime-PM cycling for H13 timeout recovery accel/ane: add bounded timeout recovery for H13 and owned H14 Oct 31, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Three wedges on the M1 Pro (T6000) tonight, all on kernels without this PR (fleet12d, fleet12e), each needed a reboot because rmmod ane fails while a client holds the device.

Signature each time

ane 285c04000.ane: tm completion failed: -110, finish lines=0 (q4 nid=0x40)    (or -5, finish lines=0)
ane 285c04000.ane: recovering: power-cycling engine partitions
ane 285c04000.ane: recovery: tm not idle after reset: 0x0
ane 285c04000.ane: recovery failed; preserving resources until module reload or reboot

The same task error with finish lines=1 recovered fine every time (three times tonight), only finish lines=0 latched. Note the idle check prints 0x0 and still says not idle, worth checking that predicate while you're in there.

Natural reproducers, in case they help qualify this on silicon

  1. A real-weight MobileNetV1 linked program from mil-hwx-compiler PR drm/apple: don't latch ->crashed when the poweroff clear swap times out #5 whose stride-2 1x1 layers used the zero-skipping weight section with actual zero weights. It wedges on its very first submit, deterministically. That compiler path is being changed so normal builds won't emit it anymore, but the old package is a good reproducer and I can hand it over.
  2. The PR drm/apple: don't latch ->crashed when the poweroff clear swap times out #5 linked MobileNetV1 with the CPU boost off (boost_idle_ms=0) hits a -5, finish lines=0 within a few hundred submits. That one comes from a missing inter-task dependency in the compiler, also being fixed there.

Happy to run the recovery selftest plus reproducer 1 on the M1 Pro when there's a build of this branch for fleet12e.

Recovery refused to restart whenever TQ_EN bit 13 was set after the
partition power cycle, reading it as "task manager still halted". On
the M1 Pro that bit is set on every healthy runtime resume as well:
TQ_EN reads 0x3000 and TM_ERROR1 0x22222222 each time the engine comes
back from autosuspend. So the check failed every recovery and left the
engine wedged until reboot. Drop it.

The tm/tq register file on T600x also keeps its state through the
acknowledged power-off, and through PMGR reset pulses on every ANE
domain (ane_sys, sys_cpu, set0, base, set1-4), so a power cycle alone
does not clear what a failed task latched. Bring back the
retained-state drain for SoCs whose descriptor says the file is
retained (T6000/T6001), based on omarchy-ane's ane_tm_drain_retained
by Joshua Warren (MIT). Before it was removed, the drain recovered
every "-5, finish lines=1" task error seen on the M1 Pro. A wedge the
drain cannot clear still fails the idle check and stays wedged, with
no reboot loop.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Silicon result on the M1 Pro (T6000), and a fix pushed as a14c10c.

Test kernel 7.3.0-aurora-fleet12e-ane692 = fleet12e plus this branch at 71fa8e9, one-shot booted. Reproducer is the real-weight MobileNetV1 package I mentioned above, which times out on its first submit (tm completion failed: -110, finish lines=0).

71fa8e9 as is does not recover. The power cycle works (engine power-off actual=0x0 rc=0, then the islands read 0xffffff), but recovery stops at task manager still halted after power-off and the engine stays wedged. The sysfs reset retry does the same. I also pulsed PMGR RESET+DEV_DISABLE by hand on every ANE domain (ane_sys, sys_cpu, set0, base, set1-4) before a retry, and nothing changed.

The reason is that TQ_EN bit 13 isn't a halt latch on this SoC. A diagnostic build logged TQ_EN on every healthy runtime resume from autosuspend, and it always reads 0x3000 with TM_ERROR1 0x22222222. So the check refuses every recovery. The tm/tq file is also retained through the power-off, which is what the old tm_retention drain was for.

a14c10c drops that check and brings back the retained-state drain for T600x (based on omarchy-ane's ane_tm_drain_retained, MIT, credited in the code). With it, same boot, no reboot in between:

round reproducer recovery smoke after (bit-exact 1x1 conv)
1-5 -EIO, -110, finish lines=0 tm recovered: idle, accepting work again, wedged 0 20/20 each

What the registers did each round: TQ_EN 0x3000 and STATUS 0x0 before the cycle, STATUS back to 0x1 after the power cycle with the error words at their healthy values, TQ_EN 0x0 after the drain, then 0x1000 and idle after re-enable, matching the fresh probe status. About 0.5 ms from failure to recovered.

Not re-run on this commit yet: the KUnit set from this PR and T8103. I didn't change the T8103 path apart from no longer refusing on bit 13, which has no evidence behind it there either. Checkpatch strict is clean. The diagnostic logging isn't in the commit.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The H13 part of this branch, plus the drain fix, is now #717, rebased on aurora-wip (this branch conflicts with aurora-wip after #684 and the H16 platform work). Leaving this PR for the H14 firmware restart (71fa8e9), which still needs an M2 run.

RyanTheTide added a commit that referenced this pull request Oct 31, 2026
accel/ane: H13 recovery without reboot (H13 part of #692, on aurora-wip)
@RyanTheTide
RyanTheTide changed the base branch from aurora-wip to integration/aurora November 2, 2026 23:16
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing as superseded: all eight commits landed in integration/aurora as revised versions with the same subjects (e.g. 5c93b77 'power-cycle runtime PM suppliers after a bounded job timeout', b5ba418 'exercise the recovery PM transaction with KUnit devices', 68e1aee 'restart owned H14 firmware after a command timeout', 51c8db3 'drain the retained task manager on T600x recovery', plus the selftest commits). 92% of this PR's added lines are byte-identical in integration 43c790f; the rest are the revisions. Deleting the head branch fix/ane-hang-recovery (tip a14c10c, no open PR based on it). Overnight merge train, 11-07.

@RyanTheTide RyanTheTide closed this Nov 7, 2026
@RyanTheTide
RyanTheTide deleted the fix/ane-hang-recovery branch November 7, 2026 11:05
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