Skip to content

accel/ane: recover T6000 and T8112 engines after a hung job - #1651

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

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

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

A job that hangs on the Neural Engine of an M1 Pro/Max (T6000) or M2 (T8112) no longer needs a reboot. The driver recovers the engine and the next job runs.

T6000 (ane.ko, direct task manager)

#1446 kept the engine wedged after a hang without a completion event, because every job after the recovery hung the same way. The task-manager file does not survive the recovery power cycle; it comes back at its reset values. The retained-state drain then cleared TQ_EN bit 13 together with the enable bit. Without bit 13 the task manager never dispatches: the next descriptor sits pending in its queue while TM_STATUS reads idle. The drain now clears only the enable bit.

Before the power cycle the driver also tries the per-queue abort (START + queue number, then queue idle and pending count zero, then both descriptor slots and the ownership word are cleared). A task stalled below the task manager never lets it be taken, and the power cycle stops it instead. The drain now clears both descriptor slots before the ownership word. On T6000 the engine is wedged until reboot only after three recoveries in a row without a completed job. tm_abort=0 turns the abort off.

T8112 (ane_t6021, firmware)

After a hung CALL, clearing RUN does not stop the ANE CPU (CPU_STATUS stays RUNNING|IDLE). An unplanned restart now holds the CPU in its ANE_SYS_CPU power-state reset, releases it only once every ANE domain reads off, and cold-boots the firmware. Planned restarts never take this path. forced_asc_stop=0 selects the old behaviour. The DT gains resets = <&ps_ane_sys_cpu> on the T8112 ANE node, and the binding requires it there.

Tests

  • KUnit (arm64, accel/ane suites): 262/262, including the new ane-tm-recovery and ane-t6021-lifetime cases. checkpatch --strict clean. dt_binding_check reports nothing new for apple,ane.yaml, and dtbs_check is clean for the T8112 DTBs.
  • M1 Pro, fleet67 with this ane.ko loaded at run time: 5 rounds of a deliberately hanging 70-task program (-110, no event), each followed by a 1-task conv (relL2 2.2e-4 vs float64, 50 runs), a 3-task program (relL2 3.0e-4) and MobileNet classification of 20 photos (top-1 and top-5 equal to the CPU on all 20). Then two hangs back to back, followed by the same good jobs. 0 DART faults, wedged 0 throughout, no reboot. Speed unchanged: MobileNet p50 485 us before (stock module), 485 us with this module, 484 us after 7 hangs. The 99-task MobileNet ran at 3673-3674 us in all three.
  • M2: see below.

T8112 exposes the ANE_SYS_CPU power-state reset to stop and cold-boot a
coprocessor that does not reach STOPPED after RUN is cleared. Describe that
reset and require it for this compatible.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Connect the ANE consumer to the ANE_SYS_CPU power-state reset so the driver
can force-stop a hung firmware CPU before a verified power cycle.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
When an unplanned H14 CALL hang leaves CPU_STATUS running after RUN is
cleared, assert the optional CPU power-state reset instead of abandoning
recovery. Keep that state across failed transactions. Release reset only
after every ANE domain is proven off. Cold-boot the firmware when power
returns.

Planned shutdowns retain their POWER_DOWN, WFI and STOPPED proof and never
use the forced path. The run-time parameter can select the former behavior.
KUnit covers forced success, reset failure, planned exclusion and the
disabled path.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
linux#1446 kept a T600x engine wedged until reboot once a job hung
without a completion event, because every job after the recovery hung
the same way. The task-manager file was thought to survive the power
cycle. It does not: after the cycle it reads its reset values (nothing
committed, no valid descriptor slot, TM_STATUS idle). The retained-state
drain then cleared TQ_EN bit 13 along with the enable bit. That bit
reads set after every power-on, and without it the TM never dispatches:
the next descriptor stays pending in its queue while TM_STATUS reads
idle, so that job timed out too.

Clear only the enable bit (12) in the drain; the re-arm sets it again.

Before the power cycle, abort the hung queue in the task manager while
the engine is still powered: write the queue number with START to the
abort register, wait for START to clear, then for the queue to report
hardware idle with no descriptor pending, and only then invalidate both
descriptor slots, clear the ownership word and restore the queue
priority. Every poll reads the DART latch before the engine. A task
stalled below the task manager never lets the abort be taken; the power
cycle stops it then. The tm_abort parameter (default on) turns the
abort off.

A hang without an event is recoverable again on T600x. The engine is
wedged until reboot only after three recoveries in a row without one
completed job. T8103 keeps its single recovery.

The drain also cleared only the first descriptor slot, and cleared the
ownership word before it. Clear both slots, then the ownership word, as
the normal completion path does.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide deleted the fix/ane-hang-recovery branch November 12, 2026 07:56
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