summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2023-11-21 02:23:25 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2023-11-21 02:23:25 +0000
commite9037bf89c690d0af7fc1ffaef227d4a7616343e (patch)
tree554966fc7bcb5e5765d3ad247f818f48b0fd08e5 /sys/dev/pci/drm/amd/amdkfd/kfd_svm.c
parent0c6ec87d442cb5ba1024614b2319c420796c0c07 (diff)
drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm code
From Xiaogang Chen 9eae81af9243aabb75bdf638fd773cdee0907f92 in linux-6.1.y/6.1.63 7bfaa160caed8192f8262c4638f552cad94bcf5a in mainline linux
Diffstat (limited to 'sys/dev/pci/drm/amd/amdkfd/kfd_svm.c')
-rw-r--r--sys/dev/pci/drm/amd/amdkfd/kfd_svm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c
index 63feea08904..d7e758c86a0 100644
--- a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c
+++ b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c
@@ -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;
}