From 01f282b57fe4e11444a3564ac83545b1310fdc44 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Wed, 15 Feb 2017 15:24:12 -0500 Subject: [PATCH 1593/4131] drm/amdgpu: Lock rmn->lock in HSA MMU notifiers This is necessary to protect against concurrent access to the rmn->objects interval tree. Bug: SWDEV-112668, SWDEV-112670 Change-Id: I69438bc2837f10a5c62c252f1aa7d77d1a1c3cb4 Signed-off-by: Felix Kuehling --- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c index 990e6fe..d961477 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c @@ -215,6 +215,8 @@ static void amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn, /* notification is exclusive, but interval is inclusive */ end -= 1; + mutex_lock(&rmn->lock); + it = interval_tree_iter_first(&rmn->objects, start, end); while (it) { struct amdgpu_mn_node *node; @@ -231,6 +233,8 @@ static void amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn, amdgpu_amdkfd_evict_mem(amdgpu_ttm_adev(bo->tbo.bdev), mem, mm); } } + + mutex_unlock(&rmn->lock); } /** @@ -258,6 +262,8 @@ static void amdgpu_mn_invalidate_range_end_hsa(struct mmu_notifier *mn, /* notification is exclusive, but interval is inclusive */ end -= 1; + mutex_lock(&rmn->lock); + it = interval_tree_iter_first(&rmn->objects, start, end); while (it) { struct amdgpu_mn_node *node; @@ -275,6 +281,8 @@ static void amdgpu_mn_invalidate_range_end_hsa(struct mmu_notifier *mn, mem, mm, 1); } } + + mutex_unlock(&rmn->lock); } static const struct mmu_notifier_ops amdgpu_mn_ops[] = { -- 2.7.4