Skip to content

Commit 14700e6

Browse files
houlz0507gregkh
authored andcommitted
accel/amdxdna: Fix incorrect command state for timed out job
[ Upstream commit 6fb7f29 ] When a command times out, mark it as ERT_CMD_STATE_TIMEOUT. Any other commands that are canceled due to this timeout should be marked as ERT_CMD_STATE_ABORT. Fixes: aac2430 ("accel/amdxdna: Add command execution") Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20251029193423.2430463-1-lizhi.hou@amd.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 30f32fa commit 14700e6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

drivers/accel/amdxdna/aie2_ctx.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,13 @@ aie2_sched_resp_handler(void *handle, void __iomem *data, size_t size)
204204

205205
cmd_abo = job->cmd_bo;
206206

207-
if (unlikely(!data))
207+
if (unlikely(job->job_timeout)) {
208+
amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_TIMEOUT);
209+
ret = -EINVAL;
208210
goto out;
211+
}
209212

210-
if (unlikely(size != sizeof(u32))) {
213+
if (unlikely(!data) || unlikely(size != sizeof(u32))) {
211214
amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_ABORT);
212215
ret = -EINVAL;
213216
goto out;
@@ -260,6 +263,13 @@ aie2_sched_cmdlist_resp_handler(void *handle, void __iomem *data, size_t size)
260263
int ret = 0;
261264

262265
cmd_abo = job->cmd_bo;
266+
267+
if (unlikely(job->job_timeout)) {
268+
amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_TIMEOUT);
269+
ret = -EINVAL;
270+
goto out;
271+
}
272+
263273
if (unlikely(!data) || unlikely(size != sizeof(u32) * 3)) {
264274
amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_ABORT);
265275
ret = -EINVAL;
@@ -362,6 +372,7 @@ aie2_sched_job_timedout(struct drm_sched_job *sched_job)
362372

363373
xdna = hwctx->client->xdna;
364374
trace_xdna_job(sched_job, hwctx->name, "job timedout", job->seq);
375+
job->job_timeout = true;
365376
mutex_lock(&xdna->dev_lock);
366377
aie2_hwctx_stop(xdna, hwctx, sched_job);
367378

drivers/accel/amdxdna/amdxdna_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct amdxdna_sched_job {
105105
/* user can wait on this fence */
106106
struct dma_fence *out_fence;
107107
bool job_done;
108+
bool job_timeout;
108109
u64 seq;
109110
struct amdxdna_gem_obj *cmd_bo;
110111
size_t bo_cnt;

0 commit comments

Comments
 (0)