Commit 709c3482 authored by Xiaogang Chen's avatar Xiaogang Chen Committed by Alex Deucher

drm/amdkfd: Fix a race condition of vram buffer unref in svm code

prange->svm_bo unref can happen in both mmu callback and a callback after
migrate to system ram. Both are async call in different tasks. Sync svm_bo
unref operation to avoid random "use-after-free".
Signed-off-by: default avatarXiaogang Chen <xiaogang.chen@amd.com>
Reviewed-by: default avatarPhilip Yang <Philip.Yang@amd.com>
Reviewed-by: default avatarJesse Zhang <Jesse.Zhang@amd.com>
Tested-by: default avatarJesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 003048dd
......@@ -637,8 +637,15 @@ svm_range_vram_node_new(struct kfd_node *node, struct svm_range *prange,
void svm_range_vram_node_free(struct svm_range *prange)
{
svm_range_bo_unref(prange->svm_bo);
prange->ttm_res = NULL;
/* serialize prange->svm_bo unref */
mutex_lock(&prange->lock);
/* prange->svm_bo has not been unref */
if (prange->ttm_res) {
prange->ttm_res = NULL;
mutex_unlock(&prange->lock);
svm_range_bo_unref(prange->svm_bo);
} else
mutex_unlock(&prange->lock);
}
struct kfd_node *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment