summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_prime.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2013-04-09 09:18:44 +0200
committerDave Airlie <airlied@redhat.com>2013-06-11 07:51:11 +1000
commit102d6dba306c825cd5c310f73868b130931f47aa (patch)
tree75346aaa4f291511fa64a94132813678f9cefd09 /drivers/gpu/drm/drm_prime.c
parent328a4719b6a0930721b5f8d5c69993d3b6e3913f (diff)
downloadlinux-102d6dba306c825cd5c310f73868b130931f47aa.tar.bz2
drm: add unpin function to prime helpers
Prevents buffers from being pinned forever. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_prime.c')
-rw-r--r--drivers/gpu/drm/drm_prime.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index dcde35231e25..1a36b0c22732 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -92,10 +92,13 @@ static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
static void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
{
struct drm_gem_object *obj = dma_buf->priv;
+ struct drm_device *dev = obj->dev;
if (obj->export_dma_buf == dma_buf) {
/* drop the reference on the export fd holds */
obj->export_dma_buf = NULL;
+ if (dev->driver->gem_prime_unpin)
+ dev->driver->gem_prime_unpin(obj);
drm_gem_object_unreference_unlocked(obj);
}
}
@@ -185,13 +188,19 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = {
struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *obj, int flags)
{
+ struct dma_buf *buf;
+
if (dev->driver->gem_prime_pin) {
int ret = dev->driver->gem_prime_pin(obj);
if (ret)
return ERR_PTR(ret);
}
- return dma_buf_export(obj, &drm_gem_prime_dmabuf_ops, obj->size,
- 0600);
+ buf = dma_buf_export(obj, &drm_gem_prime_dmabuf_ops, obj->size,
+ 0600);
+
+ if (IS_ERR(buf) && dev->driver->gem_prime_unpin)
+ dev->driver->gem_prime_unpin(obj);
+ return buf;
}
EXPORT_SYMBOL(drm_gem_prime_export);