All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: cma: fix refcounting on the dmabuf import error path
@ 2013-07-05  6:32 Joonyoung Shim
  2013-07-05  9:46 ` Laurent Pinchart
  0 siblings, 1 reply; 3+ messages in thread
From: Joonyoung Shim @ 2013-07-05  6:32 UTC (permalink / raw)
  To: dri-devel; +Cc: airlied, laurent.pinchart, stable

>From drm gem CMA helper, it wasn't fixed dma_buf refcount problem fixed
by commit 011c228. This patch solves it.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 drivers/gpu/drm/drm_gem_cma_helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index ce06397..3f3a12b 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -554,7 +554,6 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct drm_device *drm,
 			 * refcount on gem itself instead of f_count of dmabuf.
 			 */
 			drm_gem_object_reference(obj);
-			dma_buf_put(dma_buf);
 			return obj;
 		}
 	}
@@ -573,6 +572,8 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct drm_device *drm,
 		goto error_gem_free;
 	}
 
+	get_dma_buf(dma_buf);
+
 	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
 	if (IS_ERR_OR_NULL(sgt)) {
 		ret = sgt ? PTR_ERR(sgt) : -ENOMEM;
@@ -597,6 +598,7 @@ error_buf_unmap:
 	dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
 error_buf_detach:
 	dma_buf_detach(dma_buf, attach);
+	dma_buf_put(dma_buf);
 error_gem_free:
 	drm_gem_cma_free_object(&cma_obj->base);
 	return ERR_PTR(ret);
-- 
1.8.1.2

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

* Re: [PATCH] drm: cma: fix refcounting on the dmabuf import error path
  2013-07-05  6:32 [PATCH] drm: cma: fix refcounting on the dmabuf import error path Joonyoung Shim
@ 2013-07-05  9:46 ` Laurent Pinchart
  2013-07-08  9:11   ` Joonyoung Shim
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2013-07-05  9:46 UTC (permalink / raw)
  To: Joonyoung Shim; +Cc: dri-devel, airlied, stable

Hi Joonyoung,

Thank you for the patch.

On Friday 05 July 2013 15:32:35 Joonyoung Shim wrote:
> From drm gem CMA helper, it wasn't fixed dma_buf refcount problem fixed
> by commit 011c228. This patch solves it.

Please add a "Cc:stable@vger.kernel.org" here.

> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/drm_gem_cma_helper.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c
> b/drivers/gpu/drm/drm_gem_cma_helper.c index ce06397..3f3a12b 100644
> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
> @@ -554,7 +554,6 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct
> drm_device *drm, * refcount on gem itself instead of f_count of dmabuf.
>  			 */
>  			drm_gem_object_reference(obj);
> -			dma_buf_put(dma_buf);
>  			return obj;
>  		}
>  	}
> @@ -573,6 +572,8 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct
> drm_device *drm, goto error_gem_free;
>  	}
> 
> +	get_dma_buf(dma_buf);
> +

As a side note, you have probably placed the get_dma_buf() call here to mimic 
the drm_prime.c code, but would there be anything wrong by placing it right 
before returning the GEM object ? The dma_buf_put() call could then be removed 
from the error path.

>  	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
>  	if (IS_ERR_OR_NULL(sgt)) {
>  		ret = sgt ? PTR_ERR(sgt) : -ENOMEM;
> @@ -597,6 +598,7 @@ error_buf_unmap:
>  	dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
>  error_buf_detach:
>  	dma_buf_detach(dma_buf, attach);
> +	dma_buf_put(dma_buf);
>  error_gem_free:
>  	drm_gem_cma_free_object(&cma_obj->base);
>  	return ERR_PTR(ret);
-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm: cma: fix refcounting on the dmabuf import error path
  2013-07-05  9:46 ` Laurent Pinchart
@ 2013-07-08  9:11   ` Joonyoung Shim
  0 siblings, 0 replies; 3+ messages in thread
From: Joonyoung Shim @ 2013-07-08  9:11 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: dri-devel, airlied, stable

On 07/05/2013 06:46 PM, Laurent Pinchart wrote:
> Hi Joonyoung,
>
> Thank you for the patch.
>
> On Friday 05 July 2013 15:32:35 Joonyoung Shim wrote:
>>  From drm gem CMA helper, it wasn't fixed dma_buf refcount problem fixed
>> by commit 011c228. This patch solves it.
> Please add a "Cc:stable@vger.kernel.org" here.

OK.

>
>> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>> ---
>>   drivers/gpu/drm/drm_gem_cma_helper.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c
>> b/drivers/gpu/drm/drm_gem_cma_helper.c index ce06397..3f3a12b 100644
>> --- a/drivers/gpu/drm/drm_gem_cma_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
>> @@ -554,7 +554,6 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct
>> drm_device *drm, * refcount on gem itself instead of f_count of dmabuf.
>>   			 */
>>   			drm_gem_object_reference(obj);
>> -			dma_buf_put(dma_buf);
>>   			return obj;
>>   		}
>>   	}
>> @@ -573,6 +572,8 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct
>> drm_device *drm, goto error_gem_free;
>>   	}
>>
>> +	get_dma_buf(dma_buf);
>> +
> As a side note, you have probably placed the get_dma_buf() call here to mimic
> the drm_prime.c code, but would there be anything wrong by placing it right
> before returning the GEM object ? The dma_buf_put() call could then be removed
> from the error path.

Yes, i just placed get_dma_buf() call after dma_buf_attach() is called
because "[PATCH] drm: prime: fix refcounting on the dmabuf import error
path" commit does it so.

I'm not sure whether increased reference count of dma_buf needs right
After dma_buf_attach().

>
>>   	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
>>   	if (IS_ERR_OR_NULL(sgt)) {
>>   		ret = sgt ? PTR_ERR(sgt) : -ENOMEM;
>> @@ -597,6 +598,7 @@ error_buf_unmap:
>>   	dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
>>   error_buf_detach:
>>   	dma_buf_detach(dma_buf, attach);
>> +	dma_buf_put(dma_buf);
>>   error_gem_free:
>>   	drm_gem_cma_free_object(&cma_obj->base);
>>   	return ERR_PTR(ret);

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

end of thread, other threads:[~2013-07-08  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-05  6:32 [PATCH] drm: cma: fix refcounting on the dmabuf import error path Joonyoung Shim
2013-07-05  9:46 ` Laurent Pinchart
2013-07-08  9:11   ` Joonyoung Shim

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.