drm/amdkfd: Flush the process wq before creating a kfd_process
authorjsg <jsg@openbsd.org>
Sat, 15 Jun 2024 03:59:20 +0000 (03:59 +0000)
committerjsg <jsg@openbsd.org>
Sat, 15 Jun 2024 03:59:20 +0000 (03:59 +0000)
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

index 7a1a574..d98e45a 100644 (file)
@@ -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;