Skip to content

Commit db36972

Browse files
committed
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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent cf48e29 commit db36972

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

drivers/gpu/drm/vc4/vc4_bo.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ static void vc4_bo_cache_free_old(struct drm_device *dev)
291291

292292
/* Called on the last userspace/kernel unreference of the BO. Returns
293293
* it to the BO cache if possible, otherwise frees it.
294-
*
295-
* Note that this is called with the struct_mutex held.
296294
*/
297295
void vc4_free_object(struct drm_gem_object *gem_bo)
298296
{

drivers/gpu/drm/vc4/vc4_gem.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state)
5353
{
5454
unsigned int i;
5555

56-
mutex_lock(&dev->struct_mutex);
5756
for (i = 0; i < state->user_state.bo_count; i++)
58-
drm_gem_object_unreference(state->bo[i]);
59-
mutex_unlock(&dev->struct_mutex);
57+
drm_gem_object_unreference_unlocked(state->bo[i]);
6058

6159
kfree(state);
6260
}
@@ -687,21 +685,18 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
687685
struct vc4_dev *vc4 = to_vc4_dev(dev);
688686
unsigned i;
689687

690-
/* Need the struct lock for drm_gem_object_unreference(). */
691-
mutex_lock(&dev->struct_mutex);
692688
if (exec->bo) {
693689
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);
695691
kfree(exec->bo);
696692
}
697693

698694
while (!list_empty(&exec->unref_list)) {
699695
struct vc4_bo *bo = list_first_entry(&exec->unref_list,
700696
struct vc4_bo, unref_head);
701697
list_del(&bo->unref_head);
702-
drm_gem_object_unreference(&bo->base.base);
698+
drm_gem_object_unreference_unlocked(&bo->base.base);
703699
}
704-
mutex_unlock(&dev->struct_mutex);
705700

706701
mutex_lock(&vc4->power_lock);
707702
if (--vc4->power_refcount == 0)

0 commit comments

Comments
 (0)