Skip to content

Commit 1b9366c

Browse files
PhilipYangAalexdeucher
authored andcommitted
drm/amdkfd: KFD release_work possible circular locking
If waiting for gpu reset done in KFD release_work, thers is WARNING: possible circular locking dependency detected #2 kfd_create_process kfd_process_mutex flush kfd release work #1 kfd release work wait for amdgpu reset work #0 amdgpu_device_gpu_reset kgd2kfd_pre_reset kfd_process_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((work_completion)(&p->release_work)); lock((wq_completion)kfd_process_wq); lock((work_completion)(&p->release_work)); lock((wq_completion)amdgpu-reset-dev); To fix this, KFD create process move flush release work outside kfd_process_mutex. Signed-off-by: Philip Yang <[email protected]> Reviewed-by: Felix Kuehling <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent ee3ed10 commit 1b9366c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_process.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,14 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
838838
return ERR_PTR(-EINVAL);
839839
}
840840

841+
/* If the process just called exec(3), it is possible that the
842+
* cleanup of the kfd_process (following the release of the mm
843+
* of the old process image) is still in the cleanup work queue.
844+
* Make sure to drain any job before trying to recreate any
845+
* resource for this process.
846+
*/
847+
flush_workqueue(kfd_process_wq);
848+
841849
/*
842850
* take kfd processes mutex before starting of process creation
843851
* so there won't be a case where two threads of the same process
@@ -858,14 +866,6 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
858866
if (process) {
859867
pr_debug("Process already found\n");
860868
} else {
861-
/* If the process just called exec(3), it is possible that the
862-
* cleanup of the kfd_process (following the release of the mm
863-
* of the old process image) is still in the cleanup work queue.
864-
* Make sure to drain any job before trying to recreate any
865-
* resource for this process.
866-
*/
867-
flush_workqueue(kfd_process_wq);
868-
869869
process = create_process(thread);
870870
if (IS_ERR(process))
871871
goto out;

0 commit comments

Comments
 (0)