diff options
author | Christian König <christian.koenig@amd.com> | 2017-10-13 11:24:31 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-10-19 15:27:11 -0400 |
commit | 2642cf110d08a403f585a051e4cbf45a90b3adea (patch) | |
tree | c2d63a127f6abcd8da692f9bb6a8bcb9a5b72ead /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |
parent | 5c42c64f7d54ba560b0b001e4e73e4a1aeed1355 (diff) |
drm/amdgpu: reserve root PD while releasing it
Otherwise somebody could try to evict it at the same time and try to use
half torn down structures.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 13 |
1 files 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 c559d76ff695..010d14195a5e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -2759,8 +2759,9 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
2759 | { | 2759 | { |
2760 | struct amdgpu_bo_va_mapping *mapping, *tmp; | 2760 | struct amdgpu_bo_va_mapping *mapping, *tmp; |
2761 | bool prt_fini_needed = !!adev->gart.gart_funcs->set_prt; | 2761 | bool prt_fini_needed = !!adev->gart.gart_funcs->set_prt; |
2762 | struct amdgpu_bo *root; | ||
2762 | u64 fault; | 2763 | u64 fault; |
2763 | int i; | 2764 | int i, r; |
2764 | 2765 | ||
2765 | /* Clear pending page faults from IH when the VM is destroyed */ | 2766 | /* Clear pending page faults from IH when the VM is destroyed */ |
2766 | while (kfifo_get(&vm->faults, &fault)) | 2767 | while (kfifo_get(&vm->faults, &fault)) |
@@ -2795,7 +2796,15 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
2795 | amdgpu_vm_free_mapping(adev, vm, mapping, NULL); | 2796 | amdgpu_vm_free_mapping(adev, vm, mapping, NULL); |
2796 | } | 2797 | } |
2797 | 2798 | ||
2798 | amdgpu_vm_free_levels(&vm->root); | 2799 | root = amdgpu_bo_ref(vm->root.base.bo); |
2800 | r = amdgpu_bo_reserve(root, true); | ||
2801 | if (r) { | ||
2802 | dev_err(adev->dev, "Leaking page tables because BO reservation failed\n"); | ||
2803 | } else { | ||
2804 | amdgpu_vm_free_levels(&vm->root); | ||
2805 | amdgpu_bo_unreserve(root); | ||
2806 | } | ||
2807 | amdgpu_bo_unref(&root); | ||
2799 | dma_fence_put(vm->last_update); | 2808 | dma_fence_put(vm->last_update); |
2800 | for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) | 2809 | for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) |
2801 | amdgpu_vm_free_reserved_vmid(adev, vm, i); | 2810 | amdgpu_vm_free_reserved_vmid(adev, vm, i); |