[PATCH] drm/v3d: Use the new shmem helpers to reduce driver boilerplate.

Eric Anholt eric at anholt.net
Thu Mar 14 16:47:36 UTC 2019


Eric Anholt <eric at anholt.net> writes:

> The new shmem helpers from Noralf and Rob abstract out a bunch of our
> BO creation and mapping code.
>
> v2: Use the new sgt getter, and flag pages as dirty before freeing.
>
> Signed-off-by: Eric Anholt <eric at anholt.net>

> @@ -185,83 +33,120 @@ void v3d_free_object(struct drm_gem_object *obj)
>  	struct v3d_dev *v3d = to_v3d_dev(obj->dev);
>  	struct v3d_bo *bo = to_v3d_bo(obj);
>  
> +	v3d_mmu_remove_ptes(bo);
> +
>  	mutex_lock(&v3d->bo_lock);
>  	v3d->bo_stats.num_allocated--;
>  	v3d->bo_stats.pages_allocated -= obj->size >> PAGE_SHIFT;
>  	mutex_unlock(&v3d->bo_lock);
>  
> -	v3d_bo_put_pages(bo);
> -
> -	if (obj->import_attach)
> -		drm_prime_gem_destroy(obj, bo->sgt);
> -
> -	v3d_mmu_remove_ptes(bo);
>  	spin_lock(&v3d->mm_lock);
>  	drm_mm_remove_node(&bo->node);
>  	spin_unlock(&v3d->mm_lock);
>  
> -	mutex_destroy(&bo->lock);
> +	drm_gem_shmem_put_pages(&bo->base);

This put_pages() should be dropped -- it generated a WARN because the
shared helpers already do a put_pages after freeing the sgt.  The CTS
had passed, so I missed it until after I'd sent the patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20190314/c5ed475e/attachment.sig>


More information about the dri-devel mailing list