From: jsg Date: Tue, 21 Nov 2023 02:23:24 +0000 (+0000) Subject: drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm code X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=eeb918668a86128038a248a66aea50925f8e85fe;p=openbsd 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 --- 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; }