]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu: reserve root PD while releasing it
authorChristian König <christian.koenig@amd.com>
Fri, 13 Oct 2017 15:24:31 +0000 (17:24 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 Oct 2017 19:27:11 +0000 (15:27 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index c559d76ff695f7f5940c0f3a79da0879611036ba..010d14195a5ec63d54e5e37d6ce97901dbead71c 100644 (file)
@@ -2759,8 +2759,9 @@ 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;
+       struct amdgpu_bo *root;
        u64 fault;
-       int i;
+       int i, r;
 
        /* Clear pending page faults from IH when the VM is destroyed */
        while (kfifo_get(&vm->faults, &fault))
@@ -2795,7 +2796,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.base.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_update);
        for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
                amdgpu_vm_free_reserved_vmid(adev, vm, i);