mirror of https://github.com/torvalds/linux.git
accel/amdxdna: Fix deadlock between context destroy and job timeout
Hardware context destroy function holds dev_lock while waiting for all jobs
to complete. The timeout job also needs to acquire dev_lock, this leads to
a deadlock.
Fix the issue by temporarily releasing dev_lock before waiting for all
jobs to finish, and reacquiring it afterward.
Fixes: 4fd6ca90fc ("accel/amdxdna: Refactor hardware context destroy routine")
Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20251107181050.1293125-1-lizhi.hou@amd.com
This commit is contained in:
parent
6ff9385c07
commit
ca25834123
|
|
@ -690,17 +690,19 @@ void aie2_hwctx_fini(struct amdxdna_hwctx *hwctx)
|
||||||
xdna = hwctx->client->xdna;
|
xdna = hwctx->client->xdna;
|
||||||
|
|
||||||
XDNA_DBG(xdna, "%s sequence number %lld", hwctx->name, hwctx->priv->seq);
|
XDNA_DBG(xdna, "%s sequence number %lld", hwctx->name, hwctx->priv->seq);
|
||||||
drm_sched_entity_destroy(&hwctx->priv->entity);
|
|
||||||
|
|
||||||
aie2_hwctx_wait_for_idle(hwctx);
|
aie2_hwctx_wait_for_idle(hwctx);
|
||||||
|
|
||||||
/* Request fw to destroy hwctx and cancel the rest pending requests */
|
/* Request fw to destroy hwctx and cancel the rest pending requests */
|
||||||
aie2_release_resource(hwctx);
|
aie2_release_resource(hwctx);
|
||||||
|
|
||||||
|
mutex_unlock(&xdna->dev_lock);
|
||||||
|
drm_sched_entity_destroy(&hwctx->priv->entity);
|
||||||
|
|
||||||
/* Wait for all submitted jobs to be completed or canceled */
|
/* Wait for all submitted jobs to be completed or canceled */
|
||||||
wait_event(hwctx->priv->job_free_wq,
|
wait_event(hwctx->priv->job_free_wq,
|
||||||
atomic64_read(&hwctx->job_submit_cnt) ==
|
atomic64_read(&hwctx->job_submit_cnt) ==
|
||||||
atomic64_read(&hwctx->job_free_cnt));
|
atomic64_read(&hwctx->job_free_cnt));
|
||||||
|
mutex_lock(&xdna->dev_lock);
|
||||||
|
|
||||||
drm_sched_fini(&hwctx->priv->sched);
|
drm_sched_fini(&hwctx->priv->sched);
|
||||||
aie2_ctx_syncobj_destroy(hwctx);
|
aie2_ctx_syncobj_destroy(hwctx);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue