Commit db369729 authored by Daniel Vetter's avatar Daniel Vetter

drm/vc4: Use drm_gem_object_unreference_unlocked

Since my last struct_mutex crusade someone escaped!

This already has the advantage that for the common case when someone
else holds a ref the unref won't even acquire dev->struct_mutex. And
I'm working on code to allow drivers to completely opt-out of any and
all dev->struct_mutex usage, but that only works if they use the
_unlocked variants everywhere.

v2: Drop comment too.

v3: Drop the other comment too.

Cc: Eric Anholt <eric@anholt.net>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1464630800-30786-15-git-send-email-daniel.vetter@ffwll.ch
parent cf48e292
...@@ -291,8 +291,6 @@ static void vc4_bo_cache_free_old(struct drm_device *dev) ...@@ -291,8 +291,6 @@ static void vc4_bo_cache_free_old(struct drm_device *dev)
/* Called on the last userspace/kernel unreference of the BO. Returns /* Called on the last userspace/kernel unreference of the BO. Returns
* it to the BO cache if possible, otherwise frees it. * it to the BO cache if possible, otherwise frees it.
*
* Note that this is called with the struct_mutex held.
*/ */
void vc4_free_object(struct drm_gem_object *gem_bo) void vc4_free_object(struct drm_gem_object *gem_bo)
{ {
......
...@@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state) ...@@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state)
{ {
unsigned int i; unsigned int i;
mutex_lock(&dev->struct_mutex);
for (i = 0; i < state->user_state.bo_count; i++) for (i = 0; i < state->user_state.bo_count; i++)
drm_gem_object_unreference(state->bo[i]); drm_gem_object_unreference_unlocked(state->bo[i]);
mutex_unlock(&dev->struct_mutex);
kfree(state); kfree(state);
} }
...@@ -687,11 +685,9 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) ...@@ -687,11 +685,9 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
struct vc4_dev *vc4 = to_vc4_dev(dev); struct vc4_dev *vc4 = to_vc4_dev(dev);
unsigned i; unsigned i;
/* Need the struct lock for drm_gem_object_unreference(). */
mutex_lock(&dev->struct_mutex);
if (exec->bo) { if (exec->bo) {
for (i = 0; i < exec->bo_count; i++) for (i = 0; i < exec->bo_count; i++)
drm_gem_object_unreference(&exec->bo[i]->base); drm_gem_object_unreference_unlocked(&exec->bo[i]->base);
kfree(exec->bo); kfree(exec->bo);
} }
...@@ -699,9 +695,8 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) ...@@ -699,9 +695,8 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
struct vc4_bo *bo = list_first_entry(&exec->unref_list, struct vc4_bo *bo = list_first_entry(&exec->unref_list,
struct vc4_bo, unref_head); struct vc4_bo, unref_head);
list_del(&bo->unref_head); list_del(&bo->unref_head);
drm_gem_object_unreference(&bo->base.base); drm_gem_object_unreference_unlocked(&bo->base.base);
} }
mutex_unlock(&dev->struct_mutex);
mutex_lock(&vc4->power_lock); mutex_lock(&vc4->power_lock);
if (--vc4->power_refcount == 0) if (--vc4->power_refcount == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment