drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm code
authorjsg <jsg@openbsd.org>
Tue, 21 Nov 2023 02:23:24 +0000 (02:23 +0000)
committerjsg <jsg@openbsd.org>
Tue, 21 Nov 2023 02:23:24 +0000 (02:23 +0000)
From Xiaogang Chen
9eae81af9243aabb75bdf638fd773cdee0907f92 in linux-6.1.y/6.1.63
7bfaa160caed8192f8262c4638f552cad94bcf5a in mainline linux

sys/dev/pci/drm/amd/amdkfd/kfd_svm.c

index 63feea0..d7e758c 100644 (file)
@@ -487,11 +487,11 @@ svm_range_validate_svm_bo(struct amdgpu_device *adev, struct svm_range *prange)
 
        /* We need a new svm_bo. Spin-loop to wait for concurrent
         * svm_range_bo_release to finish removing this range from
-        * its range list. After this, it is safe to reuse the
-        * svm_bo pointer and svm_bo_list head.
+        * its range list and set prange->svm_bo to null. After this,
+        * it is safe to reuse the svm_bo pointer and svm_bo_list head.
         */
-       while (!list_empty_careful(&prange->svm_bo_list))
-               ;
+       while (!list_empty_careful(&prange->svm_bo_list) || prange->svm_bo)
+               cond_resched();
 
        return false;
 }