Skip to content

Commit c1cb1d2

Browse files
PhilipYangAaloktiwa
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 #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]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 0b2cb9ea6b1f94559def84f65ca1e6237f5e0b33) Signed-off-by: Alok Tiwari <[email protected]>
1 parent f7d8600 commit c1cb1d2

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
@@ -277,6 +277,14 @@ struct kfd_process *kfd_create_process(struct file *filep)
277277
if (thread->group_leader->mm != thread->mm)
278278
return ERR_PTR(-EINVAL);
279279

280+
/* If the process just called exec(3), it is possible that the
281+
* cleanup of the kfd_process (following the release of the mm
282+
* of the old process image) is still in the cleanup work queue.
283+
* Make sure to drain any job before trying to recreate any
284+
* resource for this process.
285+
*/
286+
flush_workqueue(kfd_process_wq);
287+
280288
/*
281289
* take kfd processes mutex before starting of process creation
282290
* so there won't be a case where two threads of the same process
@@ -289,14 +297,6 @@ struct kfd_process *kfd_create_process(struct file *filep)
289297
if (process) {
290298
pr_debug("Process already found\n");
291299
} else {
292-
/* If the process just called exec(3), it is possible that the
293-
* cleanup of the kfd_process (following the release of the mm
294-
* of the old process image) is still in the cleanup work queue.
295-
* Make sure to drain any job before trying to recreate any
296-
* resource for this process.
297-
*/
298-
flush_workqueue(kfd_process_wq);
299-
300300
process = create_process(thread);
301301
if (IS_ERR(process))
302302
goto out;

0 commit comments

Comments
 (0)