diff options
author | Seung-Woo Kim <sw0312.kim@samsung.com> | 2012-09-27 02:30:06 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-01-07 23:41:53 -0500 |
commit | be8a42ae60addd8b6092535c11b42d099d6470ec (patch) | |
tree | f8fe5dc8c565f9ad02c7f129bf8ad091a4b0581e /drivers | |
parent | f3215be950e40fede0dffb8534729fe0bf410727 (diff) |
drm/prime: drop reference on imported dma-buf come from gem
Increasing ref counts of both dma-buf and gem for imported dma-buf come from gem
makes memory leak. release function of dma-buf cannot be called because f_count
of dma-buf increased by importing gem and gem ref count cannot be decrease
because of exported dma-buf.
So I add dma_buf_put() for imported gem come from its own gem into each drivers
having prime_import and prime_export capabilities. With this, only gem ref
count is increased if importing gem exported from gem of same driver.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin.park <kyungmin.park@samsung.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Rob Clark <rob.clark@linaro.org>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_dmabuf.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_prime.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_prime.c | 1 | ||||
-rw-r--r-- | drivers/staging/omapdrm/omap_gem_dmabuf.c | 5 |
5 files changed, 17 insertions, 0 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index 315037af7fe0..9df97714b6c0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | |||
@@ -232,7 +232,12 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, | |||
232 | 232 | ||
233 | /* is it from our device? */ | 233 | /* is it from our device? */ |
234 | if (obj->dev == drm_dev) { | 234 | if (obj->dev == drm_dev) { |
235 | /* | ||
236 | * Importing dmabuf exported from out own gem increases | ||
237 | * refcount on gem itself instead of f_count of dmabuf. | ||
238 | */ | ||
235 | drm_gem_object_reference(obj); | 239 | drm_gem_object_reference(obj); |
240 | dma_buf_put(dma_buf); | ||
236 | return obj; | 241 | return obj; |
237 | } | 242 | } |
238 | } | 243 | } |
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c index 7be4241e8242..abeaafef6d7e 100644 --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c | |||
@@ -266,7 +266,12 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, | |||
266 | obj = dma_buf->priv; | 266 | obj = dma_buf->priv; |
267 | /* is it from our device? */ | 267 | /* is it from our device? */ |
268 | if (obj->base.dev == dev) { | 268 | if (obj->base.dev == dev) { |
269 | /* | ||
270 | * Importing dmabuf exported from out own gem increases | ||
271 | * refcount on gem itself instead of f_count of dmabuf. | ||
272 | */ | ||
269 | drm_gem_object_reference(&obj->base); | 273 | drm_gem_object_reference(&obj->base); |
274 | dma_buf_put(dma_buf); | ||
270 | return &obj->base; | 275 | return &obj->base; |
271 | } | 276 | } |
272 | } | 277 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c index 3543fec2355e..b8e05ae38212 100644 --- a/drivers/gpu/drm/nouveau/nouveau_prime.c +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c | |||
@@ -193,6 +193,7 @@ struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev, | |||
193 | if (nvbo->gem) { | 193 | if (nvbo->gem) { |
194 | if (nvbo->gem->dev == dev) { | 194 | if (nvbo->gem->dev == dev) { |
195 | drm_gem_object_reference(nvbo->gem); | 195 | drm_gem_object_reference(nvbo->gem); |
196 | dma_buf_put(dma_buf); | ||
196 | return nvbo->gem; | 197 | return nvbo->gem; |
197 | } | 198 | } |
198 | } | 199 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c index e09521858f64..26c23bb651c6 100644 --- a/drivers/gpu/drm/radeon/radeon_prime.c +++ b/drivers/gpu/drm/radeon/radeon_prime.c | |||
@@ -194,6 +194,7 @@ struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, | |||
194 | bo = dma_buf->priv; | 194 | bo = dma_buf->priv; |
195 | if (bo->gem_base.dev == dev) { | 195 | if (bo->gem_base.dev == dev) { |
196 | drm_gem_object_reference(&bo->gem_base); | 196 | drm_gem_object_reference(&bo->gem_base); |
197 | dma_buf_put(dma_buf); | ||
197 | return &bo->gem_base; | 198 | return &bo->gem_base; |
198 | } | 199 | } |
199 | } | 200 | } |
diff --git a/drivers/staging/omapdrm/omap_gem_dmabuf.c b/drivers/staging/omapdrm/omap_gem_dmabuf.c index 9a302062b031..ea3840038250 100644 --- a/drivers/staging/omapdrm/omap_gem_dmabuf.c +++ b/drivers/staging/omapdrm/omap_gem_dmabuf.c | |||
@@ -207,7 +207,12 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev, | |||
207 | obj = buffer->priv; | 207 | obj = buffer->priv; |
208 | /* is it from our device? */ | 208 | /* is it from our device? */ |
209 | if (obj->dev == dev) { | 209 | if (obj->dev == dev) { |
210 | /* | ||
211 | * Importing dmabuf exported from out own gem increases | ||
212 | * refcount on gem itself instead of f_count of dmabuf. | ||
213 | */ | ||
210 | drm_gem_object_reference(obj); | 214 | drm_gem_object_reference(obj); |
215 | dma_buf_put(buffer); | ||
211 | return obj; | 216 | return obj; |
212 | } | 217 | } |
213 | } | 218 | } |