Skip to content

Commit 07a2975

Browse files
committed
drm/vc4: bo: Fix drmm_mutex_init memory hog
Commit 374146c ("drm/vc4: Switch to drmm_mutex_init") converted, among other functions, vc4_create_object() to use drmm_mutex_init(). However, that function is used to allocate a BO, and therefore the mutex needs to be freed much sooner than when the DRM device is removed from the system. For each buffer allocation we thus end up allocating a small structure as part of the DRM-managed mechanism that is never freed, eventually leading us to no longer having any free memory anymore. Let's switch back to mutex_init/mutex_destroy to deal with it properly. Fixes: 374146c ("drm/vc4: Switch to drmm_mutex_init") Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 5640e81 commit 07a2975

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/gpu/drm/vc4/vc4_bo.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static void vc4_bo_destroy(struct vc4_bo *bo)
179179
bo->validated_shader = NULL;
180180
}
181181

182+
mutex_destroy(&bo->madv_lock);
182183
drm_gem_dma_free(&bo->base);
183184
}
184185

@@ -406,9 +407,7 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
406407
bo->madv = VC4_MADV_WILLNEED;
407408
refcount_set(&bo->usecnt, 0);
408409

409-
ret = drmm_mutex_init(dev, &bo->madv_lock);
410-
if (ret)
411-
return ERR_PTR(ret);
410+
mutex_init(&bo->madv_lock);
412411

413412
mutex_lock(&vc4->bo_lock);
414413
bo->label = VC4_BO_TYPE_KERNEL;

0 commit comments

Comments
 (0)