diff --git a/third_party/patches/amdxdna/0011-accel-amdxdna-drop-the-mailbox-ring-power-of-two-check.patch b/third_party/patches/amdxdna/0011-accel-amdxdna-drop-the-mailbox-ring-power-of-two-check.patch new file mode 100644 index 000000000..c9c37c7a0 --- /dev/null +++ b/third_party/patches/amdxdna/0011-accel-amdxdna-drop-the-mailbox-ring-power-of-two-check.patch @@ -0,0 +1,39 @@ +# Carried patch, NOT authored here and NOT a `git format-patch` artifact (engine#1811 review). +# +# Upstream change: drm-misc-next-2026-10-16 (tag 41cec5feed4687aea2a59378b271faf363c7d938), +# commit 5d7b464a4f5b -- the 12-hex prefix is what was recorded; the full 40-hex id and the author were +# not retained in this tree, so they are not stated. The paragraph below says the same thing. +# +# Applied by path (`git apply`), never by `git am`: nothing here reads these lines as authorship, and +# an earlier version of this file DID invent them (a 41-character id, "upstream@drm-misc", midnight UTC), +# which looks verifiable and is not. Provenance this file can actually support follows the subject. +Subject: [PATCH] accel/amdxdna: document trusted mailbox ring geometry and drop the power-of-two check + +Carried from drm-misc-next-2026-10-16 (tag 41cec5feed4687aea2a59378b271faf363c7d938), +upstream commit 5d7b464a4f5b (12-hex prefix as recorded; full id not retained). Unmodified upstream change: it applies to our pinned +xdna-driver (526c6081974e) both on the bare pin and on top of 0001-0010. +Applied by: pi-kernel-74 (carried, not installed). +--- + amdxdna_mailbox.c +diff --git a/drivers/accel/amdxdna/amdxdna_mailbox.c b/drivers/accel/amdxdna/amdxdna_mailbox.c +--- a/drivers/accel/amdxdna/amdxdna_mailbox.c ++++ b/drivers/accel/amdxdna/amdxdna_mailbox.c +@@ -569,11 +569,13 @@ xdna_mailbox_start_channel(struct mailbox_channel *mb_chann, + { + int ret; + +- if (!is_power_of_2(x2i->rb_size) || !is_power_of_2(i2x->rb_size)) { +- pr_err("Ring buf size must be power of 2\n"); +- return -EINVAL; +- } +- ++ /* ++ * The ring buffer geometry, rb_start_addr and rb_size for both the ++ * x2i and the i2x channel, comes from AMD signed firmware, through ++ * the management or mailbox information block, or through the ++ * CREATE_CONTEXT response. The driver trusts those values by design ++ * and does not bound them against the mapped region. ++ */ + mb_chann->msix_irq = mb_irq; + mb_chann->iohub_int_addr = iohub_int_addr; + memcpy(&mb_chann->res[CHAN_RES_X2I], x2i, sizeof(*x2i)); diff --git a/third_party/patches/amdxdna/0012-accel-amdxdna-reject-a-device-heap-BO-without-dev_mem_size.patch b/third_party/patches/amdxdna/0012-accel-amdxdna-reject-a-device-heap-BO-without-dev_mem_size.patch new file mode 100644 index 000000000..8c3376fdf --- /dev/null +++ b/third_party/patches/amdxdna/0012-accel-amdxdna-reject-a-device-heap-BO-without-dev_mem_size.patch @@ -0,0 +1,32 @@ +# Carried patch, NOT authored here and NOT a `git format-patch` artifact (engine#1811 review). +# +# Upstream change: drm-misc-next-2026-10-16 (tag 41cec5feed4687aea2a59378b271faf363c7d938), +# commit 3e32932d362b -- the 12-hex prefix is what was recorded; the full 40-hex id and the author were +# not retained in this tree, so they are not stated. The paragraph below says the same thing. +# +# Applied by path (`git apply`), never by `git am`: nothing here reads these lines as authorship, and +# an earlier version of this file DID invent them (a 41-character id, "upstream@drm-misc", midnight UTC), +# which looks verifiable and is not. Provenance this file can actually support follows the subject. +Subject: [PATCH] accel/amdxdna: Reject device heap BO when dev_mem_size is not set + +Carried from drm-misc-next-2026-10-16 (tag 41cec5feed4687aea2a59378b271faf363c7d938), +upstream commit 3e32932d362b (12-hex prefix as recorded; full id not retained). Unmodified upstream change: it applies to our pinned +xdna-driver (526c6081974e) both on the bare pin and on top of 0001-0010. +Applied by: pi-kernel-74 (carried, not installed). +--- + amdxdna_gem.c +diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c +--- a/drivers/accel/amdxdna/amdxdna_gem.c ++++ b/drivers/accel/amdxdna/amdxdna_gem.c +@@ -1140,6 +1140,11 @@ amdxdna_drm_create_dev_heap_bo(struct drm_device *dev, + struct amdxdna_gem_obj *abo; + int ret; + ++ if (!xdna->dev_info->dev_mem_size) { ++ XDNA_DBG(xdna, "Device heap is not supported"); ++ return ERR_PTR(-EOPNOTSUPP); ++ } ++ + WARN_ON(!is_power_of_2(xdna->dev_info->dev_mem_size)); + XDNA_DBG(xdna, "Requested dev heap size 0x%llx", args->size); + if (!args->size || !IS_ALIGNED(args->size, xdna->dev_info->dev_mem_size)) { diff --git a/third_party/patches/amdxdna/README.md b/third_party/patches/amdxdna/README.md index ecf9c3c8f..898695b6c 100644 --- a/third_party/patches/amdxdna/README.md +++ b/third_party/patches/amdxdna/README.md @@ -51,6 +51,8 @@ two-client shape (3/3 wedges on `646FFC30…`) now refuses the second client `co | 0008 | `accel/amdxdna: a dying context must not fail the device resume` (2 files, +33/−4) | `aie2_hwctx_resume_cb()` failed the whole walk on the `-ESRCH` that `aie2_hwctx_restart()` returns for a context whose heap address is gone (a client closing while the device is runtime-suspended), and `aie2_hw_resume()` then `break`s out of the **client** loop: every context of every later client stayed destroyed with no firmware context at all, and `pm_runtime_resume_and_get()` reported failure for a resume that had in fact started the hardware, so `amdxdna_pm_resume_get()` called `pm_runtime_set_suspended()` on a started device | the c29 take's own log: `amdxdna_pm_resume_get: Resume failed: -3` then `amdxdna_drm_close: Resume failed (-3), pid 11374 restore data not reclaimed`, followed immediately by `device is already started` — the resume ran, the dying context made it report failure (engine#1051) | | 0009 | `accel/amdxdna: keep the array awake while a context exists` (1 file, +35/−0) | a runtime suspend destroys every firmware context and the resume recreates them; on this platform a recreated context is created and host-buffer-mapped with the same messages, the same fw ctx id and the same address, `aie2_hwctx_restart()` returns 0 — and its first dispatch still never reaches the DPU (`DPU PC 0xffffffff`, `TXN OP ID 0xffffffff`, `timed out sub command 0`), after which the array wedges until a power-cycle. Take a runtime-PM usage reference for the life of each hw_context (`pm_runtime_get_noresume()` in `aie2_hwctx_init()`, released with `pm_runtime_put_autosuspend()` in `aie2_hwctx_fini()`), so the array cannot enter that state under any client; a device with no contexts still autosuspends at 5 s | the engine#1051 ladder on strixhalo 2026-11-06: **3/3 wedge** with `power/control=auto` on the shipping module, each log showing `Destroyed fw ctx 15` → suspend → `Created fw ctx 15` + host buffer → `restarted, ret 0` → wedge, while the same request into a context created after the resume succeeded and XRT's own validate passed 5/5 across resumes. This is the driver-level form of the c30 keep-awake policy, so it protects every client, not only the payload that polls GET_INFO | | 0010 | `accel/amdxdna: a context that failed to restart stays paused` (2 files, +16/−3) | `aie2_hwctx_restart()` called `aie2_hwctx_job_unpause()` from its shared `out:` label, so a context whose restart had just **failed** was unpaused anyway, and `aie2_tdr_resume_hwctx()` logged it as restarted either way: the queue then drained onto a `fw_ctx_id` firmware no longer has, and the only visible symptom is an NPU that says it recovered and then silently stops answering (engine#1750). The unpause now happens only on success; a failed context stays paused, so its jobs get a clean, attributable failure instead of a wedge. One change fixes both callers — the TDR resume callback and `aie2_hwctx_resume_cb()` on the pm-resume path, which had the same defect; `aie2_hwctx_init()` keeps its own unpause and is untouched | **carried, NOT measured** — no TDR run yet, and 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. Verified here instead: it 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; and the module **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 | +| 0011 | `accel/amdxdna: document trusted mailbox ring geometry and drop the power-of-two check` (1 file, +7/−5) — **carried, NOT installed** | `xdna_mailbox_start_channel()` refused any channel whose firmware-supplied `rb_size` was not a power of two (`-EINVAL`), which turns a ring geometry AMD's signed firmware handed us into a channel that cannot start at all. Upstream drops the check and documents that the geometry, `rb_start_addr` and `rb_size` come from signed firmware and are trusted by design | **carried, NOT measured** — no run has needed a non-power-of-two ring here, so this is a port of an upstream decision rather than a fix we have watched. Verified: the file is the upstream change unmodified, and it `git apply --check`s **both** on the bare pin (`526c6081`) and on top of `0001`–`0010`, so it is order-independent in the series. Never loaded: `/lib/modules` untouched, no `modprobe`, no parameter changed | +| 0012 | `accel/amdxdna: Reject device heap BO when dev_mem_size is not set` (1 file, +5) — **carried, NOT installed** | a heap-BO request on a device with no heap hit a `WARN_ON` and a bogus alignment test instead of one quiet refusal; upstream returns `-EOPNOTSUPP` from the allocation path. Ours warns today (`amdxdna_gem.c`), so this removes a warning from a hot path rather than changing behaviour anyone has depended on | **carried, NOT measured** — the warn path has not been hit on this box in the fleet's runs. Verified the same way: unmodified upstream change, applies on the bare pin and on `0001`–`0011`. Not loaded | **Numbering note (2026-11-06):** the kernel lane's `~/briefs/TKERNEL-74-STATE.md` uses its own series names (`0007`-`0012`) for what is `0004`/`0005`/`0003` here. The numbers in *this* directory are the ones the install order and