public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
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>,
	"Daniel Scally" <dan.scally@ideasonboard.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 v2 13/15] media: rzg2l-cru: Remove the 'state' variable
Date: Tue, 31 Mar 2026 18:32:14 +0200	[thread overview]
Message-ID: <acv3DqFG3SxjyHY5@tom-desktop> (raw)
In-Reply-To: <20260331-b4-cru-rework-v2-13-f94b238b35d4@ideasonboard.com>

Hi Jacopo,

On Tue, Mar 31, 2026 at 12:27:43PM +0200, Jacopo Mondi wrote:
> From: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> 
> The cru driver uses a 'state' variable for debugging purpose in the
> interrupt handler. The state is used to detect invalid usage conditions
> that are not meant to happen unless the driver has a bug in handling the
> stop and start conditions.
> 
> Remove the state variable which seems to be a debugging leftover.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>

Kind Regards,
Tommaso

> ---
>  .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h   | 15 -----
>  .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 71 +---------------------
>  2 files changed, 3 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> index 25f17069585c..5bf334e173d2 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> @@ -38,20 +38,6 @@ enum rzg2l_csi2_pads {
>  
>  struct rzg2l_cru_dev;
>  
> -/**
> - * enum rzg2l_cru_dma_state - DMA states
> - * @RZG2L_CRU_DMA_STOPPED:   No operation in progress
> - * @RZG2L_CRU_DMA_STARTING:  Capture starting up
> - * @RZG2L_CRU_DMA_RUNNING:   Operation in progress have buffers
> - * @RZG2L_CRU_DMA_STOPPING:  Stopping operation
> - */
> -enum rzg2l_cru_dma_state {
> -	RZG2L_CRU_DMA_STOPPED = 0,
> -	RZG2L_CRU_DMA_STARTING,
> -	RZG2L_CRU_DMA_RUNNING,
> -	RZG2L_CRU_DMA_STOPPING,
> -};
> -
>  struct rzg2l_cru_csi {
>  	struct v4l2_async_connection *asd;
>  	struct v4l2_subdev *subdev;
> @@ -174,7 +160,6 @@ struct rzg2l_cru_dev {
>  	struct vb2_v4l2_buffer *queue_buf[RZG2L_CRU_HW_BUFFER_MAX];
>  	struct list_head buf_list;
>  	unsigned int sequence;
> -	enum rzg2l_cru_dma_state state;
>  
>  	struct v4l2_pix_format format;
>  };
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index f061bee51ea8..721057edca6b 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -398,8 +398,6 @@ void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru)
>  	if (icnms)
>  		dev_err(cru->dev, "Failed stop HW, something is seriously broken\n");
>  
> -	cru->state = RZG2L_CRU_DMA_STOPPED;
> -
>  	/* Wait until the FIFO becomes empty */
>  	for (retries = 5; retries > 0; retries--) {
>  		if (cru->info->fifo_empty(cru))
> @@ -587,8 +585,6 @@ static int rzg2l_cru_set_stream(struct rzg2l_cru_dev *cru, int on)
>  
>  static void rzg2l_cru_stop_streaming(struct rzg2l_cru_dev *cru)
>  {
> -	cru->state = RZG2L_CRU_DMA_STOPPING;
> -
>  	rzg2l_cru_set_stream(cru, 0);
>  }
>  
> @@ -600,8 +596,6 @@ irqreturn_t rzg2l_cru_irq(int irq, void *data)
>  	u32 amnmbs;
>  	int slot;
>  
> -	guard(spinlock_irqsave)(&cru->hw_lock);
> -
>  	irq_status = rzg2l_cru_read(cru, CRUnINTS);
>  	if (!irq_status)
>  		return IRQ_RETVAL(handled);
> @@ -610,20 +604,9 @@ irqreturn_t rzg2l_cru_irq(int irq, void *data)
>  
>  	rzg2l_cru_write(cru, CRUnINTS, rzg2l_cru_read(cru, CRUnINTS));
>  
> -	/* 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");
> -		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");
> -		return IRQ_RETVAL(handled);
> -	}
> +	/* Calculate slot and prepare for new capture. */
> +	guard(spinlock_irqsave)(&cru->hw_lock);
>  
> -	/* Prepare for capture and update state */
>  	amnmbs = rzg2l_cru_read(cru, AMnMBS);
>  	cru->active_slot = amnmbs & AMnMBS_MBSTS;
>  
> @@ -636,20 +619,6 @@ irqreturn_t rzg2l_cru_irq(int irq, void *data)
>  	else
>  		slot = cru->active_slot - 1;
>  
> -	/*
> -	 * To hand buffers back in a known order to userspace start
> -	 * to capture first from slot 0.
> -	 */
> -	if (cru->state == RZG2L_CRU_DMA_STARTING) {
> -		if (slot != 0) {
> -			dev_dbg(cru->dev, "Starting sync slot: %d\n", slot);
> -			return IRQ_RETVAL(handled);
> -		}
> -
> -		dev_dbg(cru->dev, "Capture start synced!\n");
> -		cru->state = RZG2L_CRU_DMA_RUNNING;
> -	}
> -
>  	/* Capture frame */
>  	if (cru->queue_buf[slot]) {
>  		cru->queue_buf[slot]->field = cru->format.field;
> @@ -677,49 +646,18 @@ irqreturn_t rzg3e_cru_irq(int irq, void *data)
>  	u32 irq_status;
>  	int slot;
>  
> -	guard(spinlock)(&cru->hw_lock);
> -
>  	irq_status = rzg2l_cru_read(cru, CRUnINTS2);
>  	if (!irq_status)
>  		return IRQ_NONE;
>  
> -	dev_dbg(cru->dev, "CRUnINTS2 0x%x\n", irq_status);
> -
>  	rzg2l_cru_write(cru, CRUnINTS2, rzg2l_cru_read(cru, CRUnINTS2));
>  
> -	/* 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");
> -		return IRQ_HANDLED;
> -	}
> -
> -	if (cru->state == RZG2L_CRU_DMA_STOPPING) {
> -		if (irq_status & CRUnINTS2_FExS(0) ||
> -		    irq_status & CRUnINTS2_FExS(1) ||
> -		    irq_status & CRUnINTS2_FExS(2) ||
> -		    irq_status & CRUnINTS2_FExS(3))
> -			dev_dbg(cru->dev, "IRQ while state stopping\n");
> -		return IRQ_HANDLED;
> -	}
> -
> +	guard(spinlock)(&cru->hw_lock);
>  	slot = cru->active_slot;
>  	cru->active_slot = rzg2l_cru_slot_next(cru, cru->active_slot);
>  
>  	dev_dbg(cru->dev, "Current written slot: %d\n", slot);
>  
> -	/*
> -	 * To hand buffers back in a known order to userspace start
> -	 * to capture first from slot 0.
> -	 */
> -	if (cru->state == RZG2L_CRU_DMA_STARTING) {
> -		if (slot != 0) {
> -			dev_dbg(cru->dev, "Starting sync slot: %d\n", slot);
> -			return IRQ_HANDLED;
> -		}
> -		dev_dbg(cru->dev, "Capture start synced!\n");
> -		cru->state = RZG2L_CRU_DMA_RUNNING;
> -	}
> -
>  	/* Capture frame */
>  	if (cru->queue_buf[slot]) {
>  		struct vb2_v4l2_buffer *buf = cru->queue_buf[slot];
> @@ -788,7 +726,6 @@ static int rzg2l_cru_start_streaming_vq(struct vb2_queue *vq, unsigned int count
>  		goto out;
>  	}
>  
> -	cru->state = RZG2L_CRU_DMA_STARTING;
>  	dev_dbg(cru->dev, "Starting to capture\n");
>  	return 0;
>  
> @@ -861,8 +798,6 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
>  	spin_lock_init(&cru->hw_lock);
>  	spin_lock_init(&cru->qlock);
>  
> -	cru->state = RZG2L_CRU_DMA_STOPPED;
> -
>  	for (i = 0; i < RZG2L_CRU_HW_BUFFER_MAX; i++)
>  		cru->queue_buf[i] = NULL;
>  
> 
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-03-31 16:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 10:27 [PATCH v2 00/15] media: rzg2l-cru: Rework slot programming for V2H/G3E Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 01/15] media: rzg2l-cru: Skip ICnMC configuration when ICnSVC is used Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 02/15] media: rzg2l-cru: Use only frame end interrupts Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 03/15] media: rzg2l-cru: Modernize locking usage with guards Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 04/15] media: rzg2l-cru: Use proper guard() in irq handler Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 05/15] media: rzg2l-cru: Remove locking from start/stop routines Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 06/15] media: rzg2l-cru: Do not use irqsave when not needed Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 07/15] media: rzg2l-cru: Remove wrong locking comment Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 08/15] media: rz2gl-cru: Introduce a spinlock for hw operations Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 09/15] media: rzg2l-cru: Split hw locking from buffers Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 10/15] media: rzg2l-cru: Manually track active slot number Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 11/15] media: rz2gl-cru: Return pending buffers in order Jacopo Mondi
2026-03-31 10:27 ` [PATCH v2 12/15] media: rzg2l-cru: Rework rzg2l_cru_fill_hw_slot() Jacopo Mondi
2026-03-31 16:26   ` Tommaso Merciai
2026-03-31 10:27 ` [PATCH v2 13/15] media: rzg2l-cru: Remove the 'state' variable Jacopo Mondi
2026-03-31 16:32   ` Tommaso Merciai [this message]
2026-03-31 10:27 ` [PATCH v2 14/15] media: rzg2l-cru: Remove debug printouts from irq Jacopo Mondi
2026-03-31 10:45   ` Dan Scally
2026-03-31 10:27 ` [PATCH v2 15/15] media: rzg2l-cru: Simplify irq return value handling 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=acv3DqFG3SxjyHY5@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