[PATCH 1/3] drm/amdgpu: cleanup VM shadow BO unreferencing

Edward O'Callaghan funfunctor at folklore1984.net
Fri Sep 16 12:43:02 UTC 2016


Series is,
Acked-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 09/16/2016 10:12 PM, Christian König wrote:
> From: Christian König <christian.koenig at amd.com>
> 
> Unreference the shadow BOs in the error path as well and drop the NULL checks.
> 
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 8928a2a..19c7bf7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1429,6 +1429,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
>  
>  		r = amdgpu_vm_clear_bo(adev, vm, pt);
>  		if (r) {
> +			amdgpu_bo_unref(&pt->shadow);
>  			amdgpu_bo_unref(&pt);
>  			goto error_free;
>  		}
> @@ -1635,6 +1636,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
>  	return 0;
>  
>  error_free_page_directory:
> +	amdgpu_bo_unref(&vm->page_directory->shadow);
>  	amdgpu_bo_unref(&vm->page_directory);
>  	vm->page_directory = NULL;
>  
> @@ -1677,15 +1679,17 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
>  	}
>  
>  	for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) {
> -		if (vm->page_tables[i].entry.robj &&
> -		    vm->page_tables[i].entry.robj->shadow)
> -			amdgpu_bo_unref(&vm->page_tables[i].entry.robj->shadow);
> -		amdgpu_bo_unref(&vm->page_tables[i].entry.robj);
> +		struct amdgpu_bo *pt = vm->page_tables[i].entry.robj;
> +
> +		if (!pt)
> +			continue;
> +
> +		amdgpu_bo_unref(&pt->shadow);
> +		amdgpu_bo_unref(&pt);
>  	}
>  	drm_free_large(vm->page_tables);
>  
> -	if (vm->page_directory->shadow)
> -		amdgpu_bo_unref(&vm->page_directory->shadow);
> +	amdgpu_bo_unref(&vm->page_directory->shadow);
>  	amdgpu_bo_unref(&vm->page_directory);
>  	fence_put(vm->page_directory_fence);
>  }
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20160916/fcbbafd6/attachment.sig>


More information about the amd-gfx mailing list