On 11/17/2026 Tue 13:27, Lizhi Hou wrote:
aie2_sched_job_run() returned NULL when the firmware context is gone
(mbox_chann pointer is NULL). The DRM scheduler treats a NULL return as
a job that completed without an error.

Return ERR_PTR(-ECANCELED) so the error is recorded on the fence, and mark
the command BO aborted.

Fixes: 6b13cb8f48a4 ("accel/amdxdna: Fix runtime suspend deadlock when there is 
pending job")
Signed-off-by: Lizhi Hou <[email protected]>
Reviewed-by: Max Zhen <[email protected]>
---
  drivers/accel/amdxdna/aie2_ctx.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
index 32458d05635f9..c42ea1b4e08d2 100644
--- a/drivers/accel/amdxdna/aie2_ctx.c
+++ b/drivers/accel/amdxdna/aie2_ctx.c
@@ -404,8 +404,18 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
        trace_xdna_job(sched_job, hwctx->name, "job run",
                       job->seq, job->drv_cmd ? job->drv_cmd->opcode : 
DEFAULT_IO);
- if (!hwctx->priv->mbox_chann)
-               return NULL;
+       /*
+        * The firmware context is gone, but the scheduler keeps draining the
+        * entity, for example from drm_sched_entity_destroy(). Returning NULL
+        * would make the DRM scheduler signal the job fence without an error
+        * and user space would see the command as successfully completed.
+        * Abort the job instead. Driver internal commands have no command BO.
+        */
+       if (!hwctx->priv->mbox_chann) {
+               if (cmd_abo)
+                       amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_ABORT);
+               return ERR_PTR(-ECANCELED);
+       }
if (!mmget_not_zero(job->mm))
                return ERR_PTR(-ESRCH);

Reply via email to