The BO cache pairs a timer with a work item whose only job is to schedule
the work on expiry. The common kernel structure `delayed_work` provides
this directly, so use it and drop the timer callback.

No functional change.

Signed-off-by: Maíra Canal <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_bo.c  | 24 +++++++-----------------
 drivers/gpu/drm/vc4/vc4_drv.h |  3 +--
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index da4b11b7ce9f..360518b46381 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -526,9 +526,9 @@ static void vc4_bo_cache_free_old(struct drm_device *dev)
                struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
                                                    struct vc4_bo, unref_head);
                if (time_before(expire_time, bo->free_time)) {
-                       mod_timer(&vc4->bo_cache.time_timer,
-                                 round_jiffies_up(jiffies +
-                                                  msecs_to_jiffies(1000)));
+                       mod_delayed_work(system_percpu_wq,
+                                        &vc4->bo_cache.time_work,
+                                        round_jiffies_up_relative(HZ));
                        return;
                }
 
@@ -608,8 +608,8 @@ static void vc4_free_object(struct drm_gem_object *gem_bo)
 
 static void vc4_bo_cache_time_work(struct work_struct *work)
 {
-       struct vc4_dev *vc4 =
-               container_of(work, struct vc4_dev, bo_cache.time_work);
+       struct vc4_dev *vc4 = container_of(to_delayed_work(work),
+                                          struct vc4_dev, bo_cache.time_work);
        struct drm_device *dev = &vc4->base;
 
        mutex_lock(&vc4->bo_lock);
@@ -677,13 +677,6 @@ void vc4_bo_dec_usecnt(struct vc4_bo *bo)
        mutex_unlock(&bo->madv_lock);
 }
 
-static void vc4_bo_cache_time_timer(struct timer_list *t)
-{
-       struct vc4_dev *vc4 = timer_container_of(vc4, t, bo_cache.time_timer);
-
-       schedule_work(&vc4->bo_cache.time_work);
-}
-
 static struct dma_buf *vc4_prime_export(struct drm_gem_object *obj, int flags)
 {
        struct vc4_bo *bo = to_vc4_bo(obj);
@@ -1037,9 +1030,7 @@ int vc4_bo_cache_init(struct drm_device *dev)
        }
 
        INIT_LIST_HEAD(&vc4->bo_cache.time_list);
-
-       INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
-       timer_setup(&vc4->bo_cache.time_timer, vc4_bo_cache_time_timer, 0);
+       INIT_DELAYED_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
 
        return drmm_add_action_or_reset(dev, vc4_bo_cache_destroy, NULL);
 }
@@ -1049,8 +1040,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, 
void *unused)
        struct vc4_dev *vc4 = to_vc4_dev(dev);
        int i;
 
-       timer_shutdown_sync(&vc4->bo_cache.time_timer);
-       cancel_work_sync(&vc4->bo_cache.time_work);
+       disable_delayed_work_sync(&vc4->bo_cache.time_work);
 
        vc4_bo_cache_purge(dev);
        kvfree(vc4->bo_cache.size_list);
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index d428c10a7ae4..f122f2987853 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -120,8 +120,7 @@ struct vc4_dev {
                 * buffers.
                 */
                struct list_head time_list;
-               struct work_struct time_work;
-               struct timer_list time_timer;
+               struct delayed_work time_work;
        } bo_cache;
 
        u32 num_labels;
-- 
2.56.1

Reply via email to