[PATCH 1/2] drm/shmem: add support for per object dma api operations

Thomas Zimmermann tzimmermann at suse.de
Fri Jun 12 09:47:55 UTC 2020


Hi

Am 12.06.20 um 03:36 schrieb Gurchetan Singh:
> This is useful for the next patch.  Also, should we only unmap the
> amount entries that we mapped with the dma-api?

It looks like you're moving virtio code into shmem. It would be nice to
have a cover letter explaining the series.

> 
> Signed-off-by: Gurchetan Singh <gurchetansingh at chromium.org>
> ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 16 +++++++++++-----
>  include/drm/drm_gem_shmem_helper.h     | 10 ++++++++++
>  2 files changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 0a7e3b664bc2..d439074ad7b5 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -124,8 +124,10 @@ void drm_gem_shmem_free_object(struct drm_gem_object *obj)
>  		drm_prime_gem_destroy(obj, shmem->sgt);
>  	} else {
>  		if (shmem->sgt) {
> -			dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
> -				     shmem->sgt->nents, DMA_BIDIRECTIONAL);
> +			if (!shmem->skip_dma_api)
> +				dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
> +					     shmem->dma_map_count,
> +					     DMA_BIDIRECTIONAL);
>  			sg_free_table(shmem->sgt);
>  			kfree(shmem->sgt);
>  		}
> @@ -422,8 +424,9 @@ void drm_gem_shmem_purge_locked(struct drm_gem_object *obj)
>  
>  	WARN_ON(!drm_gem_shmem_is_purgeable(shmem));
>  
> -	dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
> -		     shmem->sgt->nents, DMA_BIDIRECTIONAL);
> +	if (!shmem->skip_dma_api)
> +		dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
> +			     shmem->dma_map_count, DMA_BIDIRECTIONAL);
>  	sg_free_table(shmem->sgt);
>  	kfree(shmem->sgt);
>  	shmem->sgt = NULL;
> @@ -695,7 +698,10 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_object *obj)
>  		goto err_put_pages;
>  	}
>  	/* Map the pages for use by the h/w. */
> -	dma_map_sg(obj->dev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL);
> +	if (!shmem->skip_dma_api)
> +		shmem->dma_map_count = dma_map_sg(obj->dev->dev, sgt->sgl,
> +						  sgt->nents,
> +						  DMA_BIDIRECTIONAL);
>  
>  	shmem->sgt = sgt;
>  
> diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
> index 5381f0c8cf6f..2669d87cbfdd 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -101,6 +101,16 @@ struct drm_gem_shmem_object {
>  	 * @map_cached: map object cached (instead of using writecombine).
>  	 */
>  	bool map_cached;
> +
> +	/**
> +	 * @skip_dma_api: skip using dma api in certain places.
> +	 */
> +	bool skip_dma_api;

This looks like an under-documented workaround for something.

> +
> +	/**
> +	 * @skip_dma_api: number of pages mapped by dma-api.
> +	 */
> +	bool dma_map_count;

The documentation comment doesn't match the field name.

Best regards
Thomas

>  };
>  
>  #define to_drm_gem_shmem_obj(obj) \
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20200612/b19fa6d2/attachment.sig>


More information about the dri-devel mailing list