Linux Media Controller development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] media: vsp1: vsp1_dl: Count display lists
Date: Mon, 16 Jun 2025 16:31:34 +0300	[thread overview]
Message-ID: <20250616133134.GC10542@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250529-vsp1_dl_list_count-v1-2-40c6d0e20592@ideasonboard.com>

Hi Jacopo,

Thank you for the patch.

On Thu, May 29, 2025 at 06:36:31PM +0200, Jacopo Mondi wrote:
> To detect invalid usage patterns of the display list helpers, store

We can be more precise:

"To detect leaks of display lists, ..."

> in the display list manager the number of available display lists

s/available/allocated/

> when the manager is created and verify that when the display manager
> is reset the same number of lists is available.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/vsp1/vsp1_dl.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_dl.c b/drivers/media/platform/renesas/vsp1/vsp1_dl.c
> index 8a3c0274a163..5c4eeb65216f 100644
> --- a/drivers/media/platform/renesas/vsp1/vsp1_dl.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_dl.c
> @@ -214,6 +214,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: display list counter

"number of allocated display lists"

>   */
>  struct vsp1_dl_manager {
>  	unsigned int index;
> @@ -228,6 +229,8 @@ struct vsp1_dl_manager {
>  
>  	struct vsp1_dl_body_pool *pool;
>  	struct vsp1_dl_cmd_pool *cmdpool;
> +
> +	size_t list_count;
>  };
>  
>  /* -----------------------------------------------------------------------------
> @@ -1073,7 +1076,9 @@ void vsp1_dlm_setup(struct vsp1_device *vsp1)
>  
>  void vsp1_dlm_reset(struct vsp1_dl_manager *dlm)
>  {
> +	size_t dlm_list_count;
>  	unsigned long flags;
> +	size_t list_count;
>  
>  	spin_lock_irqsave(&dlm->lock, flags);
>  
> @@ -1081,8 +1086,13 @@ 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);
> +	dlm_list_count = dlm->list_count;

dlm->list_count is not documented as protected by the lock. I don't
think that's an oversight, as it can only be set when the dlm is
created. You can drop the dlm_list_count variable and use
dlm->list_count below.

> +
>  	spin_unlock_irqrestore(&dlm->lock, flags);
>  
> +	WARN_ON_ONCE(list_count != dlm_list_count);
> +
>  	dlm->active = NULL;
>  	dlm->queued = NULL;
>  	dlm->pending = NULL;
> @@ -1150,6 +1160,7 @@ struct vsp1_dl_manager *vsp1_dlm_create(struct vsp1_device *vsp1,
>  				      + sizeof(*dl->header);
>  
>  		list_add_tail(&dl->list, &dlm->free);
> +		dlm->list_count = list_count_nodes(&dlm->free);

Does this need to be done inside the loop, can't you just write

	dlm->list_count = prealloc;

after the loop ?

>  	}
>  
>  	if (vsp1_feature(vsp1, VSP1_HAS_EXT_DL)) {

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2025-06-16 13:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 16:36 [PATCH 0/2] media: vsp1: Detect display list wrong usage patterns Jacopo Mondi
2025-05-29 16:36 ` [PATCH 1/2] media: vsp1: vsp1_dl: Add usage counter Jacopo Mondi
2025-06-16 13:20   ` Laurent Pinchart
2025-05-29 16:36 ` [PATCH 2/2] media: vsp1: vsp1_dl: Count display lists Jacopo Mondi
2025-06-16 13:31   ` Laurent Pinchart [this message]
2025-06-16 14:35     ` Jacopo Mondi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250616133134.GC10542@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=jacopo.mondi+renesas@ideasonboard.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox