From 5ad48b22d6803e2f8297fb272bb340be17213961 Mon Sep 17 00:00:00 2001 From: jsg Date: Sat, 15 Jun 2024 03:59:20 +0000 Subject: [PATCH] drm/amdkfd: Flush the process wq before creating a kfd_process From Lancelot SIX 6c49ba4025ee04913eedac508260aefcc2766d1f in linux-6.6.y/6.6.33 f5b9053398e70a0c10aa9cb4dd5910ab6bc457c5 in mainline linux --- sys/dev/pci/drm/amd/amdkfd/kfd_process.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_process.c b/sys/dev/pci/drm/amd/amdkfd/kfd_process.c index 7a1a574106f..d98e45aec76 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_process.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_process.c @@ -828,6 +828,14 @@ struct kfd_process *kfd_create_process(struct task_struct *thread) if (process) { pr_debug("Process already found\n"); } else { + /* If the process just called exec(3), it is possible that the + * cleanup of the kfd_process (following the release of the mm + * of the old process image) is still in the cleanup work queue. + * Make sure to drain any job before trying to recreate any + * resource for this process. + */ + flush_workqueue(kfd_process_wq); + process = create_process(thread); if (IS_ERR(process)) goto out; -- 2.20.1