Skip to content

Commit 1c80be4

Browse files
committed
drm/vc4: bo: Add a managed action to cleanup the cache
The BO cache needs to be cleaned up using vc4_bo_cache_destroy, but it's not used consistently (vc4_drv's bind calls it in its error path, but doesn't in unbind), and we can make that automatic through a managed action. Let's remove the requirement to call vc4_bo_cache_destroy. Fixes: c826a6e ("drm/vc4: Add a BO cache.") Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20201029190104.2181730-1-maxime@cerno.tech
1 parent 3cea11c commit 1c80be4

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/gpu/drm/vc4/vc4_bo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
10051005
return 0;
10061006
}
10071007

1008+
static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused);
10081009
int vc4_bo_cache_init(struct drm_device *dev)
10091010
{
10101011
struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -1033,10 +1034,10 @@ int vc4_bo_cache_init(struct drm_device *dev)
10331034
INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
10341035
timer_setup(&vc4->bo_cache.time_timer, vc4_bo_cache_time_timer, 0);
10351036

1036-
return 0;
1037+
return drmm_add_action_or_reset(dev, vc4_bo_cache_destroy, NULL);
10371038
}
10381039

1039-
void vc4_bo_cache_destroy(struct drm_device *dev)
1040+
static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)
10401041
{
10411042
struct vc4_dev *vc4 = to_vc4_dev(dev);
10421043
int i;

drivers/gpu/drm/vc4/vc4_drv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ static int vc4_drm_bind(struct device *dev)
315315
gem_destroy:
316316
vc4_gem_destroy(drm);
317317
drm_mode_config_cleanup(drm);
318-
vc4_bo_cache_destroy(drm);
319318
dev_put:
320319
drm_dev_put(drm);
321320
return ret;

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <drm/drm_device.h>
1515
#include <drm/drm_encoder.h>
1616
#include <drm/drm_gem_cma_helper.h>
17+
#include <drm/drm_managed.h>
1718
#include <drm/drm_mm.h>
1819
#include <drm/drm_modeset_lock.h>
1920

@@ -809,7 +810,6 @@ struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
809810
struct sg_table *sgt);
810811
void *vc4_prime_vmap(struct drm_gem_object *obj);
811812
int vc4_bo_cache_init(struct drm_device *dev);
812-
void vc4_bo_cache_destroy(struct drm_device *dev);
813813
int vc4_bo_inc_usecnt(struct vc4_bo *bo);
814814
void vc4_bo_dec_usecnt(struct vc4_bo *bo);
815815
void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo);

0 commit comments

Comments
 (0)