Skip to content

Commit

Permalink
drm/prime: shrink critical section protected by prime lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Vetter authored and Dave Airlie committed Aug 21, 2013
1 parent 4332bf4 commit bdf655d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/drm_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*/
Expand Down Expand Up @@ -363,13 +363,13 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
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);
Expand Down

0 comments on commit bdf655d

Please sign in to comment.