From: Karol Wachowski <karol.wachowski@xxxxxxxxx> Fix deadlock caused by inversed locking order in ivpu_job_submit() and ivpu_cmdq_destroy_ioctl(). Both functions operate locking file_priv->lock and submitted_jobs_lock. Unlock file_priv->lock in ivpu_cmdq_destroy_ioctl() before calling ivpu_cmdq_abort_all_jobs() function which locks submitted_jobs_lock. That way locking order is maintained: 1) global submitted_jobs_lock first 2) per context file_priv->lock second Signed-off-by: Karol Wachowski <karol.wachowski@xxxxxxxxx> Signed-off-by: Maciej Falkowski <maciej.falkowski@xxxxxxxxxxxxxxx> --- drivers/accel/ivpu/ivpu_job.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c index 37ea92eb4b25..c694822a14bf 100644 --- a/drivers/accel/ivpu/ivpu_job.c +++ b/drivers/accel/ivpu/ivpu_job.c @@ -883,7 +883,7 @@ int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file struct drm_ivpu_cmdq_destroy *args = data; struct ivpu_cmdq *cmdq; u32 cmdq_id; - int ret = 0; + int ret; if (!ivpu_is_capable(vdev, DRM_IVPU_CAP_MANAGE_CMDQ)) return -ENODEV; @@ -893,13 +893,16 @@ int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file cmdq = xa_load(&file_priv->cmdq_xa, args->cmdq_id); if (!cmdq || cmdq->is_legacy) { ret = -ENOENT; - goto unlock; + goto err_unlock; } cmdq_id = cmdq->id; ivpu_cmdq_destroy(file_priv, cmdq); + mutex_unlock(&file_priv->lock); ivpu_cmdq_abort_all_jobs(vdev, file_priv->ctx.id, cmdq_id); -unlock: + return 0; + +err_unlock: mutex_unlock(&file_priv->lock); return ret; } -- 2.43.0