All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent()
@ 2021-07-08 17:51 Thomas Zimmermann
  2021-11-12 15:05 ` Thomas Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Zimmermann @ 2021-07-08 17:51 UTC (permalink / raw)
  To: paul, maarten.lankhorst, mripard, daniel, airlied
  Cc: Thomas Zimmermann, dri-devel

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@suse.de>
Fixes: cf8ccbc72d61 ("drm: Add support for GEM buffers backed by non-coherent memory")
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@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);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent()
  2021-07-08 17:51 [PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent() Thomas Zimmermann
@ 2021-11-12 15:05 ` Thomas Zimmermann
  2021-11-12 15:26   ` Paul Cercueil
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Zimmermann @ 2021-11-12 15:05 UTC (permalink / raw)
  To: paul, maarten.lankhorst, mripard, daniel, airlied; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1966 bytes --]

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@suse.de>
> Fixes: cf8ccbc72d61 ("drm: Add support for GEM buffers backed by non-coherent memory")
> Cc: Paul Cercueil <paul@crapouillou.net>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent()
  2021-11-12 15:05 ` Thomas Zimmermann
@ 2021-11-12 15:26   ` Paul Cercueil
  2021-11-12 15:37     ` Thomas Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Cercueil @ 2021-11-12 15:26 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: airlied, dri-devel

Hi Thomas,

I never received the original patch and I can't find it online either?

Anyway:
Acked-by: Paul Cercueil <paul@crapouillou.net>

Cheers,
-Paul


Le ven., nov. 12 2021 at 16:05:47 +0100, Thomas Zimmermann 
<tzimmermann@suse.de> a écrit :
> 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@suse.de>
>> Fixes: cf8ccbc72d61 ("drm: Add support for GEM buffers backed by 
>> non-coherent memory")
>> Cc: Paul Cercueil <paul@crapouillou.net>
>> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Maxime Ripard <mripard@kernel.org>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: dri-devel@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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent()
  2021-11-12 15:26   ` Paul Cercueil
@ 2021-11-12 15:37     ` Thomas Zimmermann
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Zimmermann @ 2021-11-12 15:37 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: airlied, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3181 bytes --]

Hi Paul

Am 12.11.21 um 16:26 schrieb Paul Cercueil:
> Hi Thomas,
> 
> I never received the original patch and I can't find it online either?

It was posted a while ago [1] and got lost. I remember that you had a 
problem with your email setup. Maybe that's why you didn't see it.

> 
> Anyway:
> Acked-by: Paul Cercueil <paul@crapouillou.net>

Thanks a lot.

Best regards
Thomas

[1] 
https://lore.kernel.org/dri-devel/20210708175146.10618-1-tzimmermann@suse.de/

> 
> Cheers,
> -Paul
> 
> 
> Le ven., nov. 12 2021 at 16:05:47 +0100, Thomas Zimmermann 
> <tzimmermann@suse.de> a écrit :
>> 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@suse.de>
>>> Fixes: cf8ccbc72d61 ("drm: Add support for GEM buffers backed by 
>>> non-coherent memory")
>>> Cc: Paul Cercueil <paul@crapouillou.net>
>>> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>> Cc: Maxime Ripard <mripard@kernel.org>
>>> Cc: David Airlie <airlied@linux.ie>
>>> Cc: Daniel Vetter <daniel@ffwll.ch>
>>> Cc: dri-devel@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
> 
> 

-- 
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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-12 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 17:51 [PATCH] drm/cma-helper: Release non-coherent memory with dma_free_noncoherent() Thomas Zimmermann
2021-11-12 15:05 ` Thomas Zimmermann
2021-11-12 15:26   ` Paul Cercueil
2021-11-12 15:37     ` Thomas Zimmermann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.