Skip to content

accel/ane: t6021: boot the firmware after system resume, not inside it - #2138

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
sleepdrain/ane-deferred-resume
Nov 17, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
sleepdrain/ane-deferred-resume

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What this does

On the T8112 (M2), ane_t6021's system resume cold-boots the Neural Engine firmware inline, which takes about 1.2 s. That is nearly all of the device-resume time on a J413: every s2idle wake spent 1.29 s in PM: resume devices, and ane_t6021's platform_pm_resume took 1.20 s of it (pm_print_times).

  1. Boot the firmware after system resume, not inside it. Resume now only queues the existing freezable restart work, the one an aborted suspend already uses. The work boots the firmware once user space runs. A client that submits first finishes the restart itself in ane_rtclient_admit(), as before. The power cycle is still limited to a CPU whose domain stayed on through the sleep; a cold CPU boots directly, as the inline path did. Probe holds a runtime-PM reference for the firmware lifetime, so the domains stay up between resume and the work.
  2. Don't report a pending sleep restart as wedged. With the boot outside resume, user space can observe the pending restart. The wedged attribute read it as a wedge for about 1.2 s after every wake: the restart transaction raises recovering at suspend, and ane_t6021_pm_restart_deferred() marked the device FAILED while it booted. Now wedged ignores recovering while a sleep restart is pending, the pending flag is cleared only after the boot, and the device stays SUSPENDED until the restart's outcome is known (FAILED only on failure). Submitters still wait on the firmware mutex the restart holds.

Tested

J413 (M2), production kernel 7.3.0-aurora-fleet74 with ane_t6021 built from the same source plus these two commits, loaded on a one-shot boot (modprobe.blacklist=ane_t6021, then insmod):

stock module patched
PM: resume devices took (rtc s2idle) 1.277-1.294 s (5 wakes) 0.120-0.141 s (5 wakes)
MobileNet layer + full-relu net after the wake identical identical (relL2 9.5e-5 / top-5 = reference)
  • Patched paths covered: a job right after the wake (admit finishes the restart), a job 30 s later (the work did it), and a job after a pm_test=devices abort (CPU domain stayed on, so a power cycle first). wedged stayed 0. No deferred-restart failures, sequence errors or DART faults, 0 AVC denials.
  • With only the first commit, a tool that checks wedged before submitting skipped the engine for about 1.2 s after each wake. The second commit fixes that.
  • KUnit ane_t6021_pm_test (UML): 16/16 pass (ane-pm-recovery 6, ane-h14-sleep 7, ane-fw-ids 3). New check: the state the deferred restart callback sees is SUSPENDED.
  • checkpatch --strict clean; W=1 clean on the changed files (arm64, LLVM).

🤖 Generated with Claude Code

RyanTheTide and others added 2 commits November 17, 2026 21:15
On the T8112 (M2) the ANE firmware cold boot in ane_t6021's system
resume takes about 1.2 s, which is nearly all of the machine's device
resume time: on a J413 every s2idle wake spent 1.29 s in "PM: resume
devices", 1.20 s of it in ane_t6021's platform_pm_resume.

Resume now only queues the existing freezable restart work, the same
one an aborted suspend already uses. The work boots the firmware once
user space runs, and a client that submits first finishes the restart
itself through ane_rtclient_admit(), as before. The power cycle stays
limited to a CPU whose domain did not go off during the sleep; a cold
CPU boots directly, as the inline path did. Probe holds a runtime PM
reference for the firmware lifetime, so the domains stay up between
resume and the work.

Measured on a J413 (fleet74 kernel, patched module): resume devices
1.29 s -> 0.104 s over four s2idle wakes; ANE inference results are
unchanged after each wake.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the firmware boot moved out of system resume, the restart a sleep
leaves behind finishes with user space running, and the wedged
attribute counted it as a wedge for ~1.2 s after every wake: the
transaction raises recovering at suspend and clears it only when the
new firmware is up, and ane_t6021_pm_restart_deferred() marked the
device FAILED while the boot ran. A tool that checks wedged before
submitting gave up on a healthy engine.

A pending sleep restart is not a wedge: the first client finishes it
in ane_rtclient_admit() before any command is accepted. So wedged no
longer counts recovering while that restart is pending, the pending
flag is cleared only after the deferred boot, and the device stays
SUSPENDED until the restart's outcome is known, becoming FAILED only
when it fails. Submitters still wait on the firmware mutex the restart
holds. The kunit case checks the state the restart callback sees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide
RyanTheTide merged commit dcce0e7 into integration/aurora Nov 17, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the sleepdrain/ane-deferred-resume branch November 17, 2026 10:38
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