[PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent()

Thomas Zimmermann tzimmermann at suse.de
Fri Nov 12 15:05:47 UTC 2021


Ping for review.

Am 08.07.21 um 19:51 schrieb Thomas Zimmermann:
> The GEM CMA helpers allocate non-coherent (i.e., cached) backing storage
> with dma_alloc_noncoherent(), but release it with dma_free_wc(). Fix this
> with a call to dma_free_noncoherent(). Writecombining storage is still
> released with dma_free_wc().
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> Fixes: cf8ccbc72d61 ("drm: Add support for GEM buffers backed by non-coherent memory")
> Cc: Paul Cercueil <paul at crapouillou.net>
> Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> Cc: Maxime Ripard <mripard at kernel.org>
> Cc: David Airlie <airlied at linux.ie>
> Cc: Daniel Vetter <daniel at ffwll.ch>
> Cc: dri-devel at lists.freedesktop.org
> ---
>   drivers/gpu/drm/drm_gem_cma_helper.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
> index d53388199f34..9d05674550a4 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -210,8 +210,13 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj)
>   			dma_buf_vunmap(gem_obj->import_attach->dmabuf, &map);
>   		drm_prime_gem_destroy(gem_obj, cma_obj->sgt);
>   	} else if (cma_obj->vaddr) {
> -		dma_free_wc(gem_obj->dev->dev, cma_obj->base.size,
> -			    cma_obj->vaddr, cma_obj->paddr);
> +		if (cma_obj->map_noncoherent)
> +			dma_free_noncoherent(gem_obj->dev->dev, cma_obj->base.size,
> +					     cma_obj->vaddr, cma_obj->paddr,
> +					     DMA_TO_DEVICE);
> +		else
> +			dma_free_wc(gem_obj->dev->dev, cma_obj->base.size,
> +				    cma_obj->vaddr, cma_obj->paddr);
>   	}
>   
>   	drm_gem_object_release(gem_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: Ivo Totev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20211112/9f2a0afb/attachment.sig>


More information about the dri-devel mailing list