Skip to content

Commit 2aefd08

Browse files
PhilipYangAsmb49
authored andcommitted
drm/amdkfd: KFD release_work possible circular locking
BugLink: https://bugs.launchpad.net/bugs/2115678 [ Upstream commit 1b9366c601039d60546794c63fbb83ce8e53b978 ] 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 <Philip.Yang@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
1 parent 586c4a3 commit 2aefd08

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
@@ -842,6 +842,14 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
842842
return ERR_PTR(-EINVAL);
843843
}
844844

845+
/* If the process just called exec(3), it is possible that the
846+
* cleanup of the kfd_process (following the release of the mm
847+
* of the old process image) is still in the cleanup work queue.
848+
* Make sure to drain any job before trying to recreate any
849+
* resource for this process.
850+
*/
851+
flush_workqueue(kfd_process_wq);
852+
845853
/*
846854
* take kfd processes mutex before starting of process creation
847855
* so there won't be a case where two threads of the same process
@@ -862,14 +870,6 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
862870
if (process) {
863871
pr_debug("Process already found\n");
864872
} else {
865-
/* If the process just called exec(3), it is possible that the
866-
* cleanup of the kfd_process (following the release of the mm
867-
* of the old process image) is still in the cleanup work queue.
868-
* Make sure to drain any job before trying to recreate any
869-
* resource for this process.
870-
*/
871-
flush_workqueue(kfd_process_wq);
872-
873873
process = create_process(thread);
874874
if (IS_ERR(process))
875875
goto out;

0 commit comments

Comments
 (0)