Skip to content

Commit

Permalink
drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm…
Browse files Browse the repository at this point in the history
… code

This patch fixes:
1: ref number of prange's svm_bo got decreased by an async call from hmm. When
wait svm_bo of prange got released we shoul also wait prang->svm_bo become NULL,
otherwise prange->svm_bo may be set to null after allocate new vram buffer.

2: During waiting svm_bo of prange got released in a while loop should reschedule
current task to give other tasks oppotunity to run, specially the the workque
task that handles svm_bo ref release, otherwise we may enter to softlock.

Signed-off-by: Xiaogang.Chen <Xiaogang.Chen@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
(cherry picked from commit 528eed632c4fdc5d2dec90f85f90c6f4cb88aa48)

Change-Id: I80ce4bdc4c79cb8fd43064653b9842b528605dd3
  • Loading branch information
Xiaogang Chen authored and kentrussell committed Sep 29, 2023
1 parent bc04878 commit 2a83b3a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/gpu/drm/amd/amdkfd/kfd_svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,11 @@ svm_range_validate_svm_bo(struct kfd_node *node, 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;
}
Expand Down

0 comments on commit 2a83b3a

Please sign in to comment.