drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm code
authorXiaogang Chen <xiaogang.chen@amd.com>
Wed, 20 Sep 2023 16:02:51 +0000 (11:02 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:52:00 +0000 (11:52 +0100)
commit9eae81af9243aabb75bdf638fd773cdee0907f92
tree141ea741070e746bf9f31797d993850913358e88
parent78e998884d5dd515fac5075e5cc647b68af9ff55
drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm code

[ Upstream commit 7bfaa160caed8192f8262c4638f552cad94bcf5a ]

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>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdkfd/kfd_svm.c