public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E
@ 2026-03-27 17:10 Jacopo Mondi
  2026-03-27 17:10 ` [PATCH 01/14] media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used Jacopo Mondi
  2026-03-27 17:25 ` [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E Lad, Prabhakar
  0 siblings, 2 replies; 5+ messages in thread
From: Jacopo Mondi @ 2026-03-27 17:10 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart, Biju Das, Hans Verkuil,
	Sakari Ailus, Tommaso Merciai
  Cc: Daniel Scally, Barnabás Pőcze, Lad Prabhakar,
	linux-media, linux-kernel, Jacopo Mondi, stable, Jacopo Mondi,
	Daniel Scally

This patch series starts by collecting a patch sent from Dan in the past
which improves the HW slot programming on V2H(P) to avoid losing frames
under heavy system load conditions.

Tommaso also sent a series a few months ago for the CRU from which I
collected the first two patches.

Around it, I've reworked a bit the locking in the driver which is a bit
coarse and causes lost of frames under heavy system load conditions.

Along with these, bit of drive-by cometic changes here and there to
modernize the driver code.

I've tested on V2H(P) but I've also modified the G2L IRQ handler, so if
anyone could test on G2L and G3E it would be great!

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
Daniel Scally (1):
      media: rzg2l-cru: Rework rzg2l_cru_fill_hw_slot()

Jacopo Mondi (11):
      media: rzg2l-cru: Modernize spin_lock usage with cleanup.h
      media: rzg2l-cru: Use proper guard() in irq handler
      media: rzg2l-cru: Remove locking from start/stop routines
      media: rzg2l-cru: Do not use irqsave when not needed
      media: rzg2l-cru: Remove wrong locking comment
      media: rz2gl-cru: Introduce a spinlock for hw operations
      media: rzg2l-cru: Split hw locking from buffers
      media: rzg2l-cru: Manually track active slot number
      media: rz2gl-cru: Return pending buffers in order
      media: rzg2l-cru: Remove the 'state' variable
      media: rzg2l-cru: Simplify irq return value handling

Tommaso Merciai (2):
      media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used
      media: rzg2l-cru: Use only frame end interrupts

 .../platform/renesas/rzg2l-cru/rzg2l-cru-regs.h    |   2 +
 .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h   |  28 +-
 .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 328 ++++++++-------------
 3 files changed, 140 insertions(+), 218 deletions(-)
---
base-commit: 4fbeef21f5387234111b5d52924e77757626faa5
change-id: 20260326-b4-cru-rework-ba3b712bc715

Best regards,
-- 
Jacopo Mondi <jacopo.mondi@ideasonboard.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 01/14] media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used
  2026-03-27 17:10 [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E Jacopo Mondi
@ 2026-03-27 17:10 ` Jacopo Mondi
  2026-03-27 17:25 ` [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E Lad, Prabhakar
  1 sibling, 0 replies; 5+ messages in thread
From: Jacopo Mondi @ 2026-03-27 17:10 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart, Biju Das, Hans Verkuil,
	Sakari Ailus, Tommaso Merciai
  Cc: Daniel Scally, Barnabás Pőcze, Lad Prabhakar,
	linux-media, linux-kernel, Jacopo Mondi, stable, Jacopo Mondi

From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>

When the CRU is configured to use ICnSVC for virtual channel mapping,
as on the RZ/{G3E, V2H/P} SoC, the ICnMC register must not be
programmed.

Return early after setting up ICnSVC to avoid overriding the ICnMC
register, which is not applicable in this mode.

This prevents unintended register programming when ICnSVC is enabled.

Fixes: 3c5ca0a48bb0 ("media: rzg2l-cru: Drop function pointer to configure CSI")
Cc: stable@vger.kernel.org
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
[Rework to not break image format programming]
Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
---
 .../media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h   |  1 +
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c  | 17 +++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h
index a5a57369ef0e..10e62f2646d0 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h
@@ -60,6 +60,7 @@
 #define ICnMC_CSCTHR			BIT(5)
 #define ICnMC_INF(x)			((x) << 16)
 #define ICnMC_VCSEL(x)			((x) << 22)
+#define ICnMC_VCSEL_MASK		GENMASK(23, 22)
 #define ICnMC_INF_MASK			GENMASK(21, 16)
 
 #define ICnMS_IA			BIT(2)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 162e2ace6931..6aea7c244df1 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -262,19 +262,24 @@ static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru,
 				 u8 csi_vc)
 {
 	const struct rzg2l_cru_info *info = cru->info;
-	u32 icnmc = ICnMC_INF(ip_fmt->datatype);
+	u32 icnmc = rzg2l_cru_read(cru, info->image_conv) & ~(ICnMC_INF_MASK |
+							      ICnMC_VCSEL_MASK);
+	icnmc |= ICnMC_INF(ip_fmt->datatype);
 
+	/*
+	 * VC filtering goes through SVC register on G3E/V2H.
+	 *
+	 * FIXME: virtual channel filtering is likely broken and only VC=0
+	 * works.
+	 */
 	if (cru->info->regs[ICnSVC]) {
 		rzg2l_cru_write(cru, ICnSVCNUM, csi_vc);
 		rzg2l_cru_write(cru, ICnSVC, ICnSVC_SVC0(0) | ICnSVC_SVC1(1) |
 				ICnSVC_SVC2(2) | ICnSVC_SVC3(3));
+	} else {
+		icnmc |= ICnMC_VCSEL(csi_vc);
 	}
 
-	icnmc |= rzg2l_cru_read(cru, info->image_conv) & ~ICnMC_INF_MASK;
-
-	/* Set virtual channel CSI2 */
-	icnmc |= ICnMC_VCSEL(csi_vc);
-
 	rzg2l_cru_write(cru, info->image_conv, icnmc);
 }
 

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E
  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-27 17:25 ` Lad, Prabhakar
  2026-03-28 11:55   ` Jacopo Mondi
  1 sibling, 1 reply; 5+ messages in thread
From: Lad, Prabhakar @ 2026-03-27 17:25 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Biju Das, Hans Verkuil,
	Sakari Ailus, Tommaso Merciai, Daniel Scally,
	Barnabás Pőcze, Lad Prabhakar, linux-media,
	linux-kernel, stable, Jacopo Mondi, Daniel Scally

Hi Jacopo,

Thank you for the patches.

On Fri, Mar 27, 2026 at 5:19 PM Jacopo Mondi
<jacopo.mondi@ideasonboard.com> wrote:
>
> This patch series starts by collecting a patch sent from Dan in the past
> which improves the HW slot programming on V2H(P) to avoid losing frames
> under heavy system load conditions.
>
> Tommaso also sent a series a few months ago for the CRU from which I
> collected the first two patches.
>
> Around it, I've reworked a bit the locking in the driver which is a bit
> coarse and causes lost of frames under heavy system load conditions.
>
> Along with these, bit of drive-by cometic changes here and there to
> modernize the driver code.
>
> I've tested on V2H(P) but I've also modified the G2L IRQ handler, so if
> anyone could test on G2L and G3E it would be great!
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> Daniel Scally (1):
>       media: rzg2l-cru: Rework rzg2l_cru_fill_hw_slot()
>
> Jacopo Mondi (11):
>       media: rzg2l-cru: Modernize spin_lock usage with cleanup.h
>       media: rzg2l-cru: Use proper guard() in irq handler
>       media: rzg2l-cru: Remove locking from start/stop routines
>       media: rzg2l-cru: Do not use irqsave when not needed
>       media: rzg2l-cru: Remove wrong locking comment
>       media: rz2gl-cru: Introduce a spinlock for hw operations
>       media: rzg2l-cru: Split hw locking from buffers
>       media: rzg2l-cru: Manually track active slot number
You beat me to it, I had a similar patch internally.

>       media: rz2gl-cru: Return pending buffers in order
>       media: rzg2l-cru: Remove the 'state' variable
>       media: rzg2l-cru: Simplify irq return value handling
>
> Tommaso Merciai (2):
>       media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used
>       media: rzg2l-cru: Use only frame end interrupts
>
>  .../platform/renesas/rzg2l-cru/rzg2l-cru-regs.h    |   2 +
>  .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h   |  28 +-
>  .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 328 ++++++++-------------
>  3 files changed, 140 insertions(+), 218 deletions(-)

I'll test these patches with ISP enabled next week.

Cheers,
Prabhakar

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Jacopo Mondi @ 2026-03-28 11:55 UTC (permalink / raw)
  To: Lad, Prabhakar
  Cc: Jacopo Mondi, Mauro Carvalho Chehab, Laurent Pinchart, Biju Das,
	Hans Verkuil, Sakari Ailus, Tommaso Merciai, Daniel Scally,
	Barnabás Pőcze, Lad Prabhakar, linux-media,
	linux-kernel, stable, Jacopo Mondi, Daniel Scally

Hi Prabhakar

On Fri, Mar 27, 2026 at 05:25:30PM +0000, Lad, Prabhakar wrote:
> Hi Jacopo,
>
> Thank you for the patches.
>
> On Fri, Mar 27, 2026 at 5:19 PM Jacopo Mondi
> <jacopo.mondi@ideasonboard.com> wrote:
> >
> > This patch series starts by collecting a patch sent from Dan in the past
> > which improves the HW slot programming on V2H(P) to avoid losing frames
> > under heavy system load conditions.
> >
> > Tommaso also sent a series a few months ago for the CRU from which I
> > collected the first two patches.
> >
> > Around it, I've reworked a bit the locking in the driver which is a bit
> > coarse and causes lost of frames under heavy system load conditions.
> >
> > Along with these, bit of drive-by cometic changes here and there to
> > modernize the driver code.
> >
> > I've tested on V2H(P) but I've also modified the G2L IRQ handler, so if
> > anyone could test on G2L and G3E it would be great!
> >
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > ---
> > Daniel Scally (1):
> >       media: rzg2l-cru: Rework rzg2l_cru_fill_hw_slot()
> >
> > Jacopo Mondi (11):
> >       media: rzg2l-cru: Modernize spin_lock usage with cleanup.h
> >       media: rzg2l-cru: Use proper guard() in irq handler
> >       media: rzg2l-cru: Remove locking from start/stop routines
> >       media: rzg2l-cru: Do not use irqsave when not needed
> >       media: rzg2l-cru: Remove wrong locking comment
> >       media: rz2gl-cru: Introduce a spinlock for hw operations
> >       media: rzg2l-cru: Split hw locking from buffers
> >       media: rzg2l-cru: Manually track active slot number
> You beat me to it, I had a similar patch internally.

Oh that's great, I wasn't sure how this was going to be received!

>
> >       media: rz2gl-cru: Return pending buffers in order
> >       media: rzg2l-cru: Remove the 'state' variable
> >       media: rzg2l-cru: Simplify irq return value handling
> >
> > Tommaso Merciai (2):
> >       media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used
> >       media: rzg2l-cru: Use only frame end interrupts
> >
> >  .../platform/renesas/rzg2l-cru/rzg2l-cru-regs.h    |   2 +
> >  .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h   |  28 +-
> >  .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 328 ++++++++-------------
> >  3 files changed, 140 insertions(+), 218 deletions(-)
>
> I'll test these patches with ISP enabled next week.

My testing platform is v2h with the ISP, if you have a G2L could you
maybe give it a spin there as I don't have any board with that SoC ?

Thanks
   j

>
> Cheers,
> Prabhakar

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 00/14] media: rzg2l-cru: Rework slot programming for V2H/G3E
  2026-03-28 11:55   ` Jacopo Mondi
@ 2026-03-28 12:56     ` Lad, Prabhakar
  0 siblings, 0 replies; 5+ messages in thread
From: Lad, Prabhakar @ 2026-03-28 12:56 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Biju Das, Hans Verkuil,
	Sakari Ailus, Tommaso Merciai, Daniel Scally,
	Barnabás Pőcze, Lad Prabhakar, linux-media,
	linux-kernel, stable, Jacopo Mondi, Daniel Scally

Hi Jacopo,

On Sat, Mar 28, 2026 at 11:55 AM Jacopo Mondi
<jacopo.mondi@ideasonboard.com> wrote:
>
> Hi Prabhakar
>
> On Fri, Mar 27, 2026 at 05:25:30PM +0000, Lad, Prabhakar wrote:
> > Hi Jacopo,
> >
> > Thank you for the patches.
> >
> > On Fri, Mar 27, 2026 at 5:19 PM Jacopo Mondi
> > <jacopo.mondi@ideasonboard.com> wrote:
> > >
> > > This patch series starts by collecting a patch sent from Dan in the past
> > > which improves the HW slot programming on V2H(P) to avoid losing frames
> > > under heavy system load conditions.
> > >
> > > Tommaso also sent a series a few months ago for the CRU from which I
> > > collected the first two patches.
> > >
> > > Around it, I've reworked a bit the locking in the driver which is a bit
> > > coarse and causes lost of frames under heavy system load conditions.
> > >
> > > Along with these, bit of drive-by cometic changes here and there to
> > > modernize the driver code.
> > >
> > > I've tested on V2H(P) but I've also modified the G2L IRQ handler, so if
> > > anyone could test on G2L and G3E it would be great!
> > >
> > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > ---
> > > Daniel Scally (1):
> > >       media: rzg2l-cru: Rework rzg2l_cru_fill_hw_slot()
> > >
> > > Jacopo Mondi (11):
> > >       media: rzg2l-cru: Modernize spin_lock usage with cleanup.h
> > >       media: rzg2l-cru: Use proper guard() in irq handler
> > >       media: rzg2l-cru: Remove locking from start/stop routines
> > >       media: rzg2l-cru: Do not use irqsave when not needed
> > >       media: rzg2l-cru: Remove wrong locking comment
> > >       media: rz2gl-cru: Introduce a spinlock for hw operations
> > >       media: rzg2l-cru: Split hw locking from buffers
> > >       media: rzg2l-cru: Manually track active slot number
> > You beat me to it, I had a similar patch internally.
>
> Oh that's great, I wasn't sure how this was going to be received!
>
> >
> > >       media: rz2gl-cru: Return pending buffers in order
> > >       media: rzg2l-cru: Remove the 'state' variable
> > >       media: rzg2l-cru: Simplify irq return value handling
> > >
> > > Tommaso Merciai (2):
> > >       media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used
> > >       media: rzg2l-cru: Use only frame end interrupts
> > >
> > >  .../platform/renesas/rzg2l-cru/rzg2l-cru-regs.h    |   2 +
> > >  .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h   |  28 +-
> > >  .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 328 ++++++++-------------
> > >  3 files changed, 140 insertions(+), 218 deletions(-)
> >
> > I'll test these patches with ISP enabled next week.
>
> My testing platform is v2h with the ISP, if you have a G2L could you
> maybe give it a spin there as I don't have any board with that SoC ?
>
Sure I will.

Cheers,
Prabhakar

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-28 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox