From: Lizhi Hou <lizhi.hou@amd.com>
To: <ogabbay@kernel.org>, <quic_jhugo@quicinc.com>,
<dri-devel@lists.freedesktop.org>, <mario.limonciello@amd.com>,
<karol.wachowski@linux.intel.com>, <max.zhen@amd.com>
Cc: Lizhi Hou <lizhi.hou@amd.com>, <linux-kernel@vger.kernel.org>,
<sonal.santan@amd.com>
Subject: [PATCH V1 1/2] accel/amdxdna: Check the fence error after waiting for a driver command
Date: Tue, 17 Nov 2026 11:21:56 -0800 [thread overview]
Message-ID: <20261117192157.154516-1-lizhi.hou@amd.com> (raw)
aie2_cmd_wait() discarded the result of the wait, and both callers,
aie2_hwctx_cfg_debug_bo() and aie2_hwctx_sync_debug_bo(), decided
success solely from cmd->result.
cmd->result is only written by aie2_sched_drvcmd_resp_handler(), which
runs when firmware responds. If the job fails before it reaches
firmware, for example aie2_sync_bo() or aie2_config_debug_bo() fail to
send the mailbox message, the error is recorded on the fence and no
response handler runs. cmd is zero allocated, so cmd->result stays 0 and
the caller treats the failed command as successful.
aie2_hwctx_cfg_debug_bo() then goes on to update abo->assigned_hwctx.
Return the fence error from aie2_cmd_wait() and check it in both
callers. This also covers a fence errored after the command was posted,
and the case where aie2_cmd_get_out_fence() finds no fence at all, which
previously fell through to the same false success.
Fixes: 7ea046838021 ("accel/amdxdna: Support firmware debug buffer")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
drivers/accel/amdxdna/aie2_ctx.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
index 11f5421e497a..0a1914f0f1c0 100644
--- a/drivers/accel/amdxdna/aie2_ctx.c
+++ b/drivers/accel/amdxdna/aie2_ctx.c
@@ -984,20 +984,30 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
return ret;
}
-static void aie2_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq)
+static int aie2_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq)
{
struct dma_fence *out_fence = aie2_cmd_get_out_fence(hwctx, seq);
struct amdxdna_dev *xdna = hwctx->client->xdna;
+ int ret;
if (!out_fence) {
XDNA_ERR(xdna, "Failed to get fence");
- return;
+ return -EINVAL;
}
mutex_unlock(&xdna->dev_lock);
dma_fence_wait_timeout(out_fence, false, MAX_SCHEDULE_TIMEOUT);
mutex_lock(&xdna->dev_lock);
+ /*
+ * The job may never reach firmware, for example the submission to
+ * the mailbox failed. In that case there is no response and
+ * cmd->result stays untouched, so the fence error is the only way
+ * to tell the command did not complete.
+ */
+ ret = out_fence->error;
dma_fence_put(out_fence);
+
+ return ret;
}
static int aie2_hwctx_cfg_debug_bo(struct amdxdna_hwctx *hwctx, u32 bo_hdl,
@@ -1044,7 +1054,12 @@ static int aie2_hwctx_cfg_debug_bo(struct amdxdna_hwctx *hwctx, u32 bo_hdl,
goto put_cmd;
}
- aie2_cmd_wait(hwctx, seq);
+ ret = aie2_cmd_wait(hwctx, seq);
+ if (ret) {
+ XDNA_ERR(xdna, "Command failed, ret %d", ret);
+ goto put_cmd;
+ }
+
if (cmd->result) {
XDNA_ERR(xdna, "Response failure 0x%x", cmd->result);
ret = -EINVAL;
@@ -1104,7 +1119,12 @@ int aie2_hwctx_sync_debug_bo(struct amdxdna_hwctx *hwctx, u32 debug_bo_hdl)
goto put_cmd;
}
- aie2_cmd_wait(hwctx, seq);
+ ret = aie2_cmd_wait(hwctx, seq);
+ if (ret) {
+ XDNA_ERR(xdna, "Command failed, ret %d", ret);
+ goto put_cmd;
+ }
+
if (cmd->result) {
XDNA_ERR(xdna, "Response failure 0x%x", cmd->result);
ret = -EINVAL;
--
2.34.1
next reply other threads:[~2026-11-17 19:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 19:21 Lizhi Hou [this message]
2026-11-17 19:21 ` [PATCH V1 2/2] accel/amdxdna: Abort jobs when the firmware context is gone Lizhi Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117192157.154516-1-lizhi.hou@amd.com \
--to=lizhi.hou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karol.wachowski@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=max.zhen@amd.com \
--cc=ogabbay@kernel.org \
--cc=quic_jhugo@quicinc.com \
--cc=sonal.santan@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®