drm/prime: drop reference on imported dma-buf
Subsystems (8)
PATCH 1/1 drm/prime: drop reference on imported dma-buf
From: Rob Clark <[email protected]>
The GEM handle takes the reference. If a driver is actually importing a foreign dmabuf, rather than just re-importing it's own dmabuf, it needs to do a get_dma_buf().
--- drivers/gpu/drm/drm_prime.c | 7 +++++++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_prime.c | 5 +++++ drivers/gpu/drm/radeon/radeon_prime.c | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 4 ++++ 6 files changed, 28 insertions(+)
drivers/gpu/drm/drm_prime.c +7 -0
@@ -185,6 +185,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,mutex_unlock (&file_priv->prime.lock);drm_gem_object_unreference_unlocked (obj); +/* +* Drop the ref we obtained w/ dma_buf_get() for the benefit of +* drivers simply re-importing their own dma-buf.. if drivers +* import a foreign dma-buf, they should get_dma_buf(). +*/ +dma_buf_put (dma_buf); +return 0 ; fail:
drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +4 -0
@@ -190,6 +190,9 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); + attach =dma_buf_attach (dma_buf, drm_dev->dev);if (IS_ERR (attach))return ERR_PTR (-EINVAL );
@@ -250,6 +253,7 @@ err_unmap_attach:dma_buf_unmap_attachment (attach, sgt,DMA_BIDIRECTIONAL ); err_buf_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }
drivers/gpu/drm/i915/i915_gem_dmabuf.c +4 -0
@@ -189,6 +189,9 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))
@@ -224,5 +227,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }
drivers/gpu/drm/nouveau/nouveau_prime.c +5 -0
@@ -200,6 +200,10 @@ struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev, } } } + +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))
@@ -223,6 +227,7 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }
drivers/gpu/drm/radeon/radeon_prime.c +4 -0
@@ -195,6 +195,9 @@ struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))
@@ -218,5 +221,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }
drivers/gpu/drm/udl/udl_gem.c +4 -0
@@ -305,6 +305,9 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,struct udl_gem_object *uobj;int ret; +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))
@@ -329,5 +332,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }
Signature · 1 line
1.7.9.5
Dear Rob,
Am Montag, den 23.07.2012, 18:07 -0500 schrieb Rob Clark:
Quoted 21 lines
From: Rob Clark <[email protected]>
The GEM handle takes the reference. If a driver is actually importing a foreign dmabuf, rather than just re-importing it's own dmabuf, it needs to do a
get_dma_buf().Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_prime.c | 7 +++++++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_prime.c | 5 +++++ drivers/gpu/drm/radeon/radeon_prime.c | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 4 ++++ 6 files changed, 28 insertions(+)drivers/gpu/drm/drm_prime.c +0
-0
drivers/gpu/drm/drm_prime.c int drm_gem_prime_fd_to_handle(struct drm_device *dev, · line 190
Quoted 6 lines
drivers/gpu/drm/drm_prime.c +3
-0@@ -185,6 +185,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,mutex_unlock (&file_priv->prime.lock);drm_gem_object_unreference_unlocked (obj); +/* +* Drop the ref we obtained w/ dma_buf_get() for the benefit of +* drivers simply re-importing their own dma-buf.. if drivers
Is that supposed to be an ellipse or a full stop?
drivers/gpu/drm/drm_prime.c int drm_gem_prime_fd_to_handle(struct drm_device *dev, · line 191
Quoted 1 line
drivers/gpu/drm/drm_prime.c +1
-0+* import a foreign dma-buf, they should get_dma_buf().
Would s,should,should use, be better?
drivers/gpu/drm/drm_prime.c int drm_gem_prime_fd_to_handle(struct drm_device *dev, · line 197
Quoted 6 lines
drivers/gpu/drm/drm_prime.c +3
-0+*/ +dma_buf_put (dma_buf); +return 0 ; fail:
[…]
Thanks,
Paul
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Rob Clark
From: Rob Clark <[email protected]>
The GEM handle takes the reference. If a driver is actually importing a foreign dmabuf, rather than just re-importing it's own dmabuf, it needs to do a
get_dma_buf().Signed-off-by Rob Clark <[email protected]>
[Maybe mention that this is on top of my locking fixes.]
We've discussed this a bit on irc and concluded that every function taking care of their own references to the dma buf works best in avoiding potential use-after-free issues when evil userspaces sneaks in a close(dma_buf_fd).
Quoted 142 lines
--- drivers/gpu/drm/drm_prime.c | 7 +++++++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_prime.c | 5 +++++ drivers/gpu/drm/radeon/radeon_prime.c | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 4 ++++ 6 files changed, 28 insertions(+)drivers/gpu/drm/drm_prime.c +7
-0@@ -185,6 +185,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,mutex_unlock (&file_priv->prime.lock);drm_gem_object_unreference_unlocked (obj); +/* +* Drop the ref we obtained w/ dma_buf_get() for the benefit of +* drivers simply re-importing their own dma-buf.. if drivers +* import a foreign dma-buf, they should get_dma_buf(). +*/ +dma_buf_put (dma_buf); +return 0 ; fail:drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +4
-0@@ -190,6 +190,9 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); + attach =dma_buf_attach (dma_buf, drm_dev->dev);if (IS_ERR (attach))return ERR_PTR (-EINVAL );@@ -250,6 +253,7 @@ err_unmap_attach:dma_buf_unmap_attachment (attach, sgt,DMA_BIDIRECTIONAL ); err_buf_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/i915/i915_gem_dmabuf.c +4
-0@@ -189,6 +189,9 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -224,5 +227,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/nouveau/nouveau_prime.c +5
-0@@ -200,6 +200,10 @@ struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev, } } } + +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -223,6 +227,7 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/radeon/radeon_prime.c +4
-0@@ -195,6 +195,9 @@ struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -218,5 +221,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/udl/udl_gem.c +4
-1@@ -305,6 +305,9 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,struct udl_gem_object *uobj;int ret; +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -329,5 +332,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); } --1.7.9.5
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Daniel Vetter [email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
Dave, I just noticed that I still have this patch locally, but don't see it in drm-next.. so just checking that it didn't get forgotten
BR,
-R
Quoted 168 lines · Daniel Vetter
Quoted 7 lines · Rob Clark
From: Rob Clark <[email protected]>
The GEM handle takes the reference. If a driver is actually importing a foreign dmabuf, rather than just re-importing it's own dmabuf, it needs to do a
get_dma_buf().Signed-off-by Rob Clark <[email protected]>[Maybe mention that this is on top of my locking fixes.]
We've discussed this a bit on irc and concluded that every function taking care of their own references to the dma buf works best in avoiding potential use-after-free issues when evil userspaces sneaks in a
close(dma_buf_fd).Reviewed-by Daniel Vetter <[email protected]>Quoted 138 lines
--- drivers/gpu/drm/drm_prime.c | 7 +++++++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_prime.c | 5 +++++ drivers/gpu/drm/radeon/radeon_prime.c | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 4 ++++ 6 files changed, 28 insertions(+)drivers/gpu/drm/drm_prime.c +7
-0@@ -185,6 +185,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,mutex_unlock (&file_priv->prime.lock);drm_gem_object_unreference_unlocked (obj); +/* +* Drop the ref we obtained w/ dma_buf_get() for the benefit of +* drivers simply re-importing their own dma-buf.. if drivers +* import a foreign dma-buf, they should get_dma_buf(). +*/ +dma_buf_put (dma_buf); +return 0 ; fail:drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +4
-0@@ -190,6 +190,9 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); + attach =dma_buf_attach (dma_buf, drm_dev->dev);if (IS_ERR (attach))return ERR_PTR (-EINVAL );@@ -250,6 +253,7 @@ err_unmap_attach:dma_buf_unmap_attachment (attach, sgt,DMA_BIDIRECTIONAL ); err_buf_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/i915/i915_gem_dmabuf.c +4
-0@@ -189,6 +189,9 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -224,5 +227,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/nouveau/nouveau_prime.c +5
-0@@ -200,6 +200,10 @@ struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev, } } } + +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -223,6 +227,7 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/radeon/radeon_prime.c +4
-0@@ -195,6 +195,9 @@ struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -218,5 +221,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/udl/udl_gem.c +4
-1@@ -305,6 +305,9 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,struct udl_gem_object *uobj;int ret; +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -329,5 +332,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); } --1.7.9.5
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
[email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Rob Clark
Dave, I just noticed that I still have this patch locally, but don't see it in drm-next.. so just checking that it didn't get forgotten
My locking fixes blew up :(
-Daniel
Quoted 177 lines
BR,
-RQuoted 154 lines · Daniel Vetter
Quoted 7 lines · Rob Clark
From: Rob Clark <[email protected]>
The GEM handle takes the reference. If a driver is actually importing a foreign dmabuf, rather than just re-importing it's own dmabuf, it needs to do a
get_dma_buf().Signed-off-by Rob Clark <[email protected]>[Maybe mention that this is on top of my locking fixes.]
We've discussed this a bit on irc and concluded that every function taking care of their own references to the dma buf works best in avoiding potential use-after-free issues when evil userspaces sneaks in a
close(dma_buf_fd).Reviewed-by Daniel Vetter <[email protected]>Quoted 138 lines
--- drivers/gpu/drm/drm_prime.c | 7 +++++++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_prime.c | 5 +++++ drivers/gpu/drm/radeon/radeon_prime.c | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 4 ++++ 6 files changed, 28 insertions(+)drivers/gpu/drm/drm_prime.c +7
-0@@ -185,6 +185,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,mutex_unlock (&file_priv->prime.lock);drm_gem_object_unreference_unlocked (obj); +/* +* Drop the ref we obtained w/ dma_buf_get() for the benefit of +* drivers simply re-importing their own dma-buf.. if drivers +* import a foreign dma-buf, they should get_dma_buf(). +*/ +dma_buf_put (dma_buf); +return 0 ; fail:drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +4
-0@@ -190,6 +190,9 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); + attach =dma_buf_attach (dma_buf, drm_dev->dev);if (IS_ERR (attach))return ERR_PTR (-EINVAL );@@ -250,6 +253,7 @@ err_unmap_attach:dma_buf_unmap_attachment (attach, sgt,DMA_BIDIRECTIONAL ); err_buf_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/i915/i915_gem_dmabuf.c +4
-0@@ -189,6 +189,9 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -224,5 +227,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/nouveau/nouveau_prime.c +5
-0@@ -200,6 +200,10 @@ struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev, } } } + +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -223,6 +227,7 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/radeon/radeon_prime.c +4
-0@@ -195,6 +195,9 @@ struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -218,5 +221,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/udl/udl_gem.c +4
-1@@ -305,6 +305,9 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,struct udl_gem_object *uobj;int ret; +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -329,5 +332,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); } --1.7.9.5
Quoted 14 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
[email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Quoted 5 lines · Daniel Vetter
Quoted 2 lines · Rob Clark
Dave, I just noticed that I still have this patch locally, but don't see it in drm-next.. so just checking that it didn't get forgotten
My locking fixes blew up :(
oh, ok.. I guess there was a thread that I missed..
BR,
-R
Quoted 188 lines
-Daniel
Quoted 173 lines
BR,
-RQuoted 154 lines · Daniel Vetter
Quoted 7 lines · Rob Clark
From: Rob Clark <[email protected]>
The GEM handle takes the reference. If a driver is actually importing a foreign dmabuf, rather than just re-importing it's own dmabuf, it needs to do a
get_dma_buf().Signed-off-by Rob Clark <[email protected]>[Maybe mention that this is on top of my locking fixes.]
We've discussed this a bit on irc and concluded that every function taking care of their own references to the dma buf works best in avoiding potential use-after-free issues when evil userspaces sneaks in a
close(dma_buf_fd).Reviewed-by Daniel Vetter <[email protected]>Quoted 138 lines
--- drivers/gpu/drm/drm_prime.c | 7 +++++++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_prime.c | 5 +++++ drivers/gpu/drm/radeon/radeon_prime.c | 4 ++++ drivers/gpu/drm/udl/udl_gem.c | 4 ++++ 6 files changed, 28 insertions(+)drivers/gpu/drm/drm_prime.c +7
-0@@ -185,6 +185,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,mutex_unlock (&file_priv->prime.lock);drm_gem_object_unreference_unlocked (obj); +/* +* Drop the ref we obtained w/ dma_buf_get() for the benefit of +* drivers simply re-importing their own dma-buf.. if drivers +* import a foreign dma-buf, they should get_dma_buf(). +*/ +dma_buf_put (dma_buf); +return 0 ; fail:drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +4
-0@@ -190,6 +190,9 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); + attach =dma_buf_attach (dma_buf, drm_dev->dev);if (IS_ERR (attach))return ERR_PTR (-EINVAL );@@ -250,6 +253,7 @@ err_unmap_attach:dma_buf_unmap_attachment (attach, sgt,DMA_BIDIRECTIONAL ); err_buf_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/i915/i915_gem_dmabuf.c +4
-0@@ -189,6 +189,9 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -224,5 +227,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/nouveau/nouveau_prime.c +5
-0@@ -200,6 +200,10 @@ struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev, } } } + +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -223,6 +227,7 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/radeon/radeon_prime.c +4
-0@@ -195,6 +195,9 @@ struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, } } +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -218,5 +221,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); }drivers/gpu/drm/udl/udl_gem.c +4
-1@@ -305,6 +305,9 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,struct udl_gem_object *uobj;int ret; +/* since we are attaching, we need to hold a ref */ +get_dma_buf (dma_buf); +/* need to attach */ attach =dma_buf_attach (dma_buf, dev->dev);if (IS_ERR (attach))@@ -329,5 +332,6 @@ fail_unmap:dma_buf_unmap_attachment (attach, sg,DMA_BIDIRECTIONAL ); fail_detach:dma_buf_detach (dma_buf, attach); +dma_buf_put (dma_buf);return ERR_PTR (ret); } --1.7.9.5
Quoted 14 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
[email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-develQuoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel