Skip to content

Commit cfc5a07

Browse files
PhilipYangAgregkh
authored andcommitted
drm/amdkfd: KFD release_work possible circular locking
[ Upstream commit 1b9366c ] If waiting for gpu reset done in KFD release_work, thers is WARNING: possible circular locking dependency detected Freescale#2 kfd_create_process kfd_process_mutex flush kfd release work Freescale#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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 2e04e06 commit cfc5a07

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
@@ -807,6 +807,14 @@ struct kfd_process *kfd_create_process(struct file *filep)
807807
if (thread->group_leader->mm != thread->mm)
808808
return ERR_PTR(-EINVAL);
809809

810+
/* If the process just called exec(3), it is possible that the
811+
* cleanup of the kfd_process (following the release of the mm
812+
* of the old process image) is still in the cleanup work queue.
813+
* Make sure to drain any job before trying to recreate any
814+
* resource for this process.
815+
*/
816+
flush_workqueue(kfd_process_wq);
817+
810818
/*
811819
* take kfd processes mutex before starting of process creation
812820
* so there won't be a case where two threads of the same process
@@ -819,14 +827,6 @@ struct kfd_process *kfd_create_process(struct file *filep)
819827
if (process) {
820828
pr_debug("Process already found\n");
821829
} else {
822-
/* If the process just called exec(3), it is possible that the
823-
* cleanup of the kfd_process (following the release of the mm
824-
* of the old process image) is still in the cleanup work queue.
825-
* Make sure to drain any job before trying to recreate any
826-
* resource for this process.
827-
*/
828-
flush_workqueue(kfd_process_wq);
829-
830830
process = create_process(thread);
831831
if (IS_ERR(process))
832832
goto out;

0 commit comments

Comments
 (0)