You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
amdxdna: one TDR leaves the NPU array unrecoverable on the appliance (hwctx_restart -22, 'restore data not reclaimed'), so a single wedged request needs a reboot #1005
The c21 board's NPU chat failure (amdxdna aie2_legacy_tdr_detect: TDR timeout detected, 2026-11-04 12:34Z) turned
into a dead appliance because the array could not be restarted afterwards. That recoverability half is worth its
own fix, separate from whatever wedged the firmware in the first place (that is #911).
What the board's own log shows (stick /data/logs/20261104T123017-f675126f/dmesg.log)
[325.47] amdxdna aie2_legacy_tdr_detect: TDR timeout detected
[325.47] amdxdna aie2_tdr_work_func: Device isn't making progress
[325.47] aie2_set_cmd_timeout: Context ID: 15, DPU PC 0xffffffff, TXN OP ID 0xffffffff,
Context PC 0x28b060ad, fatal type 0x0
[365.22] aie_send_mgmt_msg_wait: command opcode 0x106 failed, status 0x4000003
[365.22] aie2_send_host_buf_msgs: fw ctx 15 addr 0xffffffffffffffff size 0x4000000
[365.22] aie2_hwctx_restart: Map host buf failed, ret -22
[365.22] amdxdna_pm_resume_get: Resume failed: -22
[365.22] amdxdna_drm_close: Resume failed (-22), pid 30053 restore data not reclaimed
After that the page's retry (20 s later, new request, same process) failed identically inside another 200, and the only
thing that brought the array back was the owner rebooting the box. addr 0xffffffffffffffff is not a plausible host
buffer address for aie2_send_host_buf_msgs, so the restart path is being handed a torn down / never-created mapping.
It is not this payload
The same release payload (engine 98fb79d5df8a3766), the same kernel (7.4.0-rc1-1bit) and the same OOT amdxdna
byte-for-byte (b45b9663…, srcversion EBC78CDA…) answered the board's exact shape on strixhalo twice today —
evict → auto-load at ctx 32768 → thinking ON → 700 tokens, non-streaming (67.3 tok/s) and streaming (537 SSE data
lines, 535 chunks, [DONE], 8 s) — with 0aie2_legacy_tdr_detect lines. Evidence: ~/briefs/TC21-NPUCHAT-FINDINGS.md, strixhalo:~/wt/c21-repro/out-20261104-092005/.
Precedent, and why a ticket does not fix it
~/briefs/TQDQ-STATE.md (2026-11-01) records the same failure body three times in 11 minutes with the same context
id 15 and different pids, while the pid in hwctx.<pid>.15 is only whoever held the dead context at that instant —
and that "more tickets cannot recover this: the device needs a reset at the kernel/driver level (module reload, or a
reboot) before anything can be validated on the array again, because every new process is handed ctx 15 and dies the
same way 45 s later."
Ask (HRX/driver lane)
Make the TDR path recover rather than inherit: destroy/invalidate the wedged hardware context so a new context
gets a fresh firmware context instead of dead ctx 15, and
if the restart genuinely cannot succeed, fail the wedging process loudly (an error the backend can propagate, and a
dmesg line that says "the array is unusable until reload") instead of leaving a device that silently swallows every
later request until reboot.
Either way the appliance's own gate should see it: chat-npu-stream (PR #999) asks the page's shape on the board and
counts aie2_legacy_tdr_detect between turns, so a recurrence will be a red row rather than a user-reported failure.
Driver side: the recoverability half, root-caused — plus a prepared patch (scratch build, not installed, not loaded)
I took this as the driver lane. Short version: the TDR path already has a working recovery and it is gated on the wrong
condition. The gate measures "firmware will not answer a context destroy"; the wedge we are hitting is "firmware answers
everything and never dispatches". So the one recovery that clears it never runs, and every later request inherits a dead
array. The requested fix is not "invalidate the wedged context" (there is no wedged context to invalidate) — it is to make
the stall path do the firmware reload it already implements, and to fail loudly when even that does not work.
1. Root cause, from the board's own capture and the driver source (xdna-driver @ 526c6081)
aie2_tdr_recover_all() (aie2_tdr.c:129-150) does two things: stop every hwctx, then aie2_hwctx_restart() every hwctx.
The power-cycle (aie2_hw_reset(), aie2_pci.c:516 — "recover a wedged NPU via full hardware power-cycle") runs only
when fw_dead is set, and fw_dead is set only when aie2_hwctx_stop() returned -ETIME/-ENODEV
(aie2_tdr.c:110-113).
In the c21 capture, the destroy succeeded: there is no Firmware unresponsive line, and — this is the part that settles
it — there is no hwctx.<pid>.<id> restart failed, ret N line either, which aie2_tdr_resume_hwctx() emits for any restart
error (XDNA_ERR, aie2_tdr.c:139). So at [325.47] the driver stopped the contexts, re-created them, and concluded the
array was recovered. It was not: the firmware report is DPU PC 0xffffffff, TXN OP ID 0xffffffff, Timed out sub command ID: 0, fatal type 0x0 — no dispatch, no transaction, no exception. Control messages still worked; dispatching did
not. That is the state a per-context restart cannot leave, and it is why the page's retry 20 s later failed identically
inside another 200.
ctx 15 is not a leaked context: aie2_destroy_context() sets hwctx->fw_ctx_id = -1unconditionally
(aie2_message.c:404-408), and the firmware hands out the lowest free id, which is 15 again. That is also why the TQDQ note's
"every new process is handed ctx 15" is not an id-allocation bug — a new context on a wedged array is dead on arrival, and Create hwctx failed never appears in the capture because the create succeeds too.
Precedent that this is the gate and not a one-off: four captures, three kernel+module builds (2026-11-01 12:26 ctx 15;
2026-11-02 09:48:51 ctx 8+6; 11-02 09:49:37 the same pair re-firing; c21 board 11-04 08:34:51 ctx 15), all with DPU PC/TXN OP ID all-ones, all with the array dead afterwards, and TQDQ-STATE.md 2026-11-01 records three restart
attempts failing identically.
2. The -22 chain is a second, independent defect (it is what leaks the restore data)
It is the close path, not the TDR path, and it fires because the device was runtime-suspended in the 40 s between the TDR
and the client exiting. amdxdna_drm_close() → amdxdna_pm_resume_get() → aie2_hw_resume() → aie2_hwctx_restart(),
which maps the hwctx heap through amdxdna_obj_dma_addr() (aie2_ctx.c:157-163). Under PASID that is the client VA, and the
VA is gone once the process's VMAs are torn down — so the driver shipped MSG_OP_MAP_HOST_BUFFER (0x106) with addr 0xffffffffffffffff (AMDXDNA_INVALID_ADDR) and the firmware answered 0x4000003 (-EINVAL). The driver could see that
address was invalid before sending it; instead the failure surfaced as Map host buf failed, ret -22 → Resume failed: -22
→ restore data not reclaimed, i.e. the leak is a consequence of shipping an unaddressable mapping, not a separate
firmware state.
The leak itself (restore data for a ctx suspended across a runtime suspend, destroyable only while the device is up) needs a
different ordering fix — not attempted here, flagged below.
Applies clean to the exact shipped tree (git apply --check against ~/wt/xdna-7.4-rc1 = 526c6081 + the 5/5+6/6 crash
fix, i.e. the module this box and the c21 stick run). Four behaviours, each one line of reasoning:
A TDR now does the firmware reload, not only an fw_dead TDR (aie2_tdr.c). fw_dead keeps its own wording; the
stall case gets its own (Array stopped dispatching, power-cycling NPU to recover). aie2_hw_reset()'s existing
rate limiter (one per 60 s, AIE2_HW_RESET_MIN_INTERVAL_MS) still bounds reset storms, and the existing comment's
semantics — "repeated timeouts after that indicate a deeper firmware problem" — become the escalation ladder below.
aie2_hw_reset() reports its outcome (int, -EBUSY when rate-limited) — it has exactly one caller, so this is a
local change, and without it the caller cannot tell "recovered" from "skipped".
A restart refuses an unaddressable host buffer instead of sending 0xffffffffffffffff (aie2_ctx.c): a driver-side
error naming the hwctx, no bogus firmware request, and the close path's leak now has a stated cause.
Recovery failure is loud and sticky (aie2_tdr.c + aie2_pci.h + aie2_message.c + aie2_ctx.c): if the
power-cycle did not happen or any restart failed, the driver logs one line — "NPU array is unusable until the driver is reloaded: TDR recovery failed (…); new contexts and submissions are refused
with -ENODEV" — sets hw_dead, and new contexts and new submissions fail with -ENODEV immediately instead of each
request hanging ~45 s until the next TDR. hw_dead is cleared only by a successful full aie2_hw_start(), i.e. a real
firmware reload.
Resulting ladder: TDR #1 → power-cycle → recovered, work continues. TDR again within 60 s → rate limit → hw_dead → callers
get -ENODEV. TDR again after 60 s → power-cycle again.
4. What I can and cannot claim
Compiles clean: kbuild against the installed 7.4 headers with the same flag set the shipped module was built with
(-DAMDXDNA_DEVEL -DMODULE_VER_STR=…), -j2 under thermal-run.sh, rc=0, 0 warnings, 8 s. amdxdna.ko
14 034 024 B, sha256 fbc877e94ab3bfa7…, srcversion 56AB94758C18FEEC838D18C, vermagic 7.4.0-rc1-1bit. In my scratch
tree (~/wt/xdna-tdr-recover/), not installed, not signed, not loaded. (BTF skipped there because the headers dir has
no vmlinux; the shipped module is built from the full tree and does carry BTF.)
The four behaviours are visible in the compiled objects, so this is not a patch-text claim: pahole puts hw_dead at
offset 408 (0x198) of amdxdna_dev_hdl, and objdump -dr on the scratch objects shows aie2_tdr_work_func.cold: _dev_warn ×2 → amdxdna_hwctx_walk (stop) → _dev_warn → call aie2_hw_reset → amdxdna_hwctx_walk (resume) → movb $0x1,0x198(%r15) (the sticky flag); aie2_hw_start: movb $0x0,0x198(%rbx) (cleared on a real reload); aie2_cmd_submit and aie2_create_context: movzbl 0x198(…) (the fast refusal); aie2_hwctx_restart: cmpq $0xffffffffffffffff,0x1e0(%r13) before the aie2_create_context / aie2_map_host_buf calls (the heap has no
address ⇒ refuse locally).
Not proven on hardware, and I did not pretend otherwise: this is the one path where the reproducer is the wedge
itself, which cannot be provoked on demand — the same c21 payload on this box produced 0 TDRs in two full runs
(TC21-NPUCHAT-FINDINGS.md §5). So the fix is argued from four captures plus the code, not from a before/after run.
Loading it is the owner's call (standing rule for this lane: no module install/load, no force_iova, no parameter
changes). If you load 0007, the proof plan is: run the c21 shape until aie2_legacy_tdr_detect fires (or replay a
capture's conditions), then check three things — (a) the next request after the TDR answers instead of dying 45 s later,
(b) no Map host buf with addr 0xffffffffffffffff ever appears again, (c) if recovery does fail, -ENODEV reaches the
caller and the "unusable until the driver is reloaded" line is in dmesg. Row (a) is the release-relevant one.
What the patch deliberately does not do: reclaim the restore data leaked by a ctx that was suspended across a runtime
suspend and then closed (amdxdna_drm.c:186-196). That needs the close to destroy before the device is resumed, which is a
separate, riskier change; with (3) it at least stops being silent.
5. For the release verdict
Nothing here is a payload problem — that is already established in the findings §5-6, and the driver-side reading agrees: the
array wedges on firmware dispatch, and the reason a single wedge costs a reboot is the gate in §1, not the payload, the
kernel, or the model. Two consequences worth writing down for c21/c22: the appliance's red row (chat-npu-stream, PR #999)
will catch a recurrence, and until a patched module ships, one TDR still means reboot — a retry from the app cannot
succeed, because the array is dead, not the request.
No device touched for any of this: 0 tickets from this lane, GPU never taken, :18097 and npu-serve-keeper untouched, no
module install/load/parameter, no PR (this is a third-party driver tree, so the patch lives with the evidence as with #812),
no merge. Patch + build tree + static evidence: ~/wt/xdna-tdr-recover/; write-up ~/briefs/THRX-FABRIC-STATE.md.
Proof run on the loaded patch (srcversion 56AB9475…): NOT PROVEN — neither PASS nor FAIL, and here is exactly why
Owner asked for three rows. Two are green, the one that decides #1005 is unexercised: in 11 full c21-shaped runs the
firmware wedge never fired, and the one deterministic entry point into the recovery code (the close-after-suspend restart)
turned out to be unreachable on this box in its current state. No rollback is indicated — nothing regressed — but I am not
going to call this PASS, because the recovery path itself has not executed once.
Evidence: ~/amd-oss/hrx-study/evidence/fabric/1005-proof-20261104-102539/ (8 runs, VERDICT.txt, harness + per-run bodies)
and …/1005-close-20261104-103330/ (close-path probe + 3 more runs).
Row 1 — known-answer probe: PASS, bit-identical
p1 shape of the c21 payload (/no_think Reply with exactly: 1BIT OK, 48 tokens, ctx 4096, temperature 0), same payload
identity 98fb79d5df8a3766, compared against the pre-0007 run at 09:20:
baseline: content='1BIT OK.' finish=stop
now : content='1BIT OK.' finish=stop
Row 2 — 01:49 crash class: clear, with an honest limit
11 runs × 2 serve teardowns = 22 client exits with live contexts and live buffers, all SIGTERM (0 SIGKILL), 0 panics: kernel BUG 0, list_debug 0, Oops 0, amdxdna_hmm_invalidate 0 — in fact 0 amdxdna kernel lines at all in either
window. Limit: without dyndbg I cannot show those processes still held ubuf BOs at exit, so this says "the exit shape ran
22 times and nothing crashed", not "the UAF path was proven reached". A dyndbg toggle would close that, and I did not take a
box-level knob without asking.
Every phase answered (p9 streaming: 537 SSE data lines, 535 chunks, [DONE], stream_verdict PASS), so the payload did not
stall the array once. That is consistent with the c21 triage (TC21-NPUCHAT-FINDINGS.md §5: 0 TDRs in two prior runs) and it
means patch 0007's recovery path has still never run on this box.
Why a healthy array cannot be made to fire the detector: aie2_legacy_tdr_detect() needs a hwctx with pending jobs and two
consecutive 2 s intervals with no aie2_tdr_signal (message 2026-09 style two-phase check, aie2_tdr.c:36-72). A working
dx run signals on every run completion (~sub-millisecond during prefill/decode), so the two quiet windows never happen. The
wedge is the only thing that produces them.
And the deterministic fallback turned out to be blocked by a real box fact
My plan B was to enter the same recovery code through the close path (amdxdna_drm_close → pm_resume_get → aie2_hwctx_restart), which is deterministic if the device is runtime-suspended at close — the board's condition. It is
not reachable here: after a normal request and 12 s of idling,
runtime_status active
runtime_usage 1
runtime_suspended_time 0 <- never suspended since the module was loaded at 10:23
openers of /dev/accel/accel0 0
So the NPU does not runtime-suspend on this boot, with one pm reference held by nobody visible (no process has accel0
open, checked as root). Consequence for #1005: on this box the close path never takes the restart branch at all, which is also
why the board's -22 chain (and my new "has no host buffer address, cannot restart it" line) both count 0.
That is worth chasing separately and I did not localise it — two candidate explanations (an unbalanced amdxdna_pm_resume_get/suspend_put somewhere, or a persistent consumer). The cheap discriminator is to read runtime_usage immediately after a module load, before any client runs: 1 there means the driver itself holds it, 0 means
a client leaked it. I did not reload the module to find out (owner action).
What would make this decidable (one owner decision)
tdr_timeout_ms is a root-writable module parameter, default 2000 ms. Setting it low (say 1 ms) for one bounded ticket and
submitting one long job makes the detector fire on a healthy array — that is the only way I can see to force patch 0007's
recovery branch without waiting for a real wedge. Two caveats I would want agreed first: (a) the power-cycle will kill the
in-flight job, and (b) if a second TDR lands inside the 60 s rate-limit window, hw_dead latches and the array answers -ENODEV until a driver reload — i.e. the box does not come back by itself, which is exactly the behaviour the patch
intends, but it means the experiment ends with a module reload. I will run it and restore the parameter inside one ticket if
you want that; otherwise the honest status of #1005 stays "fix prepared and loaded, recovery unproven".
What is proven about the loaded module, for the release row
Patch 0007 does not change normal operation: 11 runs, 22 live-context exits, 0 amdxdna errors, 0 panics, known answer
bit-identical, and the c21 page shape still passes through the shipped stream_verdict. No rollback indicated.
Provocation done: patch 0007's recovery branch executes, power-cycles the NPU, and the array is usable afterwards with no reboot
Owner approved forcing the TDR (tdr_timeout_ms ~1 ms) in one npu-hold ticket. Two surprises on the way, both recorded because
they change how this should be tested in future — then the result.
1. tdr_timeout_ms is not runtime-writable
module_param(tdr_timeout_ms, uint, 0400) makes the sysfs file -r--------, so a root write fails: Permission denied (os error 13). (The other three are -rw------- and are writable: aie2_max_col, force_cmdlist, force_iova.) My first
attempt silently ran with the timeout still at the configured 15000 and reported correctly NOT-PROVOKED — no invented
result. The only route is a load-time override, so the ticket did modprobe -r amdxdna; modprobe amdxdna tdr_timeout_ms=1,
and restored with a second plain modprobe (the value comes back as 15000 from /etc/modprobe.d/amdxdna-tdr.conf). No config
file was edited, and both reloads happened inside the ticket with zero accel0 openers.
2. Why a 1 ms detector still did not fire on a normal request: the tick is one jiffy
CONFIG_HZ=250, and TDR_TIMEOUT_JIFF = msecs_to_jiffies(tdr_timeout_ms) rounds up, so tdr_timeout_ms=1 is 4 ms per
tick — and detection needs three ticks (signal → WAIT → WAIT → fire) ≈ 12 ms during which a job is pending and aie2_tdr_signal() never fires. The 0.6B dx route runs ~15 ms per token across 28 layer-designs, i.e. sub-millisecond jobs
with a signal between each: a 19-token request plus a 700-token generation came nowhere near the window. A ~2.8k-token
prefill (11 KB prompt, max_tokens=8) does put one long dispatch in flight, and that fired immediately.
3. What the provocation shows
10:48:12 aie2_legacy_tdr_detect: TDR timeout detected
10:48:12 aie2_tdr_work_func: Device isn't making progress
10:48:12 aie2_set_cmd_timeout: Context ID: 15, DPU PC 0xffffffff, TXN OP ID 0xffffffff,
Context PC 0x28b0cdd2, fatal type 0x0, Timed out sub command ID: 0
10:48:12 aie2_tdr_recover_all: Array stopped dispatching, power-cycling NPU to recover <- the new branch
10:48:12 aie2_hw_reset: NPU firmware unhealthy: power-cycling NPU <- reached, 10 s of reload
10:48:22 Load firmware amdnpu/17f0_11/npu_7.sbin <- firmware reload done
and in the census for the whole window: NPU power-cycle did not recover0, is unusable until the driver is reloaded 0, hw_dead never latched, Map host buf failed 0, addr 0xffffffffffffffff 0, restore data not reclaimed 0, no
BUG/Oops/list_debug. The client's request failed loudly (HTTP 500) instead of hanging — that is the "tell someone" half —
and after the restore reload a fresh client asked the same question and got 1BIT OK. with no new TDR. No reboot.
So the two things #1005 asked for are demonstrated on a real NPU: the stall path now performs the firmware reload instead of a
per-context restart that cannot clear anything, and when recovery genuinely cannot hold, the sticky flag reports it as an
error instead of a device that swallows requests. Before this patch the same event produced only "Device isn't making
progress", a restart that returns success, and an array that never dispatched again.
4. The honest limit, stated plainly
The stall I provoked is a detector false positive on a live array (it was mid-prefill, and note Context PC 0x28b0cdd2 is
a third distinct value beyond the 0x28b06005/0x28b060ad pair, i.e. the capture alone cannot distinguish this from a real
wedge). What is proven is that the recovery mechanism runs end to end and leaves a working array; that this clears a genuine firmware wedge is inferred from the mechanism — a full firmware reload through the SMU power-cycle is the same
device-level operation a reboot performs — not directly observed. Closing that last gap needs a real wedge, which no one can
schedule; the field tripwires are the appliance's chat-npu-stream row and the new dmesg line.
5. Item 9 (the never-suspending NPU): answered — it is not a client leak
Read immediately after each module load in this ticket, before any client, with accel0 openers = 0:
runtime_usage 1 runtime_status active (after load with the override, and again after the plain reload)
So the reference that keeps the device out of runtime suspend is taken by the driver/core side at probe/init, not leaked by a
client — the earlier "some client leaked it" hypothesis is dead. Practical meaning: the board's close-after-suspend -22
chain cannot be reproduced on this box while this holds, and it is a power bug in its own right (autosuspend is configured at
5000 ms and can never engage). Not fixed here; unchanged OWNER item.
Final state of the box
tdr_timeout_ms 15000 (as on entry, from the conf file), module srcversion 56AB94758C18FEEC838D18C on /dev/accel/accel0, :18097 back with the keeper's serve, token released, no config file edited, nothing running. Evidence: ~/amd-oss/hrx-study/evidence/fabric/1005-provoke3-20261104-104745/ (provoke3.log, VERDICT.txt, the provoked body).
The c22 board's "512-token wedge" does not reproduce on strixhalo with byte-identical artifacts — the appliance arms the TDR 7.5× tighter (2000 ms vs 15000 ms)
Assigned the board-vs-strixhalo ladder (TC22-NPU-TDR). Ran it here on the 0007 module (restored in-ticket by modprobe -r+modprobe; the box had silently booted the pre-0007 build from a stale initramfs — separate finding, noted to the kernel lane). Two tickets, 166 s total, released; GPU untouched.
Result: every shape passes here, including well past the board's failing row.
And every input is byte-identical, verified from the board's own media (read-only debugfs on the stick's data partition + unsquashfs, not from a staging copy): engine 98fb79d5…, kernel set layout.json 6fcc9562… (diff -rq clean), model 6abacb42…, firmware npu_7.sbin.zst 278c84d4…, kernel 7.4.0-rc1-1bit, amdxdna 51f0b29a…/56AB9475…/build-id 1e4cdb07…. The board is this same box, so hardware is excluded as well.
The difference that is left, and it is a driver setting
c22 appliance
this box
/etc/modprobe.d/amdxdna*.conf
absent in puppy/bdrv/fdrv/zdrv sfs, and there is no pupsave (pfix=copy,nox), so /etc is exactly the sfs
2000 (aie2_ctx.c:32 default; param is 0400, load-time only)
15000
detection latency
≥ 2 intervals ≈ 4 s without an aie2_tdr_signal (aie2_tdr.c:36-72)
≥ 30 s
The board's failing row took ~12.4 s for 600 tokens where the same row takes 8.1 s here — the extra ~4 s is the watchdog's two-interval confirmation, i.e. generation itself was not slower. And the board's capture (DPU PC 0xffffffff, TXN OP ID 0xffffffff, Timed out sub command ID: 0, Context PC 0x28b060ad) is shape-identical to the false positive I provoked on a healthy array at 10:48 (tdr_timeout_ms=1, Context PC 0x28b0cdd2) — so that capture cannot distinguish a genuine firmware stall from a host-side gap, and here it was demonstrably not a stall.
So
Not the payload / kernels / model / firmware / kernel / driver — identical, and 1029 positions pass.
Not length, process history, ctx or the resident config set — each isolated and measured above.
What the appliance does differently: arms TDR at 2000 ms instead of 15000, and runs a USB root with pfix=copy + zram as the only swap, where a multi-second host pause is plausible. A ≥4 s gap in submits/completions then becomes: TDR → power-cycle (0007 works, as the c22 dmesg shows) → dead client (the second half of this issue's original report).
Recommended, one file, image-side: ship /etc/modprobe.d/amdxdna.conf with options amdxdna tdr_timeout_ms=15000 (parity with this box; it is what TKERNEL-74-STATE.md:205 planned, but the c22 stick does not carry it — verified). Then, separately, find what pauses the host on the appliance (pfix=copy copies ~1.3 GB of sfs into RAM at boot; zram is the only swap).
Evidence: ~/amd-oss/hrx-study/evidence/fabric/c22-ladder/ (per-row JSON + serve logs + the extracted stick artifacts and logs), write-up in ~/briefs/THRX-FABRIC-STATE.md (14:05 entry).
Activity
bong-water-water-bong commentedon Nov 4, 2026
Driver side: the recoverability half, root-caused — plus a prepared patch (scratch build, not installed, not loaded)
I took this as the driver lane. Short version: the TDR path already has a working recovery and it is gated on the wrong
condition. The gate measures "firmware will not answer a context destroy"; the wedge we are hitting is "firmware answers
everything and never dispatches". So the one recovery that clears it never runs, and every later request inherits a dead
array. The requested fix is not "invalidate the wedged context" (there is no wedged context to invalidate) — it is to make
the stall path do the firmware reload it already implements, and to fail loudly when even that does not work.
1. Root cause, from the board's own capture and the driver source (
xdna-driver@526c6081)aie2_tdr_recover_all()(aie2_tdr.c:129-150) does two things: stop every hwctx, thenaie2_hwctx_restart()every hwctx.The power-cycle (
aie2_hw_reset(),aie2_pci.c:516— "recover a wedged NPU via full hardware power-cycle") runs onlywhen
fw_deadis set, andfw_deadis set only whenaie2_hwctx_stop()returned-ETIME/-ENODEV(
aie2_tdr.c:110-113).In the c21 capture, the destroy succeeded: there is no
Firmware unresponsiveline, and — this is the part that settlesit — there is no
hwctx.<pid>.<id> restart failed, ret Nline either, whichaie2_tdr_resume_hwctx()emits for any restarterror (
XDNA_ERR,aie2_tdr.c:139). So at[325.47]the driver stopped the contexts, re-created them, and concluded thearray was recovered. It was not: the firmware report is
DPU PC 0xffffffff,TXN OP ID 0xffffffff,Timed out sub command ID: 0,fatal type 0x0— no dispatch, no transaction, no exception. Control messages still worked; dispatching didnot. That is the state a per-context restart cannot leave, and it is why the page's retry 20 s later failed identically
inside another 200.
ctx 15is not a leaked context:aie2_destroy_context()setshwctx->fw_ctx_id = -1unconditionally(
aie2_message.c:404-408), and the firmware hands out the lowest free id, which is 15 again. That is also why the TQDQ note's"every new process is handed ctx 15" is not an id-allocation bug — a new context on a wedged array is dead on arrival, and
Create hwctx failednever appears in the capture because the create succeeds too.Precedent that this is the gate and not a one-off: four captures, three kernel+module builds (2026-11-01 12:26 ctx 15;
2026-11-02 09:48:51 ctx 8+6; 11-02 09:49:37 the same pair re-firing; c21 board 11-04 08:34:51 ctx 15), all with
DPU PC/TXN OP IDall-ones, all with the array dead afterwards, andTQDQ-STATE.md2026-11-01 records three restartattempts failing identically.
2. The
-22chain is a second, independent defect (it is what leaks the restore data)It is the close path, not the TDR path, and it fires because the device was runtime-suspended in the 40 s between the TDR
and the client exiting.
amdxdna_drm_close()→amdxdna_pm_resume_get()→aie2_hw_resume()→aie2_hwctx_restart(),which maps the hwctx heap through
amdxdna_obj_dma_addr()(aie2_ctx.c:157-163). Under PASID that is the client VA, and theVA is gone once the process's VMAs are torn down — so the driver shipped
MSG_OP_MAP_HOST_BUFFER(0x106) withaddr 0xffffffffffffffff(AMDXDNA_INVALID_ADDR) and the firmware answered0x4000003(-EINVAL). The driver could see thataddress was invalid before sending it; instead the failure surfaced as
Map host buf failed, ret -22→Resume failed: -22→
restore data not reclaimed, i.e. the leak is a consequence of shipping an unaddressable mapping, not a separatefirmware state.
The leak itself (restore data for a ctx suspended across a runtime suspend, destroyable only while the device is up) needs a
different ordering fix — not attempted here, flagged below.
3. Prepared patch —
0007-accel-amdxdna-recover-the-array-after-a-TDR.patch(+96/−24, 5 files)Applies clean to the exact shipped tree (
git apply --checkagainst~/wt/xdna-7.4-rc1=526c6081+ the 5/5+6/6 crashfix, i.e. the module this box and the c21 stick run). Four behaviours, each one line of reasoning:
fw_deadTDR (aie2_tdr.c).fw_deadkeeps its own wording; thestall case gets its own (
Array stopped dispatching, power-cycling NPU to recover).aie2_hw_reset()'s existingrate limiter (one per 60 s,
AIE2_HW_RESET_MIN_INTERVAL_MS) still bounds reset storms, and the existing comment'ssemantics — "repeated timeouts after that indicate a deeper firmware problem" — become the escalation ladder below.
aie2_hw_reset()reports its outcome (int,-EBUSYwhen rate-limited) — it has exactly one caller, so this is alocal change, and without it the caller cannot tell "recovered" from "skipped".
0xffffffffffffffff(aie2_ctx.c): a driver-sideerror naming the hwctx, no bogus firmware request, and the close path's leak now has a stated cause.
aie2_tdr.c+aie2_pci.h+aie2_message.c+aie2_ctx.c): if thepower-cycle did not happen or any restart failed, the driver logs one line —
"NPU array is unusable until the driver is reloaded: TDR recovery failed (…); new contexts and submissions are refused
with -ENODEV" — sets
hw_dead, and new contexts and new submissions fail with-ENODEVimmediately instead of eachrequest hanging ~45 s until the next TDR.
hw_deadis cleared only by a successful fullaie2_hw_start(), i.e. a realfirmware reload.
Resulting ladder: TDR #1 → power-cycle → recovered, work continues. TDR again within 60 s → rate limit →
hw_dead→ callersget
-ENODEV. TDR again after 60 s → power-cycle again.4. What I can and cannot claim
(
-DAMDXDNA_DEVEL -DMODULE_VER_STR=…),-j2underthermal-run.sh, rc=0, 0 warnings, 8 s.amdxdna.ko14 034 024 B, sha256
fbc877e94ab3bfa7…,srcversion 56AB94758C18FEEC838D18C, vermagic7.4.0-rc1-1bit. In my scratchtree (
~/wt/xdna-tdr-recover/), not installed, not signed, not loaded. (BTF skipped there because the headers dir hasno
vmlinux; the shipped module is built from the full tree and does carry BTF.)paholeputshw_deadatoffset
408(0x198) ofamdxdna_dev_hdl, andobjdump -dron the scratch objects showsaie2_tdr_work_func.cold:_dev_warn×2 →amdxdna_hwctx_walk(stop) →_dev_warn→call aie2_hw_reset→amdxdna_hwctx_walk(resume) →movb $0x1,0x198(%r15)(the sticky flag);aie2_hw_start:movb $0x0,0x198(%rbx)(cleared on a real reload);aie2_cmd_submitandaie2_create_context:movzbl 0x198(…)(the fast refusal);aie2_hwctx_restart:cmpq $0xffffffffffffffff,0x1e0(%r13)before theaie2_create_context/aie2_map_host_bufcalls (the heap has noaddress ⇒ refuse locally).
itself, which cannot be provoked on demand — the same c21 payload on this box produced 0 TDRs in two full runs
(
TC21-NPUCHAT-FINDINGS.md§5). So the fix is argued from four captures plus the code, not from a before/after run.force_iova, no parameterchanges). If you load
0007, the proof plan is: run the c21 shape untilaie2_legacy_tdr_detectfires (or replay acapture's conditions), then check three things — (a) the next request after the TDR answers instead of dying 45 s later,
(b) no
Map host bufwithaddr 0xffffffffffffffffever appears again, (c) if recovery does fail,-ENODEVreaches thecaller and the "unusable until the driver is reloaded" line is in
dmesg. Row (a) is the release-relevant one.suspend and then closed (
amdxdna_drm.c:186-196). That needs the close to destroy before the device is resumed, which is aseparate, riskier change; with (3) it at least stops being silent.
5. For the release verdict
Nothing here is a payload problem — that is already established in the findings §5-6, and the driver-side reading agrees: the
array wedges on firmware dispatch, and the reason a single wedge costs a reboot is the gate in §1, not the payload, the
kernel, or the model. Two consequences worth writing down for c21/c22: the appliance's red row (
chat-npu-stream, PR #999)will catch a recurrence, and until a patched module ships, one TDR still means reboot — a retry from the app cannot
succeed, because the array is dead, not the request.
No device touched for any of this: 0 tickets from this lane, GPU never taken,
:18097andnpu-serve-keeperuntouched, nomodule install/load/parameter, no PR (this is a third-party driver tree, so the patch lives with the evidence as with #812),
no merge. Patch + build tree + static evidence:
~/wt/xdna-tdr-recover/; write-up~/briefs/THRX-FABRIC-STATE.md.bong-water-water-bong commentedon Nov 4, 2026
Proof run on the loaded patch (srcversion
56AB9475…): NOT PROVEN — neither PASS nor FAIL, and here is exactly whyOwner asked for three rows. Two are green, the one that decides #1005 is unexercised: in 11 full c21-shaped runs the
firmware wedge never fired, and the one deterministic entry point into the recovery code (the close-after-suspend restart)
turned out to be unreachable on this box in its current state. No rollback is indicated — nothing regressed — but I am not
going to call this PASS, because the recovery path itself has not executed once.
Evidence:
~/amd-oss/hrx-study/evidence/fabric/1005-proof-20261104-102539/(8 runs,VERDICT.txt, harness + per-run bodies)and
…/1005-close-20261104-103330/(close-path probe + 3 more runs).Row 1 — known-answer probe: PASS, bit-identical
p1shape of the c21 payload (/no_think Reply with exactly: 1BIT OK, 48 tokens, ctx 4096, temperature 0), same payloadidentity
98fb79d5df8a3766, compared against the pre-0007 run at 09:20:Row 2 — 01:49 crash class: clear, with an honest limit
11 runs × 2 serve teardowns = 22 client exits with live contexts and live buffers, all SIGTERM (0 SIGKILL), 0 panics:
kernel BUG0,list_debug0,Oops0,amdxdna_hmm_invalidate0 — in fact 0amdxdnakernel lines at all in eitherwindow. Limit: without
dyndbgI cannot show those processes still held ubuf BOs at exit, so this says "the exit shape ran22 times and nothing crashed", not "the UAF path was proven reached". A
dyndbgtoggle would close that, and I did not take abox-level knob without asking.
Row 3 — wedge replay → recovery: NOT PROVEN
aie2_legacy_tdr_detectfabric-1005fabric-closeEvery phase answered (
p9streaming: 537 SSE data lines, 535 chunks,[DONE],stream_verdictPASS), so the payload did notstall the array once. That is consistent with the c21 triage (
TC21-NPUCHAT-FINDINGS.md§5: 0 TDRs in two prior runs) and itmeans patch 0007's recovery path has still never run on this box.
Why a healthy array cannot be made to fire the detector:
aie2_legacy_tdr_detect()needs a hwctx with pending jobs and twoconsecutive 2 s intervals with no
aie2_tdr_signal(message 2026-09 style two-phase check,aie2_tdr.c:36-72). A workingdx run signals on every run completion (~sub-millisecond during prefill/decode), so the two quiet windows never happen. The
wedge is the only thing that produces them.
And the deterministic fallback turned out to be blocked by a real box fact
My plan B was to enter the same recovery code through the close path (
amdxdna_drm_close→pm_resume_get→aie2_hwctx_restart), which is deterministic if the device is runtime-suspended at close — the board's condition. It isnot reachable here: after a normal request and 12 s of idling,
So the NPU does not runtime-suspend on this boot, with one pm reference held by nobody visible (no process has
accel0open, checked as root). Consequence for #1005: on this box the close path never takes the restart branch at all, which is also
why the board's
-22chain (and my new "has no host buffer address, cannot restart it" line) both count 0.That is worth chasing separately and I did not localise it — two candidate explanations (an unbalanced
amdxdna_pm_resume_get/suspend_putsomewhere, or a persistent consumer). The cheap discriminator is to readruntime_usageimmediately after a module load, before any client runs:1there means the driver itself holds it,0meansa client leaked it. I did not reload the module to find out (owner action).
What would make this decidable (one owner decision)
tdr_timeout_msis a root-writable module parameter, default 2000 ms. Setting it low (say 1 ms) for one bounded ticket andsubmitting one long job makes the detector fire on a healthy array — that is the only way I can see to force patch 0007's
recovery branch without waiting for a real wedge. Two caveats I would want agreed first: (a) the power-cycle will kill the
in-flight job, and (b) if a second TDR lands inside the 60 s rate-limit window,
hw_deadlatches and the array answers-ENODEVuntil a driver reload — i.e. the box does not come back by itself, which is exactly the behaviour the patchintends, but it means the experiment ends with a module reload. I will run it and restore the parameter inside one ticket if
you want that; otherwise the honest status of #1005 stays "fix prepared and loaded, recovery unproven".
What is proven about the loaded module, for the release row
Patch 0007 does not change normal operation: 11 runs, 22 live-context exits, 0 amdxdna errors, 0 panics, known answer
bit-identical, and the c21 page shape still passes through the shipped
stream_verdict. No rollback indicated.bong-water-water-bong commentedon Nov 4, 2026
Provocation done: patch 0007's recovery branch executes, power-cycles the NPU, and the array is usable afterwards with no reboot
Owner approved forcing the TDR (
tdr_timeout_ms ~1 ms) in onenpu-holdticket. Two surprises on the way, both recorded becausethey change how this should be tested in future — then the result.
1.
tdr_timeout_msis not runtime-writablemodule_param(tdr_timeout_ms, uint, 0400)makes the sysfs file-r--------, so a root write fails:Permission denied (os error 13). (The other three are-rw-------and are writable:aie2_max_col,force_cmdlist,force_iova.) My firstattempt silently ran with the timeout still at the configured 15000 and reported correctly
NOT-PROVOKED— no inventedresult. The only route is a load-time override, so the ticket did
modprobe -r amdxdna; modprobe amdxdna tdr_timeout_ms=1,and restored with a second plain
modprobe(the value comes back as 15000 from/etc/modprobe.d/amdxdna-tdr.conf). No configfile was edited, and both reloads happened inside the ticket with zero
accel0openers.2. Why a 1 ms detector still did not fire on a normal request: the tick is one jiffy
CONFIG_HZ=250, andTDR_TIMEOUT_JIFF = msecs_to_jiffies(tdr_timeout_ms)rounds up, sotdr_timeout_ms=1is 4 ms pertick — and detection needs three ticks (signal → WAIT → WAIT → fire) ≈ 12 ms during which a job is pending and
aie2_tdr_signal()never fires. The 0.6B dx route runs ~15 ms per token across 28 layer-designs, i.e. sub-millisecond jobswith a signal between each: a 19-token request plus a 700-token generation came nowhere near the window. A ~2.8k-token
prefill (11 KB prompt,
max_tokens=8) does put one long dispatch in flight, and that fired immediately.3. What the provocation shows
and in the census for the whole window:
NPU power-cycle did not recover0,is unusable until the driver is reloaded0,
hw_deadnever latched,Map host buf failed0,addr 0xffffffffffffffff0,restore data not reclaimed0, noBUG/Oops/list_debug. The client's request failed loudly (HTTP 500) instead of hanging — that is the "tell someone" half —
and after the restore reload a fresh client asked the same question and got
1BIT OK.with no new TDR. No reboot.So the two things #1005 asked for are demonstrated on a real NPU: the stall path now performs the firmware reload instead of a
per-context restart that cannot clear anything, and when recovery genuinely cannot hold, the sticky flag reports it as an
error instead of a device that swallows requests. Before this patch the same event produced only "Device isn't making
progress", a restart that returns success, and an array that never dispatched again.
4. The honest limit, stated plainly
The stall I provoked is a detector false positive on a live array (it was mid-prefill, and note
Context PC 0x28b0cdd2isa third distinct value beyond the
0x28b06005/0x28b060adpair, i.e. the capture alone cannot distinguish this from a realwedge). What is proven is that the recovery mechanism runs end to end and leaves a working array; that this clears a
genuine firmware wedge is inferred from the mechanism — a full firmware reload through the SMU power-cycle is the same
device-level operation a reboot performs — not directly observed. Closing that last gap needs a real wedge, which no one can
schedule; the field tripwires are the appliance's
chat-npu-streamrow and the newdmesgline.5. Item 9 (the never-suspending NPU): answered — it is not a client leak
Read immediately after each module load in this ticket, before any client, with
accel0openers = 0:So the reference that keeps the device out of runtime suspend is taken by the driver/core side at probe/init, not leaked by a
client — the earlier "some client leaked it" hypothesis is dead. Practical meaning: the board's close-after-suspend
-22chain cannot be reproduced on this box while this holds, and it is a power bug in its own right (autosuspend is configured at
5000 ms and can never engage). Not fixed here; unchanged OWNER item.
Final state of the box
tdr_timeout_ms 15000(as on entry, from the conf file), modulesrcversion 56AB94758C18FEEC838D18Con/dev/accel/accel0,:18097back with the keeper's serve, token released, no config file edited, nothing running. Evidence:~/amd-oss/hrx-study/evidence/fabric/1005-provoke3-20261104-104745/(provoke3.log,VERDICT.txt, the provoked body).bong-water-water-bong commentedon Nov 4, 2026
The c22 board's "512-token wedge" does not reproduce on strixhalo with byte-identical artifacts — the appliance arms the TDR 7.5× tighter (2000 ms vs 15000 ms)
Assigned the board-vs-strixhalo ladder (TC22-NPU-TDR). Ran it here on the 0007 module (restored in-ticket by
modprobe -r+modprobe; the box had silently booted the pre-0007 build from a stale initramfs — separate finding, noted to the kernel lane). Two tickets, 166 s total, released; GPU untouched.Result: every shape passes here, including well past the board's failing row.
DX_CTX_RESIDENT=0[DONE]/ 629 / 629 positions, 0 TDRAnd every input is byte-identical, verified from the board's own media (read-only
debugfson the stick's data partition +unsquashfs, not from a staging copy): engine98fb79d5…, kernel setlayout.json 6fcc9562…(diff -rqclean), model6abacb42…, firmwarenpu_7.sbin.zst 278c84d4…, kernel7.4.0-rc1-1bit, amdxdna51f0b29a…/56AB9475…/build-id1e4cdb07…. The board is this same box, so hardware is excluded as well.The difference that is left, and it is a driver setting
/etc/modprobe.d/amdxdna*.confpuppy/bdrv/fdrv/zdrvsfs, and there is no pupsave (pfix=copy,nox), so/etcis exactly the sfsamdxdna-tdr.conf→options amdxdna tdr_timeout_ms=15000tdr_timeout_msaie2_ctx.c:32default; param is0400, load-time only)aie2_tdr_signal(aie2_tdr.c:36-72)The board's failing row took ~12.4 s for 600 tokens where the same row takes 8.1 s here — the extra ~4 s is the watchdog's two-interval confirmation, i.e. generation itself was not slower. And the board's capture (
DPU PC 0xffffffff,TXN OP ID 0xffffffff,Timed out sub command ID: 0,Context PC 0x28b060ad) is shape-identical to the false positive I provoked on a healthy array at 10:48 (tdr_timeout_ms=1,Context PC 0x28b0cdd2) — so that capture cannot distinguish a genuine firmware stall from a host-side gap, and here it was demonstrably not a stall.So
pfix=copy+ zram as the only swap, where a multi-second host pause is plausible. A ≥4 s gap in submits/completions then becomes: TDR → power-cycle (0007 works, as the c22 dmesg shows) → dead client (the second half of this issue's original report).Recommended, one file, image-side: ship
/etc/modprobe.d/amdxdna.confwithoptions amdxdna tdr_timeout_ms=15000(parity with this box; it is whatTKERNEL-74-STATE.md:205planned, but the c22 stick does not carry it — verified). Then, separately, find what pauses the host on the appliance (pfix=copycopies ~1.3 GB of sfs into RAM at boot; zram is the only swap).Evidence:
~/amd-oss/hrx-study/evidence/fabric/c22-ladder/(per-row JSON + serve logs + the extracted stick artifacts and logs), write-up in~/briefs/THRX-FABRIC-STATE.md(14:05 entry).os/v3/puppy: ship the NPU's TDR timeout, and a release row that cross…
os/v3/puppy: ship the NPU's TDR timeout, and a release row that cross…
os/v3/puppy: ship the NPU TDR timeout and a release row that crosses …
third_party: carry the two amdxdna patches every build of ours runs (c…
docs/npu: the amdxdna series is nine patches, seven installed — say w…