Repository navigation
third_party/amdxdna: no runtime suspend under a live context, and a dying context must not fail the resume (#1051) - #1295
Conversation
…ive context; a dying context must not fail the resume)
|
ready for review at 862dc9a (pi-kernel-74, driver side of #1051). Part of #1051 — cl-1051 leads and its PR carries the Fixes line; this one is the amdxdna half. Measured on strixhalo in two swap windows, each rolled back: 614 ladder 3/3 wedge -> 3/3 PASS (0 TDR), XRT regression PASS, close-while-suspended A/B clean on the 0008-only build (0 Resume failed lines where the shipping module prints them), driver restored to |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Reproducibility check from
|
third_party/patches/amdxdna: keep the array out of runtime suspend under a live context (#1051)
Two carried amdxdna patches for engine#1051, on top of the series this directory
already ships (
0001, 0002, 0004, 0005, 0003).What the issue is
A dx request that arrives after the NPU's own runtime suspend wedges the array:
The c30/c31 images hide it with the keep-awake rule (one runtime-PM reference
held by the payload while a model is loaded). That is a mitigation in the
caller: every other consumer of the array — a second serve, the demo, anything
that opens a context and then idles 5 s — still hits it.
Root cause, from the driver's own log
Reproduced on strixhalo with the c29 payload + the board's model,
power/control=auto,drm.debug=0x2, 3/3 iterations, on the shipping module (EE1F36A2B9BA294CE11AD80):The recreated context gets the same messages, the same firmware context id and
the same host-buffer address as the create that worked, and the restart returns
0. So no driver step that a firmware message can carry is missing; the firmware
accepts the whole restore and then refuses to dispatch into it.
Ruled out on the same box: the resume handshake and the create path (XRT's own
NPU
validate— a full context + submit path — passes 5/5 including runs thatstart with the device suspended,
restarts 0), and the dispatch payload (acontext created after the same resume works).
Config cunever appears ineither path because this route has
hwctx->cus == NULL, so CU configuration isnot the missing piece.
The fix
0009 — keep the array awake while a context exists (aie2_ctx.c, +35/−0).
A runtime-PM usage reference is taken at the end of a successful
aie2_hwctx_init()(pm_runtime_get_noresume()) and released inaie2_hwctx_fini()(pm_runtime_put_autosuspend()). Only the usage countmoves: nothing is woken out of order and the create path is unchanged. A device
with no contexts still autosuspends after the existing 5 s delay.
Effect: the array can no longer enter the state whose exit is broken, for any
client, without every client having to know to hold the device awake.
0008 — a dying context must not fail the device resume (aie2_ctx.c +
aie2_pci.c, +33/−4).
aie2_hwctx_restart()returns-ESRCHfor a context whoseheap address is already gone (the process's mm is torn down before its fds are
closed). That error failed the whole hwctx walk, and
aie2_hw_resume()thenbroke out of the client loop, so every later client was left with no firmware
context — and
pm_runtime_resume_and_get()reported failure for a resume thathad started the hardware, after which
amdxdna_pm_resume_get()marks a runningdevice suspended. That is the board's own line:
Measured
BEFORE (shipping module
EE1F36A2B9BA294CE11AD80,power/control=auto):code 614: state 8, run 0 of 28),3 TDRs, log above —
~/lb/k74-ab/i1051-before2/.~/lb/k74-ab/i1051-xrt-before/.AFTER (candidate
F87D0BDF248067862F83BA3):power/control=auto):3 PASS / 0 FAIL / 0 VOID, 0 TDR, 0
amdxdnaerrors — and the log shows why: the 20 s idle window containsno suspend at all (no
dpt_suspend, noDestroyed fw ctxin the gap) and norestarted, retline anywhere in theladder, so the array never entered the state whose exit is broken.
~/lb/k74-ab/i1051-cand-1639/rc 0)0008-only buildF77B98053D0D680105B251F(with0009installed the device cannotsuspend, so that path is unreachable and 0008 needs its own window): arm
control=autoclean — the process reallydid exit with
runtime_status=suspendedand the log shows the suspend (Destroyed fw ctx+dpt_suspend) followed byaie2_hwctx_restart: hwctx.798697.15 has no host buffer address (torn down), not restarting itand a completedresume (
dpt_resume_chan: Resumed), with 0Resume failedand 0 "restore data not reclaimed". On the shippingmodule the same arm prints the two
Resume failed: -3lines.~/lb/k74-ab/i1051-close-cand/EE1F36A2B9BA294CE11AD80,SWAP CLEAN,/bootand the initramfsuntouched by the test at every step
Limits, stated rather than discovered later
system suspend (S3), a TDR power-cycle or an admin-initiated suspend, contexts
still come back through
aie2_hwctx_restart()and would still be dead on theirfirst dispatch. Fixing that needs firmware/AMD work; 0008 makes the failure
cost one client instead of every client.
already accepted at the application level (the c30 keep-awake policy); this
moves it where it protects all clients, and the array still suspends once the
last context closes.
module vs the candidate module, same payload, same model, same kernels.
Part of #1051.