accel/ivpu: Correct mutex unlock order in job submission
PATCH 1/1 accel/ivpu: Correct mutex unlock order in job submission
From: Karol Wachowski <[email protected]>
The mutex unlock for vdev->submitted_jobs_lock was incorrectly placed after unlocking file_priv->lock. Change order of unlocks to avoid potential race conditions.
--- drivers/accel/ivpu/ivpu_job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_job.c +1 -1
@@ -681,8 +681,8 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority, u32 cmdq_id) err_erase_xa:xa_erase (&vdev->submitted_jobs_xa, job->job_id); err_unlock: -mutex_unlock (&vdev->submitted_jobs_lock);mutex_unlock (&file_priv->lock); +mutex_unlock (&vdev->submitted_jobs_lock);ivpu_rpm_put (vdev);return ret; }
Signature · 1 line
2.45.1
Quoted 4 lines · Jacek Lawrynowicz
From: Karol Wachowski <[email protected]>
The mutex unlock for
vdev->submitted_jobs_lockwas incorrectly placed after unlockingfile_priv->lock. Change order of unlocks to avoid potential
This should read "before unlocking", right?
Quoted 23 lines
race conditions.
Fixes 5bbccadaf33e ("accel/ivpu: Abort all jobs after command queue unregister")Signed-off-by Karol Wachowski <[email protected]>Signed-off-by Jacek Lawrynowicz <[email protected]>--- drivers/accel/ivpu/ivpu_job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/accel/ivpu/ivpu_job.c +1
-1@@ -681,8 +681,8 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority, u32 cmdq_id) err_erase_xa:xa_erase (&vdev->submitted_jobs_xa, job->job_id); err_unlock: -mutex_unlock (&vdev->submitted_jobs_lock);mutex_unlock (&file_priv->lock); +mutex_unlock (&vdev->submitted_jobs_lock);ivpu_rpm_put (vdev);return ret; }
Hi,
Quoted 7 lines · Jeff Hugo
Quoted 4 lines · Jacek Lawrynowicz
From: Karol Wachowski <[email protected]>
The mutex unlock for
vdev->submitted_jobs_lockwas incorrectly placed after unlockingfile_priv->lock. Change order of unlocks to avoid potentialThis should read "before unlocking", right?
Yes, I will correct the commit message after submitting this patch :)
Quoted 24 lines
Quoted 23 lines
race conditions.
Fixes 5bbccadaf33e ("accel/ivpu: Abort all jobs after command queue unregister")Signed-off-by Karol Wachowski <[email protected]>Signed-off-by Jacek Lawrynowicz <[email protected]>---
drivers/accel/ivpu/ivpu_job.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/accel/ivpu/ivpu_job.c +0
-0@@ -681,8 +681,8 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority, u32 cmdq_id)
err_erase_xa:
xa_erase(&vdev->submitted_jobs_xa, job->job_id);err_unlock:
-mutex_unlock(&vdev->submitted_jobs_lock);mutex_unlock(&file_priv->lock);
+mutex_unlock(&vdev->submitted_jobs_lock);ivpu_rpm_put(vdev);
return ret;
}
Quoted 4 lines · Jacek Lawrynowicz
Hi,
Quoted 1 line · Jeff Hugo
On 4/25/2025 3:36 AM, Jacek Lawrynowicz wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
From: Karol Wachowski <[email protected]>
The mutex unlock for
vdev->submitted_jobs_lockwas incorrectly placed after unlockingfile_priv->lock. Change order of unlocks to avoid potentialThis should read "before unlocking", right?
Yes, I will correct the commit message after submitting this patch :)
It does not look like this would apply to -next. Does it depend on something else? The locking order in -next appears correct.
Quoted 26 lines
Quoted 25 lines
Quoted 24 lines
race conditions.
Fixes 5bbccadaf33e ("accel/ivpu: Abort all jobs after command queue unregister")Signed-off-by Karol Wachowski <[email protected]>Signed-off-by Jacek Lawrynowicz <[email protected]>--- drivers/accel/ivpu/ivpu_job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/accel/ivpu/ivpu_job.c +1
-1@@ -681,8 +681,8 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority, u32 cmdq_id) err_erase_xa: xa_erase(&vdev->submitted_jobs_xa, job->job_id); err_unlock: - mutex_unlock(&vdev->submitted_jobs_lock); mutex_unlock(&file_priv->lock); + mutex_unlock(&vdev->submitted_jobs_lock); ivpu_rpm_put(vdev); return ret; }
Hi,
Quoted 7 lines · Jeff Hugo
Quoted 6 lines · Jacek Lawrynowicz
Hi,
Quoted 3 lines · Jeff Hugo
Quoted 2 lines · Jacek Lawrynowicz
From: Karol Wachowski <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
The mutex unlock for
vdev->submitted_jobs_lockwas incorrectly placed after unlockingfile_priv->lock. Change order of unlocks to avoid potentialThis should read "before unlocking", right?
Yes, I will correct the commit message after submitting this patch :)
It does not look like this would apply to -next. Does it depend on something else? The locking order in -next appears correct.
Both -fixes and -next have incorrect order, see:
https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-next/drivers/accel/ivpu/ivpu_job.c#L683
https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-fixes/drivers/accel/ivpu/ivpu_job.c#L683
The patch applies to both without issues.
Regards,
Jacek
Jeff Hugo
Reviewed-byQuoted 17 lines · Jacek Lawrynowicz
Hi,
Quoted 14 lines · Jeff Hugo
Quoted 12 lines · Jacek Lawrynowicz
Hi,
Quoted 7 lines · Jeff Hugo
Quoted 4 lines · Jacek Lawrynowicz
From: Karol Wachowski <[email protected]>
The mutex unlock for
vdev->submitted_jobs_lockwas incorrectly placed after unlockingfile_priv->lock. Change order of unlocks to avoid potentialThis should read "before unlocking", right?
Yes, I will correct the commit message after submitting this patch :)
Quoted 7 lines
Quoted 1 line
It does not look like this would apply to -next. Does it depend on something else? The locking order in -next appears correct.
Both -fixes and -next have incorrect order, see:
https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-next/drivers/accel/ivpu/ivpu_job.c#L683
https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-fixes/drivers/accel/ivpu/ivpu_job.c#L683The patch applies to both without issues.
Huh, I'm not sure what I was looking at yesterday. I'm seeing it today.
Assuming the commit message fix discussed previously
Fixed commit message and applied to drm-misc-fixes
Quoted 27 lines · Jacek Lawrynowicz
From: Karol Wachowski <[email protected]>
The mutex unlock for
vdev->submitted_jobs_lockwas incorrectly placed after unlockingfile_priv->lock. Change order of unlocks to avoid potential race conditions.Fixes 5bbccadaf33e ("accel/ivpu: Abort all jobs after command queue unregister")Signed-off-by Karol Wachowski <[email protected]>Signed-off-by Jacek Lawrynowicz <[email protected]>--- drivers/accel/ivpu/ivpu_job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/accel/ivpu/ivpu_job.c +1
-1@@ -681,8 +681,8 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority, u32 cmdq_id) err_erase_xa:xa_erase (&vdev->submitted_jobs_xa, job->job_id); err_unlock: -mutex_unlock (&vdev->submitted_jobs_lock);mutex_unlock (&file_priv->lock); +mutex_unlock (&vdev->submitted_jobs_lock);ivpu_rpm_put (vdev);return ret; }