summaryrefslogtreecommitdiff
path: root/drivers/accel
diff options
context:
space:
mode:
authorLizhi Hou <lizhi.hou@amd.com>2025-11-07 10:10:50 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-12-18 13:59:41 +0100
commit431e5af9e40e62f22a6de0d35fa20a0922cf53b8 (patch)
tree141c84ae892fa9f057f10a068e09540405e666b2 /drivers/accel
parent1073d1628c3d6c45285b6087386ba7f2e6c9e167 (diff)
downloadlinux-431e5af9e40e62f22a6de0d35fa20a0922cf53b8.tar.gz
linux-431e5af9e40e62f22a6de0d35fa20a0922cf53b8.tar.bz2
linux-431e5af9e40e62f22a6de0d35fa20a0922cf53b8.zip
accel/amdxdna: Fix deadlock between context destroy and job timeout
[ Upstream commit ca2583412306ceda9304a7c4302fd9efbf43e963 ] 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: 4fd6ca90fc7f ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/accel')
-rw-r--r--drivers/accel/amdxdna/aie2_ctx.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
index b02f84121f3a..8e6a60897479 100644
--- a/drivers/accel/amdxdna/aie2_ctx.c
+++ b/drivers/accel/amdxdna/aie2_ctx.c
@@ -675,17 +675,19 @@ void aie2_hwctx_fini(struct amdxdna_hwctx *hwctx)
ndev->hwctx_num--;
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);
/* Request fw to destroy hwctx and cancel the rest pending requests */
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_event(hwctx->priv->job_free_wq,
atomic64_read(&hwctx->job_submit_cnt) ==
atomic64_read(&hwctx->job_free_cnt));
+ mutex_lock(&xdna->dev_lock);
drm_sched_fini(&hwctx->priv->sched);
aie2_ctx_syncobj_destroy(hwctx);