Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/vc4: bo: Fix drmm_mutex_init memory hog

Commit 374146cad469 ("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: 374146cad469 ("drm/vc4: Switch to drmm_mutex_init")
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20230112091243.490799-1-maxime@cerno.tech

+2 -3
+2 -3
drivers/gpu/drm/vc4/vc4_bo.c
··· 179 179 bo->validated_shader = NULL; 180 180 } 181 181 182 + mutex_destroy(&bo->madv_lock); 182 183 drm_gem_dma_free(&bo->base); 183 184 } 184 185 ··· 407 406 bo->madv = VC4_MADV_WILLNEED; 408 407 refcount_set(&bo->usecnt, 0); 409 408 410 - ret = drmm_mutex_init(dev, &bo->madv_lock); 411 - if (ret) 412 - return ERR_PTR(ret); 409 + mutex_init(&bo->madv_lock); 413 410 414 411 mutex_lock(&vc4->bo_lock); 415 412 bo->label = VC4_BO_TYPE_KERNEL;