[PATCH] drm/amdgpu: fix error handling in amdgpu_bo_do_create

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 31/10/17 09:37 AM, Christian König wrote:
> From: Christian König <christian.koenig at amd.com>
> 
> The bo structure is freed up in case of an error, so we can't do any
> accounting if that happens.
> 
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index e44b880eefdd..ff6f842655d1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -369,6 +369,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
>  	r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
>  				 &bo->placement, page_align, !kernel, NULL,
>  				 acc_size, sg, resv, &amdgpu_ttm_bo_destroy);
> +	if (unlikely(r != 0))
> +		return r;
> +
>  	bytes_moved = atomic64_read(&adev->num_bytes_moved) -
>  		      initial_bytes_moved;
>  	if (adev->mc.visible_vram_size < adev->mc.real_vram_size &&
> @@ -378,9 +381,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
>  	else
>  		amdgpu_cs_report_moved_bytes(adev, bytes_moved, 0);
>  
> -	if (unlikely(r != 0))
> -		return r;
> -
>  	if (kernel)
>  		bo->tbo.priority = 1;
>  
> 

Hmm. If it's at least theoretically possible that ttm_bo_init_reserved
moves some BOs before returning an error, we should instead make the
accounting safe WRT bo having been freed. But assuming it's not possible,

Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux