diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-05-30 13:53:06 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-05-31 15:13:23 -0400 |
commit | db3697295cf4da1356e3ec86761d464d6d013b48 (patch) | |
tree | 3a06cd5308a73e5fc25f5f58ceeadae4b2dd20ba | |
parent | cf48e2921ee95011a164dc31e8725022bd008666 (diff) |
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: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1464630800-30786-15-git-send-email-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_bo.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_gem.c | 11 |
2 files changed, 3 insertions, 10 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index e5a9d3aaf45f..59adcf8532dd 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c | |||
@@ -291,8 +291,6 @@ static void vc4_bo_cache_free_old(struct drm_device *dev) | |||
291 | 291 | ||
292 | /* Called on the last userspace/kernel unreference of the BO. Returns | 292 | /* Called on the last userspace/kernel unreference of the BO. Returns |
293 | * it to the BO cache if possible, otherwise frees it. | 293 | * it to the BO cache if possible, otherwise frees it. |
294 | * | ||
295 | * Note that this is called with the struct_mutex held. | ||
296 | */ | 294 | */ |
297 | void vc4_free_object(struct drm_gem_object *gem_bo) | 295 | void vc4_free_object(struct drm_gem_object *gem_bo) |
298 | { | 296 | { |
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 46899d6de675..6155e8aca1c6 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c | |||
@@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state) | |||
53 | { | 53 | { |
54 | unsigned int i; | 54 | unsigned int i; |
55 | 55 | ||
56 | mutex_lock(&dev->struct_mutex); | ||
57 | for (i = 0; i < state->user_state.bo_count; i++) | 56 | for (i = 0; i < state->user_state.bo_count; i++) |
58 | drm_gem_object_unreference(state->bo[i]); | 57 | drm_gem_object_unreference_unlocked(state->bo[i]); |
59 | mutex_unlock(&dev->struct_mutex); | ||
60 | 58 | ||
61 | kfree(state); | 59 | kfree(state); |
62 | } | 60 | } |
@@ -687,11 +685,9 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) | |||
687 | struct vc4_dev *vc4 = to_vc4_dev(dev); | 685 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
688 | unsigned i; | 686 | unsigned i; |
689 | 687 | ||
690 | /* Need the struct lock for drm_gem_object_unreference(). */ | ||
691 | mutex_lock(&dev->struct_mutex); | ||
692 | if (exec->bo) { | 688 | if (exec->bo) { |
693 | for (i = 0; i < exec->bo_count; i++) | 689 | for (i = 0; i < exec->bo_count; i++) |
694 | drm_gem_object_unreference(&exec->bo[i]->base); | 690 | drm_gem_object_unreference_unlocked(&exec->bo[i]->base); |
695 | kfree(exec->bo); | 691 | kfree(exec->bo); |
696 | } | 692 | } |
697 | 693 | ||
@@ -699,9 +695,8 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) | |||
699 | struct vc4_bo *bo = list_first_entry(&exec->unref_list, | 695 | struct vc4_bo *bo = list_first_entry(&exec->unref_list, |
700 | struct vc4_bo, unref_head); | 696 | struct vc4_bo, unref_head); |
701 | list_del(&bo->unref_head); | 697 | list_del(&bo->unref_head); |
702 | drm_gem_object_unreference(&bo->base.base); | 698 | drm_gem_object_unreference_unlocked(&bo->base.base); |
703 | } | 699 | } |
704 | mutex_unlock(&dev->struct_mutex); | ||
705 | 700 | ||
706 | mutex_lock(&vc4->power_lock); | 701 | mutex_lock(&vc4->power_lock); |
707 | if (--vc4->power_refcount == 0) | 702 | if (--vc4->power_refcount == 0) |