Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] accel/amdxdna: premature return in aie2_cmd_wait() when syncobj is reset --
commit f05d19edddd799b35af693f49ef6b95d8743aad9 Author: Lizhi Hou <[email protected]> accel/amdxdna: Detect a driver command without firmware response This commit initializes cmd->result to U32_MAX before submitting debug BO driver commands so that commands which never receive a firmware response are reported as failures. > diff --git a/drivers/accel/amdxdna/aie2_ctx.c > b/drivers/accel/amdxdna/aie2_ctx.c > index 74d7019268cb6..7525fefa6f1ef 100644 > --- a/drivers/accel/amdxdna/aie2_ctx.c > +++ b/drivers/accel/amdxdna/aie2_ctx.c > @@ -985,10 +985,14 @@ static void 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; > > - if (!out_fence) { > - XDNA_ERR(xdna, "Failed to get fence"); > + /* > + * No fence to wait for. Either seq has already signaled and a later > + * point pruned it out of the timeline chain, or the syncobj was > + * reset. Neither means the command failed, so leave the verdict to > + * the caller, which inspects cmd->result. > + */ > + if (!out_fence) > return; > - } > > mutex_unlock(&xdna->dev_lock); > dma_fence_wait_timeout(out_fence, false, MAX_SCHEDULE_TIMEOUT); > @@ -1018,6 +1022,7 @@ static int aie2_hwctx_cfg_debug_bo(struct amdxdna_hwctx > *hwctx, u32 bo_hdl, > goto put_obj; > } > kref_init(&cmd->refcnt); > + cmd->result = U32_MAX; [Severity: Medium] Can aie2_hwctx_cfg_debug_bo() and aie2_hwctx_sync_debug_bo() observe cmd->result == U32_MAX while the job is still running if the syncobj was reset? aie2_ctx_syncobj_create() exports hwctx->priv->syncobj to userspace as hwctx->syncobj_hdl. If userspace resets that syncobj while a debug BO command is in flight, aie2_cmd_get_out_fence() returns NULL and aie2_cmd_wait() returns immediately without waiting for the job to finish: CPU0 CPU1 aie2_hwctx_cfg_debug_bo() cmd->result = U32_MAX amdxdna_cmd_submit() DRM_IOCTL_SYNCOBJ_RESET drm_syncobj_replace_fence(..., NULL) aie2_cmd_wait() out_fence = NULL return if (cmd->result) <-- sees U32_MAX, returns -EINVAL aie2_sched_drvcmd_resp_handler() job->drv_cmd->result = 0 Unlike the pruned timeline point case where seq has already signaled, resetting the syncobj drops the fence before the firmware responds. aie2_hwctx_cfg_debug_bo() then sees cmd->result == U32_MAX and skips updating abo->assigned_hwctx even though firmware still executes the attach or detach command, leaving abo->assigned_hwctx out of sync with firmware. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
