On Mon Jun 16 18:30:38 2025 +0200, Jacopo Mondi wrote:
> To detect leaks of display lists, store in the display list manager the
> number of allocated display lists when the manager is created and verify
> that when the display manager is reset the same number of lists is
> available in the free list.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi+rene...@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> Link: 
> https://lore.kernel.org/r/20250616-vsp1_dl_list_count-v2-2-7d3f43fb1...@ideasonboard.com
> Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/platform/renesas/vsp1/vsp1_dl.c | 9 +++++++++
 1 file changed, 9 insertions(+)

---

diff --git a/drivers/media/platform/renesas/vsp1/vsp1_dl.c 
b/drivers/media/platform/renesas/vsp1/vsp1_dl.c
index 18617cbb1687..c660f8539ff5 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_dl.c
@@ -215,6 +215,7 @@ struct vsp1_dl_list {
  * @pending: list waiting to be queued to the hardware
  * @pool: body pool for the display list bodies
  * @cmdpool: commands pool for extended display list
+ * @list_count: number of allocated display lists
  */
 struct vsp1_dl_manager {
        unsigned int index;
@@ -229,6 +230,8 @@ struct vsp1_dl_manager {
 
        struct vsp1_dl_body_pool *pool;
        struct vsp1_dl_cmd_pool *cmdpool;
+
+       size_t list_count;
 };
 
 /* 
-----------------------------------------------------------------------------
@@ -1078,6 +1081,7 @@ void vsp1_dlm_setup(struct vsp1_device *vsp1)
 void vsp1_dlm_reset(struct vsp1_dl_manager *dlm)
 {
        unsigned long flags;
+       size_t list_count;
 
        spin_lock_irqsave(&dlm->lock, flags);
 
@@ -1085,8 +1089,11 @@ void vsp1_dlm_reset(struct vsp1_dl_manager *dlm)
        __vsp1_dl_list_put(dlm->queued);
        __vsp1_dl_list_put(dlm->pending);
 
+       list_count = list_count_nodes(&dlm->free);
        spin_unlock_irqrestore(&dlm->lock, flags);
 
+       WARN_ON_ONCE(list_count != dlm->list_count);
+
        dlm->active = NULL;
        dlm->queued = NULL;
        dlm->pending = NULL;
@@ -1156,6 +1163,8 @@ struct vsp1_dl_manager *vsp1_dlm_create(struct 
vsp1_device *vsp1,
                list_add_tail(&dl->list, &dlm->free);
        }
 
+       dlm->list_count = prealloc;
+
        if (vsp1_feature(vsp1, VSP1_HAS_EXT_DL)) {
                dlm->cmdpool = vsp1_dl_cmd_pool_create(vsp1,
                                        VSP1_EXTCMD_AUTOFLD, prealloc);

Reply via email to