summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-14 22:02:42 (GMT)
committerInki Dae <inki.dae@samsung.com>2014-10-15 11:05:12 (GMT)
commitbaf526df86a1a9add07cda6e80ca6b301ab81aa7 (patch)
treedf8940f26f84a0fd05ec8e4cbd1bb4d3fb74cfbc
parentd0e392e209c23bb05cd22d967ac626ac60ba9c27 (diff)
downloadlinux-3.10-baf526df86a1a9add07cda6e80ca6b301ab81aa7.zip
linux-3.10-baf526df86a1a9add07cda6e80ca6b301ab81aa7.tar.gz
linux-3.10-baf526df86a1a9add07cda6e80ca6b301ab81aa7.tar.bz2
drm/prime: shrink critical section protected by prime lock
When exporting a gem object as a dma-buf the critical section for the per-fd prime lock is just the adding (and in case of errors, removing) of the handle to the per-fd lookup cache. So restrict the critical section to just that part of the function. This simplifies later reordering. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_prime.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 3a92bed..cf38430 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -310,7 +310,6 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
if (!obj)
return -ENOENT;
- mutex_lock(&file_priv->prime.lock);
/* re-export the original imported object */
if (obj->import_attach) {
dmabuf = obj->import_attach->dmabuf;
@@ -332,6 +331,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
}
obj->export_dma_buf = dmabuf;
+ mutex_lock(&file_priv->prime.lock);
/* if we've exported this buffer the cheat and add it to the import list
* so we get the correct handle back
*/
@@ -363,13 +363,13 @@ out_have_obj:
fail_rm_handle:
drm_prime_remove_buf_handle_locked(&file_priv->prime,
dmabuf);
+ mutex_unlock(&file_priv->prime.lock);
fail_put_dmabuf:
/* clear NOT to be checked when releasing dma_buf */
obj->export_dma_buf = NULL;
dma_buf_put(dmabuf);
out:
drm_gem_object_unreference_unlocked(obj);
- mutex_unlock(&file_priv->prime.lock);
return ret;
}
EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);