[PATCH WW 10/13] drm/ttm: get rid of ttm_bo_is_reserved usage

Daniel Vetter daniel at ffwll.ch
Thu Jun 27 05:23:29 PDT 2013


On Thu, Jun 27, 2013 at 01:48:25PM +0200, Maarten Lankhorst wrote:
> Use lockdep_assert_held instead.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at canonical.com>
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index a8a27f5..6e6975c 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -166,7 +166,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
>  	struct ttm_bo_device *bdev = bo->bdev;
>  	struct ttm_mem_type_manager *man;
>  
> -	BUG_ON(!ttm_bo_is_reserved(bo));
> +	lockdep_assert_held(&bo->resv->lock.base);

What about assert_ttm_bo_is_reserved instead to both dtrt and also hide
the pointer chasing a bit better? Maybe even add a
assert_reservation_is_held helper to the very first patch?

Same comment applies to following patches which roll this change out on
the drivers.
-Daniel

>  
>  	if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
>  
> @@ -671,7 +671,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
>  		goto out;
>  	}
>  
> -	BUG_ON(!ttm_bo_is_reserved(bo));
> +	lockdep_assert_held(&bo->resv->lock.base);
>  
>  	evict_mem = bo->mem;
>  	evict_mem.mm_node = NULL;
> @@ -961,7 +961,7 @@ int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
>  	struct ttm_mem_reg mem;
>  	struct ttm_bo_device *bdev = bo->bdev;
>  
> -	BUG_ON(!ttm_bo_is_reserved(bo));
> +	lockdep_assert_held(&bo->resv->lock.base);
>  
>  	/*
>  	 * FIXME: It's possible to pipeline buffer moves.
> @@ -1020,7 +1020,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
>  {
>  	int ret;
>  
> -	BUG_ON(!ttm_bo_is_reserved(bo));
> +	lockdep_assert_held(&bo->resv->lock.base);
>  	/* Check that range is valid */
>  	if (placement->lpfn || placement->fpfn)
>  		if (placement->fpfn > placement->lpfn ||
> -- 
> 1.8.3.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list