[PATCH 01/10] drm/ttm: allocate resource object instead of embedding it v2

Thomas Hellström thomas.hellstrom at linux.intel.com
Tue Jun 8 06:55:53 UTC 2021


Hi,

On 6/2/21 12:09 PM, Christian König wrote:
> To improve the handling we want the establish the resource object as base
> class for the backend allocations.
>
> v2: add missing error handling
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  4 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 54 +++++++-------
>   drivers/gpu/drm/nouveau/nouveau_bo.c       |  2 +-
>   drivers/gpu/drm/radeon/radeon_ttm.c        |  2 +-
>   drivers/gpu/drm/ttm/ttm_bo.c               | 83 ++++++++--------------
>   drivers/gpu/drm/ttm/ttm_bo_util.c          | 43 ++++++-----
>   drivers/gpu/drm/ttm/ttm_resource.c         | 31 +++++---
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c |  2 +-
>   include/drm/ttm/ttm_bo_api.h               |  1 -
>   include/drm/ttm/ttm_bo_driver.h            | 10 ++-
>   include/drm/ttm/ttm_resource.h             |  4 +-
>   11 files changed, 110 insertions(+), 126 deletions(-)
...
>   
> @@ -629,7 +628,7 @@ static void ttm_bo_move_pipeline_evict(struct ttm_buffer_object *bo,
>   	}
>   	spin_unlock(&from->move_lock);
>   
> -	ttm_resource_free(bo, bo->resource);
> +	ttm_resource_free(bo, &bo->resource);
>   
>   	dma_fence_put(bo->moving);
>   	bo->moving = dma_fence_get(fence);
> @@ -678,11 +677,11 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
>   	if (ret)
>   		ttm_bo_wait(bo, false, false);
>   
> -	ttm_resource_alloc(bo, &sys_mem, bo->resource);
> +	ret = ttm_resource_alloc(bo, &sys_mem, &bo->resource);
>   	bo->ttm = NULL;
>   
>   	dma_resv_unlock(&ghost->base._resv);
>   	ttm_bo_put(ghost);
>   
> -	return 0;
> +	return ret;

Here we re-introduce a late point of failure, which I guess leaves the 
bo in an undefined state? Same thing with my optimization for the idle 
case. Needs fixing as soon as possible.

/Thomas




More information about the dri-devel mailing list