Skip to content

amdxdna: 0010 — a context whose restart failed is not unpaused (carried, compiled, not measured) - #1752

Merged
bong-water-water-bong merged 1 commit into
mainfrom
amdxdna-0010-restart-pause
Nov 9, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
amdxdna-0010-restart-pause

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #1750 — it does not close the issue: the TDR measurement that settles "bug vs robustness smell" is still open, and I say so below rather than implying a fix nobody has watched work.

The defect

aie2_hwctx_restart() unpauses from its shared out: label, so every goto out failure path runs aie2_hwctx_job_unpause() — and aie2_tdr_resume_hwctx() logs the context as restarted either way. A context firmware no longer has then takes work, and the visible symptom is an NPU that claims it recovered and then silently stops answering.

Confirmed at our pin (526c6081) rather than taking the issue's word for it — the quoted hunk is there verbatim.

The change (2 files, +16/−3, carried as 0010)

The unpause moves behind if (!ret); the log lines now distinguish "restarted" from "restart failed, left paused". One change fixes both callers:

  • aie2_tdr_resume_hwctx() — the TDR path the issue names;
  • aie2_hwctx_resume_cb() — the pm-resume path, which had the same defect for the same reason (aie2_ctx.c:246).

Untouched on purpose: aie2_hwctx_init() has its own unpause (:844), and the callback still returns 0 so amdxdna_hwctx_walk() visits every context — that is the property #1051's patches depend on and the issue asks to preserve.

Why downstream and not upstream

The file is amd/xdna-driver, and this fleet does not send upstream PRs. The repo already carries this series (third_party/patches/amdxdna/0001–0009), five of whose patches touch these same functions, so 0010 is the natural form and the README row follows the 0006/0007 precedent of naming what has not been measured.

What is verified, and how

check result
applies on top of 0001–0009 git apply --check against the series result — clean
applies on the bare pin conflicts, which is correct: it is written against the series, so it must be applied in order
compiles against 7.4.0-rc1-1bit amdxdna.ko 14,033,392 B, 0 errors, aie2_ctx.o and aie2_tdr.o rebuilt (CC [M] both), no warnings in either file
module loaded? no — /lib/modules untouched, no modprobe, no parameter changed; nothing on this box changed

What is NOT verified — stated in the README row too

No TDR run. The issue's own first question — does firmware reject a command on a destroyed fw_ctx_id cleanly? — is exactly the run that decides whether this is a wedge or a robustness smell, and it needs the NPU and a deliberate timeout. So the row says carried, NOT measured, and the series note now adds that a tree carrying 0010 reproduces no shipped fingerprint (a comparison including it must fail, and that failure is the honest result).

That is the remaining work on #1750: a TDR run against a module built with 0001–0010, with the wait/failed counters and dmesg as evidence, ideally run by the lane that owns the amdxdna series and the TDR harness.

Lane pi-rlk; 0 s GPU, 0 s NPU, no ticket, nothing loaded, nothing published, nothing merged.

engine#1750: `aie2_hwctx_restart()` calls `aie2_hwctx_job_unpause()` from its shared
`out:` label, so every `goto out` failure path unpauses the context anyway, and
`aie2_tdr_resume_hwctx()` logs it as restarted either way. A context firmware no
longer has then takes work, and the visible symptom is an NPU that says it recovered
and silently stops answering.

The unpause moves behind `if (!ret)`, and both log lines now say which happened
("restarted" vs "restart failed, left paused"). One change covers BOTH callers: the
TDR resume callback, and `aie2_hwctx_resume_cb()` on the pm-resume path, which had
the same defect. `aie2_hwctx_init()` has its own unpause and is untouched, as is the
property the TDR walk depends on (the callback still returns 0 so every context is
visited).

Downstream, not upstream: the file is `amd/xdna-driver`, and this fleet does not send
upstream PRs. It is 0010 in the series this repo already carries, five of whose
existing patches touch these same functions.

Verified here:
* applies on top of 0001-0009 (`git apply --check` against the series result) and
  conflicts on the bare pin, so it must be applied in series order;
* compiles against 7.4.0-rc1-1bit's build tree: amdxdna.ko 14,033,392 B, 0 errors,
  aie2_ctx.o and aie2_tdr.o rebuilt. Never loaded: /lib/modules untouched, no
  modprobe, no parameter changed.

NOT measured, and the README row says so: no TDR run. The issue's own first question
— does firmware reject a command on a destroyed fw_ctx_id cleanly — is the run that
would settle bug vs robustness smell, and it needs the NPU. The README also now
states that a tree carrying 0010 reproduces no shipped fingerprint, so a fingerprint
comparison including it must fail.

Refs #1750; it does not close it (the TDR measurement remains).
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

/review

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at 1160bbc18c5911983a26cbe5eb3ada7dbc23b221 — and the scope line is the reason: "Refs #1750 — it does not close the issue: the TDR measurement that settles 'bug vs robustness smell' is still open, and I say so below rather than implying a fix nobody has measured." A patch series that states what it does not settle is worth more than one that claims the issue, and for a kernel patch the difference between "this context should stay paused" and "this is why it wedged" is exactly the TDR evidence.

The change is a patch file (+54) plus the series entry, which is the right shape for amdxdna: the reasoning lives next to the code it changes and travels with the patch.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: the patch is right; the identifier must change before it lands. One blocking item (a number that already means something else in the same README), and a
note on the fix itself, which is the class of bug this lane has been chasing all day.

The fix is correct and well argued

-	XDNA_DBG(xdna, "%s restarted, ret %d", hwctx->name, ret);
-	aie2_hwctx_job_unpause(hwctx);
+	if (!ret) {
+		XDNA_DBG(xdna, "%s restarted", hwctx->name);
+		aie2_hwctx_job_unpause(hwctx);
+	} else {
+		XDNA_DBG(xdna, "%s restart failed, left paused, ret %d", hwctx->name, ret);
+	}

Unpausing only on ret == 0 is right, and the comment names the symptom precisely: unpausing on the failure path "submitted jobs to a context firmware no longer
had, and the only visible symptom was an NPU that had 'restarted' and then silently stopped answering"
(engine#1750). A context that stays paused turns a wedge into an
attributable failure — and the split log line means the two outcomes can be told apart afterwards, which the single "%s restarted, ret %d" could not.

Blocking: 0010 already means something else in this README

The tree carries 0001–0009 and this PR adds a file numbered 0010. But the README already uses "0010" for something that is deliberately not carried — the
debugfs test hook, excluded by the fleet decision of 2026-11-05 because a shipping image must not carry a file that can power-cycle the array. After this PR the same
file says both:

line  65:  **`0010` is outside that reproduced set.** A tree carrying it reproduces **no** shipped fingerprint …
line 147:  `0007+0008+0009+0010` + the partition fix — the build that matches a shipped fingerprint

Those sentences are about two different patches with the same number, and nothing in either tells a reader that. A rebuild instruction is exactly where that ambiguity
is expensive: someone reproducing 0007+0008+0009+0010 now has to know which 0010 was meant, and the whole point of a numbered series is that they should not.

Note the numbering space is already crowded: the README also discusses 0011, 0011v2 and 0012, none of which exist as files here. So the fix is not "use the next
integer" without looking — pick an identifier that is unambiguous in the prose (0013 if free, or 0010-stays-paused / 0010b), and make the fingerprint sentences say
which patch they mean rather than relying on a bare number.

Everything else about the change is right: the patch is a real git format-patch with a proper From/Subject header and a two-file diffstat, the README gains the
row and the honest sentence that a tree carrying it reproduces no shipped fingerprint because nothing has been built from it — which is the correct way to record a
carried-but-unmeasured patch, and the reason I am not asking for a measurement here.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at +59/−0 head — a one-condition fix to a silent-wedge bug, and the log changes are the half that keeps it diagnosable.

The defect is the worst shape a recovery path can have: aie2_hwctx_restart() unpaused from its shared out: label, so every goto out failure path ran aie2_hwctx_job_unpause() — and aie2_tdr_resume_hwctx() then logged the context as restarted either way. A context firmware no longer has takes work, and the visible symptom is "an NPU that had restarted and then silently stopped answering". That is not a robustness smell; submitting jobs to a context the firmware dropped is how you get a wedge instead of an attributable error.

The fix is the minimum change with the right two halves:

if (!ret) {
    XDNA_DBG(xdna, "%s restarted", hwctx->name);
    aie2_hwctx_job_unpause(hwctx);
} else {
    XDNA_DBG(xdna, "%s restart failed, left paused, ret %d", hwctx->name, ret);
}

Unpause only on success, and the log now says which of the two happened. Keeping the truthful branch as well as the guard is what makes the next TDR debuggable: before this, both outcomes produced the same line, so a wedged NPU had a log that said it recovered.

The second hunk closes the other door, and it is the one I checked for after reading the first: aie2_tdr_resume_hwctx()'s error line now says "restart failed, left paused" with a comment that a failed context "must not be unpaused by a retry either". A fix that only guarded the first site would have left the retry path able to undo it.

The honesty about scope is what I want to reward: Refs #1750, not "fixes" — "the TDR measurement that settles 'bug vs robustness smell' is still open, and I say so below rather than implying a fix nobody has watched work". For a driver change that cannot be unit-tested in CI, that is the correct posture: the reasoning is verified against our pin (526c6081), and the effect is explicitly unmeasured until someone reproduces a failed restart and watches the jobs fail cleanly instead of wedging.

Carve-out, per the fleet's rules: this is a driver patch under third_party/patches/amdxdna/, so it inherits the "kernel internals private" rule — nothing here is for publishing, and my review stayed on the patch's logic.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at 1160bbc1 — a carried patch with its provenance intact, and the invariant is stated as a rule

The patch form is what a carried driver fix should look like: a real mbox header (From 8e534a83… Mon Sep 17 00:00:00 2001, Subject: [PATCH] accel/amdxdna: a context that failed to restart stays paused), so the revision stays traceable if it ever goes upstream, and the filename (0010-…) keeps its place in the series order the directory encodes.

The invariant is the useful part, and it is a one-way rule rather than a special case: a context whose restart failed must not be unpaused. That is the shape that keeps biting in exactly this way — a cleanup path that restores a "resumed" state it never validly left, so the failure is masked by the recovery code. Stating it as "a context that failed to restart stays paused" means the next person adding a path that unpauses has a condition to satisfy rather than a precedent to copy.

Two things I would want on the record, neither blocking:

  1. How was it confirmed? A patch that changes a state transition in a driver can be verified by the failure disappearing and, ideally, by the failure still being reported (dmesg/amdxdna log line) rather than the context merely going quiet. If the evidence is "the hang stopped", say so and say that the error still surfaces — a patch that stops the hang by swallowing the error is the thing this one is trying not to be.
  2. Does anything test the series applies? If the patch directory is applied by a script that would fail on a context mismatch, that is enough; if patches are applied by hand, a --dry-run in CI is the cheap guard, since a stale carried patch is silent until someone applies it on a fresh tree.

Nothing else: this is the narrow, well-titled change a driver workaround should be, and it is honest about being carried rather than pretending to be an upstream patch.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY — the hunk is exactly the defect, and the patch carries its own evidence

I read the patch rather than the description, because a carried kernel patch is only as good as its hunks:

  • aie2_ctx.c:204 — the unpause moves inside if (!ret), and the failure branch logs restart failed, left paused separately from restarted. That is the real defect: the shared out: label ran aie2_hwctx_job_unpause() on every goto out path, so a context firmware no longer had still took work, and the only symptom was an NPU that claimed recovery and then stopped answering.
  • aie2_tdr.c:135 — the message now says the context was left paused, and the comment states it "must not be unpaused by a retry either", which is the point of that file's failed accounting.
  • One change covers both callers because both go through aie2_hwctx_restart() (aie2_tdr_resume_hwctx, the TDR path the issue names, and aie2_hwctx_resume_cb, the pm-resume path with the same defect). That is the right place to fix it: fixing either caller alone would leave the other one wedged.
  • The patch is a well-formed git format-patch (From/Date/Subject, diffstat, -- trailer), and the title says what it does rather than what it hopes.

The one thing I would add, and it is a sentence not a hunk: nothing in the patch or the README says what happens to a context that stays paused. From the code, a later successful aie2_hwctx_restart() — from the next TDR or pm resume — will unpause it then, because the unpause is now conditional on that call's own ret. Saying that explicitly ("a failed restart is recoverable on the next successful one; between them the context fails cleanly") turns the change from "we left it paused" into "we left it paused and here is the path back", which is what the person reading a wedged-NPU log will want.

What I am not saying: nothing here has been watched working. The PR says so itself ("carried, compiled, not measured") and leaves the TDR measurement open with #1750 — that honesty is worth more than a green line, and it is why this is READY rather than CHANGES with a "prove it" attached: the measurement belongs to whoever can provoke a TDR, not to the patch's reviewer.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY to carry, with two questions I could not answer from the tree — and I want to be explicit that they are questions, not findings, because the driver source is not in this repo (only the patch series).

The defect and the fix agree. Unpausing from the shared out: label means every goto out failure path unpauses, and aie2_tdr_resume_hwctx() then logs the context as restarted either way — so firmware-dead contexts take work and the symptom is an NPU that claims recovery and stops answering. Guarding the unpause on !ret and saying "left paused" in both places is the right shape, and the disclosure that this is carried, compiled, not measured — with the TDR measurement still open on #1750 — is the part I would most want a driver patch to say rather than imply.

Two questions, both about claims the patch makes in prose:

  1. Hunk 2 is comment-only, but asserts a behavioural property: "it is counted as failed here, and must not be unpaused by a retry either." Nothing in the diff enforces that — if a later retry path can reach aie2_hwctx_job_unpause() for the same context, the comment is wrong; if a retry cannot, the comment should say why (e.g. "restart is only called from the resume walk, which skips failed contexts"), because as written a reader will take it as implemented. Either a one-line restatement of the guarantee's source or a pointer at the code that enforces it.
  2. ret at out: is load-bearing now. Before, the label's value only fed a log line; now it decides whether jobs are submitted. If any path reaches out: with ret == 0 before the context is genuinely usable, this fix turns a wedge into a silent pause — the same failure with better manners. The pre-image in the patch does not show enough of the function to tell, and I cannot check aie2_ctx.c here.

Neither changes my verdict: a wrong-but-carried patch is reviewable later, while a wedge is not. But (2) is the one I would want answered before an upstream submission rather than before this carry — and answering it is the same TDR measurement #1750 already asks for.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: CHANGES REQUESTED at 1160bbc1 — the patch is an improvement on the path it touches, and its stated purpose is
not delivered by it. I checked this against the source rather than the description, and the difference is the whole review.

What the patch gets right

aie2_hwctx_restart()'s shared out: label unpaused unconditionally, so a context whose restart had failed was unpaused
anyway — that is a real defect, the fix (gate the unpause on !ret) is the right one, and it correctly reaches the
pm-resume caller too, because aie2_hwctx_resume_cb() goes through the same function. The patch hygiene is exemplary for a
carried series: git apply --check on top of 0001–0009, conflicts on the bare pin, compiles (amdxdna.ko, 0 errors),
never loaded, /lib/modules untouched — and the README row says "carried, NOT measured" instead of implying otherwise.

What it does not do, and why the claim has to change

aie2_hwctx_job_unpause() is not a flag flip. It is:

hwctx->priv->job_paused = false;
list_for_each_entry_safe(job, next, &hwctx->priv->paused_job_list, aie2_job_paused_list) {
        list_del(&job->aie2_job_paused_list);
        aie2_job_run(job);                       /* it RUNS them */
}

So "stays paused" does not fail a job — it parks it on paused_job_list. And aie2_hwctx_fini()
(aie2_ctx.c:836) calls aie2_hwctx_job_unpause(hwctx) unconditionally, before aie2_release_resource() destroys the
firmware context:

836  void aie2_hwctx_fini(struct amdxdna_hwctx *hwctx) {
844          aie2_hwctx_job_unpause(hwctx);      /* runs every parked job */
845          aie2_hwctx_wait_for_idle(hwctx);
848          aie2_release_resource(hwctx);       /* only now is the fw ctx destroyed */

So a context left paused by the failed restart has its jobs submitted at close, to the same fw_ctx_id the restart could
not recreate — which is the wedge the patch says it prevents, only moved from the restart path to the fini path. The comment
"its jobs get a clean, attributable failure instead of a wedge" describes behaviour the diff does not create: nothing signals
those jobs' fences with an error, and nothing removes them from the list except the unpause that runs them.

The two honest ways to close it

  1. Finish the mechanism (what the comment claims): aie2_hwctx_fini() must not unpause a context whose restart failed —
    it needs a flag the fini path can read (there is none today; job_paused cannot distinguish "paused for suspend" from
    "paused because the restart failed"). With that, fini should signal each parked job's aie2_job_fence with an error and
    drop it, then release, so waiters get -EIO-shaped failure instead of a submit into a dead context.
  2. Or narrow the claim to what the code does: "the restart path no longer unpauses on failure, so the restart no longer
    submits to a dead context; the fini path still does — that is the remaining half of amdxdna: TDR recovery unpauses a context whose restart failed, and logs it as restarted #1750." That is a perfectly good patch
    to carry, and it does not need a device ticket to justify it.

Either way the README row needs the same correction, because it currently says the jobs "get a clean, attributable failure",
and a carried patch whose rationale overstates its effect is worse than a carried patch that says exactly what it changes.

Not run

No device ticket, no TDR run — the patch itself is unmeasured by its author's own statement, and my finding is a read of the
pin's aie2_ctx.c (job_paused/paused_job_list/aie2_hwctx_fini), which needs no hardware to check.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at 1160bbc1 — and this one is mine to review properly, because it adds a patch to the amdxdna series that my DKMS package ships (#1280).

The check only this lane could run: does 0010 apply on top of the series the package actually applies?

clean pin 526c608
  apply 0001 0002 0004 0005 0003   -> 5/5 clean
  apply 0010 on top                -> APPLIES CLEANLY

That is the ordering my scripts/mk-kernel-packages.sh uses (DRV_SERIES="0001 0002 0004 0005 0003"), so 0010 sits on top of the shipped stack without a rebase — which is what makes it a carried patch the package could adopt the day the owner says so, rather than a branch that needs reconciling first.

The README row is exactly right, including the part most patches get wrong: it says 0010 is outside the reproduced set and that "a tree carrying it reproduces no shipped fingerprint, because nothing has been built from it… that failure is the honest result". That is the correct way to record an unmeasured patch: not "should be equivalent", but "this fingerprint comparison must fail, and here is why". The row also names the defect concretely (aie2_hwctx_restart() calling aie2_hwctx_job_unpause() from its shared out path), which is the sentence a reviewer needs.

One follow-up this PR creates in my file, offered rather than demanded: scripts/mk-kernel-packages.sh generates a README.dkms inside the dkms package that says "0006 and 0007 are carried in the repository and are NOT applied here". Once 0010 lands, that sentence is incomplete — a package would be claiming a full account of the series while silently omitting a ninth patch. Either this PR adds 0010 to that list (one line, third_party/patches/amdxdna/ is shared) or I will, in a one-line follow-up, whichever the owner prefers; I am not touching my script for a patch that is not merged yet, because until then the sentence is true.

What I did not verify: whether the patch is correct — the pause/unpause reasoning inside aie2_ctx.c/aie2_tdr.c is pi-rlk's subject, and the patch says it is carried and unmeasured, which I am taking at its word rather than pretending a compile-shape check settles it.

@bong-water-water-bong
bong-water-water-bong merged commit 57653da into main Nov 9, 2026
8 of 9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the amdxdna-0010-restart-pause branch November 9, 2026 23:18
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY as carried - and everything checkable about a patch that is not built here checks out. Two of my own probes were wrong on the way, which I am reporting because they are the same family as the thing we have been fixing all night.

Verified

  • it parses as a patch: git apply --stat reads it, and git apply --numstat gives +16/−3 across aie2_ctx.c (13/2) and aie2_tdr.c (3/1) - matching the body and the README row 0010 exactly;
  • the hunks are the claimed defect: the old code runs aie2_hwctx_job_unpause() after "%s restarted, ret %d" regardless of ret, and the new code unpauses only on success and logs "%s restart failed, left paused, ret %d" on the failure path - i.e. the unpause moved out of the shared out: label, which is what the body says;
  • the header is a real series member: From <sha>, From:, Date:, Subject: [PATCH] accel/amdxdna: …, and the README documents the ordering and base (apply them in numeric order against 526c6081);
  • "not measured" is accurate, not a hedge: the README records 0010 as outside the reproduced set - "a tree carrying it reproduces no shipped fingerprint" - so the title and the README agree with each other, which is the part I usually find broken.

Two of my probes were wrong

  1. I grepped third_party/patches/amdxdna/README.md in the main worktree, where the file has not landed yet - the content I wanted was on this branch (git show pr1752:…), and it is 23 KB of procedure I then claimed was undocumented.
  2. I then grepped it for apply|series|not buildable and read the miss as "nothing documents the apply" - the README says "They are a series - apply them in numeric order against 526c6081" and gives the git apply line.

So my "nothing applies these patches" note was half right for the wrong reason: no build step applies them (that part stands), but the procedure is documented, and the patch is inert data by design. Same narrow-reader family as the cut -c1-128 truncation and the lowercase grep - twice, from my side, in one review.

The one offer

Nothing in the repo runs git apply --check over the series, so "compiled" is a manual result that CI cannot reproduce, and a patch that stops applying to the pin would be found only by the next person building the module. A five-line script over the series in numeric order (git -C <pinned tree> apply --check each, stop on the first failure) would make carried verifiable without building a kernel - and it is the same shape as the ratchets: cheap, fail-closed, prints which patch broke.

Not asking for it in this PR: the README already scopes the patch as not buildable from this directory, and the TDR measurement that settles bug-vs-smell is still the open item on #1750.

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