[PATCH] drm/amdgpu: reserve root PD while releasing it
Michel Dänzer
michel at daenzer.net
Fri Oct 13 15:59:20 UTC 2017
On 13/10/17 05:26 PM, Christian König wrote:
> From: Christian König <christian.koenig at amd.com>
>
> Otherwise somebody could try to evict it at the same time and try to use
> halve torn down structures.
Typo: "half torn down"
> Signed-off-by: Christian König <christian.koenig at amd.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 b72ef2c652d0..ef8b7a9a735a 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)
> {
> 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))
> @@ -2794,7 +2795,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);
>
That seems to do the trick, thanks!
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer at amd.com>
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the amd-gfx
mailing list