public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
To: Dan Scally <dan.scally@ideasonboard.com>
Cc: "Jacopo Mondi" <jacopo.mondi@ideasonboard.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
	"Biju Das" <biju.das.jz@bp.renesas.com>,
	"Hans Verkuil" <hverkuil+cisco@kernel.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Barnabás Pőcze" <pobrn@protonmail.com>,
	"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jacopo Mondi" <jacopo.mondi+renesas@ideasonboard.com>
Subject: Re: [PATCH 09/14] media: rzg2l-cru: Split hw locking from buffers
Date: Mon, 30 Mar 2026 18:09:08 +0200	[thread overview]
Message-ID: <acqgJP1unNZ5DV1U@tom-desktop> (raw)
In-Reply-To: <aebf7c60-c478-4952-83ef-d7e9cf98cd1d@ideasonboard.com>

On Mon, Mar 30, 2026 at 12:19:00PM +0100, Dan Scally wrote:
> Hi Jacopo
> 
> On 27/03/2026 17:10, Jacopo Mondi wrote:
> > From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> > 
> > Split the locking between a spinlock dedicated to protect the hardware
> > slots programming (hw_lock) and one lock (qlock) to protect the queue of
> > buffers submitted by userspace.
> > 
> > Do not rework the locking strategy yet but start simply by splitting the
> > locking in two.
> > 
> > Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> > ---
> >   .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 32 +++++++++++++---------
> >   1 file changed, 19 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > index a79b17e146bf..9406a089ec9f 100644
> > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > @@ -112,19 +112,21 @@ static void return_unused_buffers(struct rzg2l_cru_dev *cru,
> >   	struct rzg2l_cru_buffer *buf, *node;
> >   	unsigned int i;
> > -	guard(spinlock_irq)(&cru->qlock);
> > -
> > -	for (i = 0; i < cru->num_buf; i++) {
> > -		if (cru->queue_buf[i]) {
> > -			vb2_buffer_done(&cru->queue_buf[i]->vb2_buf,
> > -					state);
> > -			cru->queue_buf[i] = NULL;
> > +	scoped_guard(spinlock_irq, &cru->hw_lock) {
> > +		for (i = 0; i < cru->num_buf; i++) {
> > +			if (cru->queue_buf[i]) {
> > +				vb2_buffer_done(&cru->queue_buf[i]->vb2_buf,
> > +						state);
> > +				cru->queue_buf[i] = NULL;
> > +			}
> >   		}
> >   	}
> > -	list_for_each_entry_safe(buf, node, &cru->buf_list, list) {
> > -		vb2_buffer_done(&buf->vb.vb2_buf, state);
> > -		list_del(&buf->list);
> > +	scoped_guard(spinlock_irq, &cru->qlock) {
> > +		list_for_each_entry_safe(buf, node, &cru->buf_list, list) {
> > +			vb2_buffer_done(&buf->vb.vb2_buf, state);
> > +			list_del(&buf->list);
> > +		}
> >   	}
> >   }
> > @@ -198,12 +200,16 @@ static void rzg2l_cru_fill_hw_slot(struct rzg2l_cru_dev *cru, int slot)
> >   	struct rzg2l_cru_buffer *buf;
> >   	dma_addr_t phys_addr;
> > +	lockdep_assert_held(&cru->hw_lock);
> 
> I think this condition mightn't be true at the point of this commit; as far
> as I can see this function is called without hw_lock being held in
> rzg2l_cru_initialize_axi() until patch 12.

Agree.

Kind Regards,
Tommaso

> 
> > +
> >   	/* A already populated slot shall never be overwritten. */
> >   	if (WARN_ON(cru->queue_buf[slot]))
> >   		return;
> >   	dev_dbg(cru->dev, "Filling HW slot: %d\n", slot);
> > +	guard(spinlock)(&cru->qlock);
> > +
> >   	if (list_empty(&cru->buf_list)) {
> >   		cru->queue_buf[slot] = NULL;
> >   		phys_addr = cru->scratch_phys;
> > @@ -342,7 +348,7 @@ void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru)
> >   	unsigned int retries = 0;
> >   	u32 icnms;
> > -	scoped_guard(spinlock_irq, &cru->qlock) {
> > +	scoped_guard(spinlock_irq, &cru->hw_lock) {
> >   		/* Disable and clear the interrupt */
> >   		cru->info->disable_interrupts(cru);
> >   	}
> > @@ -560,7 +566,7 @@ irqreturn_t rzg2l_cru_irq(int irq, void *data)
> >   	u32 amnmbs;
> >   	int slot;
> > -	guard(spinlock_irqsave)(&cru->qlock);
> > +	guard(spinlock_irqsave)(&cru->hw_lock);
> >   	irq_status = rzg2l_cru_read(cru, CRUnINTS);
> >   	if (!irq_status)
> > @@ -662,7 +668,7 @@ irqreturn_t rzg3e_cru_irq(int irq, void *data)
> >   	u32 irq_status;
> >   	int slot;
> > -	guard(spinlock)(&cru->qlock);
> > +	guard(spinlock)(&cru->hw_lock);
> >   	irq_status = rzg2l_cru_read(cru, CRUnINTS2);
> >   	if (!irq_status)
> > 
> 

  reply	other threads:[~2026-03-30 16:09 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27 17:10 [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E Jacopo Mondi
2026-03-27 17:10 ` [PATCH 01/14] media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used Jacopo Mondi
2026-03-30 15:51   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 02/14] media: rzg2l-cru: Use only frame end interrupts Jacopo Mondi
2026-03-30 15:55   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 03/14] media: rzg2l-cru: Modernize spin_lock usage with cleanup.h Jacopo Mondi
2026-03-30  7:30   ` Dan Scally
2026-03-30 11:12   ` Tommaso Merciai
2026-03-30 11:41     ` Biju Das
2026-03-31  7:18       ` Jacopo Mondi
2026-03-30 18:43   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 04/14] media: rzg2l-cru: Use proper guard() in irq handler Jacopo Mondi
2026-03-30  7:32   ` Dan Scally
2026-03-30 11:15   ` Tommaso Merciai
2026-03-30 19:00   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 05/14] media: rzg2l-cru: Remove locking from start/stop routines Jacopo Mondi
2026-03-30 13:29   ` Tommaso Merciai
2026-03-30 13:47   ` Dan Scally
2026-03-30 19:04   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 06/14] media: rzg2l-cru: Do not use irqsave when not needed Jacopo Mondi
2026-03-30  7:50   ` Dan Scally
2026-03-30 13:52   ` Tommaso Merciai
2026-03-31  7:46   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 07/14] media: rzg2l-cru: Remove wrong locking comment Jacopo Mondi
2026-03-30  7:38   ` Dan Scally
2026-03-30 13:54   ` Tommaso Merciai
2026-03-31  7:47   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 08/14] media: rz2gl-cru: Introduce a spinlock for hw operations Jacopo Mondi
2026-03-30 10:46   ` Dan Scally
2026-03-30 16:17   ` Tommaso Merciai
2026-03-31  8:11   ` Lad, Prabhakar
2026-03-27 17:10 ` [PATCH 09/14] media: rzg2l-cru: Split hw locking from buffers Jacopo Mondi
2026-03-30 11:19   ` Dan Scally
2026-03-30 16:09     ` Tommaso Merciai [this message]
2026-03-27 17:10 ` [PATCH 10/14] media: rzg2l-cru: Manually track active slot number Jacopo Mondi
2026-03-30 13:39   ` Dan Scally
2026-03-30 16:25   ` Tommaso Merciai
2026-03-31  7:43     ` Jacopo Mondi
2026-03-31  8:30   ` Lad, Prabhakar
2026-03-31 10:03     ` Jacopo Mondi
2026-03-31 10:05       ` Jacopo Mondi
2026-03-27 17:10 ` [PATCH 11/14] media: rz2gl-cru: Return pending buffers in order Jacopo Mondi
2026-03-30 13:52   ` Dan Scally
2026-03-30 17:14   ` Tommaso Merciai
2026-03-27 17:10 ` [PATCH 12/14] media: rzg2l-cru: Rework rzg2l_cru_fill_hw_slot() Jacopo Mondi
2026-03-27 17:10 ` [PATCH 13/14] media: rzg2l-cru: Remove the 'state' variable Jacopo Mondi
2026-03-30 11:55   ` Dan Scally
2026-03-31  7:45     ` Jacopo Mondi
2026-03-27 17:10 ` [PATCH 14/14] media: rzg2l-cru: Simplify irq return value handling Jacopo Mondi
2026-03-30 11:55   ` Dan Scally
2026-03-30 17:24   ` Tommaso Merciai
2026-03-27 17:25 ` [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E Lad, Prabhakar
2026-03-28 11:55   ` Jacopo Mondi
2026-03-28 12:56     ` Lad, Prabhakar

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=acqgJP1unNZ5DV1U@tom-desktop \
    --to=tommaso.merciai.xr@bp.renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=jacopo.mondi+renesas@ideasonboard.com \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=pobrn@protonmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sakari.ailus@linux.intel.com \
    /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