[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171201002311.28098-4-lyude@redhat.com>
Date: Thu, 30 Nov 2017 19:23:05 -0500
From: Lyude Paul <lyude@...hat.com>
To: stable@...r.kernel.org
Cc: Christian König <christian.koenig@....com>,
Alex Deucher <alexander.deucher@....com>,
David Airlie <airlied@...ux.ie>,
Chunming Zhou <David1.Zhou@....com>,
"Zhang, Jerry" <Jerry.Zhang@....com>,
Felix Kuehling <Felix.Kuehling@....com>,
Harish Kasiviswanathan <Harish.Kasiviswanathan@....com>,
Alex Xie <AlexBin.Xie@....com>, amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/4] drm/amdgpu: reserve root PD while releasing it
From: Christian König <christian.koenig@....com>
Otherwise somebody could try to evict it at the same time and try to use
half torn down structures.
commit 2642cf110d08a403f585a051e4cbf45a90b3adea upstream
Signed-off-by: Christian König <christian.koenig@....com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@....com>
Reviewed-by: Alex Deucher <alexander.deucher@....com>
Signed-off-by: Alex Deucher <alexander.deucher@....com>
Signed-off-by: Lyude Paul <lyude@...hat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index bd20ff018512..591c6dc2c1f7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2586,7 +2586,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
{
struct amdgpu_bo_va_mapping *mapping, *tmp;
bool prt_fini_needed = !!adev->gart.gart_funcs->set_prt;
- int i;
+ struct amdgpu_bo *root;
+ int i, r;
amd_sched_entity_fini(vm->entity.sched, &vm->entity);
@@ -2609,7 +2610,15 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
amdgpu_vm_free_mapping(adev, vm, mapping, NULL);
}
- amdgpu_vm_free_levels(&vm->root);
+ root = amdgpu_bo_ref(vm->root.bo);
+ r = amdgpu_bo_reserve(root, true);
+ if (r) {
+ dev_err(adev->dev, "Leaking page tables because BO reservation failed\n");
+ } else {
+ amdgpu_vm_free_levels(&vm->root);
+ amdgpu_bo_unreserve(root);
+ }
+ amdgpu_bo_unref(&root);
dma_fence_put(vm->last_dir_update);
for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
amdgpu_vm_free_reserved_vmid(adev, vm, i);
--
2.14.3
Powered by blists - more mailing lists