From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: "Tommaso Merciai" <tommaso.merciai.xr@bp.renesas.com>,
"jacopo.mondi" <jacopo.mondi@ideasonboard.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
"Hans Verkuil" <hverkuil+cisco@kernel.org>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"dan.scally" <dan.scally@ideasonboard.com>,
"Barnabás Pőcze" <pobrn@protonmail.com>,
"Prabhakar Mahadev Lad" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Jacopo Mondi" <jacopo.mondi+renesas@ideasonboard.com>
Subject: Re: [PATCH 03/14] media: rzg2l-cru: Modernize spin_lock usage with cleanup.h
Date: Tue, 31 Mar 2026 09:18:32 +0200 [thread overview]
Message-ID: <actzkO0E01pcKlDE@zed> (raw)
In-Reply-To: <TY3PR01MB1134607F4DCD0CC01345D8C368652A@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Hi Biju
On Mon, Mar 30, 2026 at 11:41:52AM +0000, Biju Das wrote:
> Hi Jacopo,
>
> > -----Original Message-----
> > From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > Sent: 30 March 2026 12:12
> > To: jacopo.mondi <jacopo.mondi@ideasonboard.com>
> > Cc: 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>; dan.scally
> > <dan.scally@ideasonboard.com>; Barnabás Pőcze <pobrn@protonmail.com>; Prabhakar Mahadev Lad
> > <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 03/14] media: rzg2l-cru: Modernize spin_lock usage with cleanup.h
> >
> > Hi Jacopo,
> > Thanks for your patch.
> >
> > On Fri, Mar 27, 2026 at 06:10:08PM +0100, Jacopo Mondi wrote:
> > > From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> > >
> > > Use more modern constructs from cleanup.h to express the locking
> > > sequences in the rzg2l driver.
> >
> >
> > Looks good to me.
> >
> > Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > Reviewed-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> >
> > Kind Regards,
> > Tommaso
> >
> > >
> > > Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> > > ---
> > > .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 32
> > > +++++++---------------
> > > 1 file changed, 10 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > index 98b6afbc708d..2d7ac9f37291 100644
> > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > @@ -11,6 +11,7 @@
> > > * Copyright (C) 2008 Magnus Damm
> > > */
> > >
> > > +#include <linux/cleanup.h>
>
>
> Not sure, asper comment from [1]
>
> The spinlock guards should come from spinlock.h
Oh you're right. spinlock.h provides the correct definitions for that
lock class using the constructs from cleanup.h.
I'll drop the include, thanks!
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=irq/drivers&id=9fd2170d70178faa0427adaa9d2dfdbfa231d1b7
>
> Cheers,
> Biju
>
> > > #include <linux/clk.h>
> > > #include <linux/delay.h>
> > > #include <linux/pm_runtime.h>
> > > @@ -110,10 +111,10 @@ static void return_unused_buffers(struct rzg2l_cru_dev *cru,
> > > enum vb2_buffer_state state)
> > > {
> > > struct rzg2l_cru_buffer *buf, *node;
> > > - unsigned long flags;
> > > unsigned int i;
> > >
> > > - spin_lock_irqsave(&cru->qlock, flags);
> > > + guard(spinlock_irqsave)(&cru->qlock);
> > > +
> > > for (i = 0; i < cru->num_buf; i++) {
> > > if (cru->queue_buf[i]) {
> > > vb2_buffer_done(&cru->queue_buf[i]->vb2_buf,
> > > @@ -126,7 +127,6 @@ static void return_unused_buffers(struct rzg2l_cru_dev *cru,
> > > vb2_buffer_done(&buf->vb.vb2_buf, state);
> > > list_del(&buf->list);
> > > }
> > > - spin_unlock_irqrestore(&cru->qlock, flags);
> > > }
> > >
> > > static int rzg2l_cru_queue_setup(struct vb2_queue *vq, unsigned int
> > > *nbuffers, @@ -165,13 +165,9 @@ static void
> > > rzg2l_cru_buffer_queue(struct vb2_buffer *vb) {
> > > struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> > > struct rzg2l_cru_dev *cru = vb2_get_drv_priv(vb->vb2_queue);
> > > - unsigned long flags;
> > > -
> > > - spin_lock_irqsave(&cru->qlock, flags);
> > >
> > > + guard(spinlock_irqsave)(&cru->qlock);
> > > list_add_tail(to_buf_list(vbuf), &cru->buf_list);
> > > -
> > > - spin_unlock_irqrestore(&cru->qlock, flags);
> > > }
> > >
> > > static void rzg2l_cru_set_slot_addr(struct rzg2l_cru_dev *cru, @@
> > > -465,7 +461,6 @@ void rzg2l_cru_disable_interrupts(struct
> > > rzg2l_cru_dev *cru) int rzg2l_cru_start_image_processing(struct
> > > rzg2l_cru_dev *cru) {
> > > struct v4l2_mbus_framefmt *fmt = rzg2l_cru_ip_get_src_fmt(cru);
> > > - unsigned long flags;
> > > u8 csi_vc;
> > > int ret;
> > >
> > > @@ -475,7 +470,7 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru)
> > > csi_vc = ret;
> > > cru->svc_channel = csi_vc;
> > >
> > > - spin_lock_irqsave(&cru->qlock, flags);
> > > + guard(spinlock_irqsave)(&cru->qlock);
> > >
> > > /* Select a video input */
> > > rzg2l_cru_write(cru, CRUnCTRL, CRUnCTRL_VINSEL(0)); @@ -492,7 +487,6
> > > @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru)
> > > /* Initialize image convert */
> > > ret = rzg2l_cru_initialize_image_conv(cru, fmt, csi_vc);
> > > if (ret) {
> > > - spin_unlock_irqrestore(&cru->qlock, flags);
> > > return ret;
> > > }
> > >
> > > @@ -502,8 +496,6 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru)
> > > /* Enable image processing reception */
> > > rzg2l_cru_write(cru, ICnEN, ICnEN_ICEN);
> > >
> > > - spin_unlock_irqrestore(&cru->qlock, flags);
> > > -
> > > return 0;
> > > }
> > >
> > > @@ -573,16 +565,15 @@ irqreturn_t rzg2l_cru_irq(int irq, void *data)
> > > {
> > > struct rzg2l_cru_dev *cru = data;
> > > unsigned int handled = 0;
> > > - unsigned long flags;
> > > u32 irq_status;
> > > u32 amnmbs;
> > > int slot;
> > >
> > > - spin_lock_irqsave(&cru->qlock, flags);
> > > + guard(spinlock_irqsave)(&cru->qlock);
> > >
> > > irq_status = rzg2l_cru_read(cru, CRUnINTS);
> > > if (!irq_status)
> > > - goto done;
> > > + return IRQ_RETVAL(handled);
> > >
> > > handled = 1;
> > >
> > > @@ -591,14 +582,14 @@ irqreturn_t rzg2l_cru_irq(int irq, void *data)
> > > /* Nothing to do if capture status is 'RZG2L_CRU_DMA_STOPPED' */
> > > if (cru->state == RZG2L_CRU_DMA_STOPPED) {
> > > dev_dbg(cru->dev, "IRQ while state stopped\n");
> > > - goto done;
> > > + return IRQ_RETVAL(handled);
> > > }
> > >
> > > /* Increase stop retries if capture status is 'RZG2L_CRU_DMA_STOPPING' */
> > > if (cru->state == RZG2L_CRU_DMA_STOPPING) {
> > > if (irq_status & CRUnINTS_SFS)
> > > dev_dbg(cru->dev, "IRQ while state stopping\n");
> > > - goto done;
> > > + return IRQ_RETVAL(handled);
> > > }
> > >
> > > /* Prepare for capture and update state */ @@ -621,7 +612,7 @@
> > > irqreturn_t rzg2l_cru_irq(int irq, void *data)
> > > if (cru->state == RZG2L_CRU_DMA_STARTING) {
> > > if (slot != 0) {
> > > dev_dbg(cru->dev, "Starting sync slot: %d\n", slot);
> > > - goto done;
> > > + return IRQ_RETVAL(handled);
> > > }
> > >
> > > dev_dbg(cru->dev, "Capture start synced!\n"); @@ -646,9 +637,6 @@
> > > irqreturn_t rzg2l_cru_irq(int irq, void *data)
> > > /* Prepare for next frame */
> > > rzg2l_cru_fill_hw_slot(cru, slot);
> > >
> > > -done:
> > > - spin_unlock_irqrestore(&cru->qlock, flags);
> > > -
> > > return IRQ_RETVAL(handled);
> > > }
> > >
> > >
> > > --
> > > 2.53.0
> > >
>
next prev parent reply other threads:[~2026-03-31 7:18 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 [this message]
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
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=actzkO0E01pcKlDE@zed \
--to=jacopo.mondi@ideasonboard.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=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 \
--cc=tommaso.merciai.xr@bp.renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.