mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: "Sven Püschel" <s.pueschel@pengutronix.de>,
	"Jacob Chen" <jacob-chen@iotwrt.com>,
	"Ezequiel Garcia" <ezequiel@vanguardiasur.com.ar>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>
Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  devicetree@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH 12/16] media: rockchip: rga: handle error interrupt
Date: Tue, 07 Oct 2025 14:47:38 -0400	[thread overview]
Message-ID: <a57669be1d58e71229dedcf4acbe6eda201e45ea.camel@ndufresne.ca> (raw)
In-Reply-To: <20251007-spu-rga3-v1-12-36ad85570402@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 5216 bytes --]

Le mardi 07 octobre 2025 à 10:32 +0200, Sven Püschel a écrit :
> Handle the error interrupt status in preparation of the RGA3 addition.
> This allows the buffer to be marked as done, as it would otherwise
> be stuck in the queue.
> 
> The RGA3 needs a soft reset to properly work after an error occurred,
> as it would otherwise cease to deliver new interrupts. Also the soft
> reset avoids additional error interrupts to be triggered, which are
> currently not supported by the rga_isr function.
> As it is unknown how the RGA2 behaves in the error case, no
> error interrupt was enabled and handled.
> 
> Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
> ---
>  drivers/media/platform/rockchip/rga/rga-hw.c |  6 ++++--
>  drivers/media/platform/rockchip/rga/rga.c    | 32 +++++++++++++++++----------
> -
>  drivers/media/platform/rockchip/rga/rga.h    |  8 ++++++-
>  3 files changed, 31 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/media/platform/rockchip/rga/rga-hw.c
> b/drivers/media/platform/rockchip/rga/rga-hw.c
> index
> d54183d224b3e9c42d5503acf172257f2e736f7b..93822b5b8b15e76862bd022759eaa5cb9552
> dd76 100644
> --- a/drivers/media/platform/rockchip/rga/rga-hw.c
> +++ b/drivers/media/platform/rockchip/rga/rga-hw.c
> @@ -459,7 +459,7 @@ static void rga_hw_start(struct rockchip_rga *rga,
>  	rga_write(rga, RGA_CMD_CTRL, 0x1);
>  }
>  
> -static bool rga_handle_irq(struct rockchip_rga *rga)
> +static enum rga_irq_result rga_handle_irq(struct rockchip_rga *rga)
>  {
>  	int intr;
>  
> @@ -467,7 +467,9 @@ static bool rga_handle_irq(struct rockchip_rga *rga)
>  
>  	rga_mod(rga, RGA_INT, intr << 4, 0xf << 4);
>  
> -	return intr & 0x04;
> +	if (intr & 0x04)
> +		return RGA_IRQ_DONE;

Since you reuse an old driver, would be nice to create proper defines for
RGA_INT bit 3 (current command finish interrupt flag).

> +	return RGA_IRQ_IGNORE;
>  }
>  
>  static void rga_get_version(struct rockchip_rga *rga)
> diff --git a/drivers/media/platform/rockchip/rga/rga.c
> b/drivers/media/platform/rockchip/rga/rga.c
> index
> 0a725841b0cfa41bbc5b861b8f5ceac2452fc2b5..3b5d2eb8e109f44af76dd2240a239b1fa8a7
> 8cee 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -56,30 +56,38 @@ static void device_run(void *prv)
>  static irqreturn_t rga_isr(int irq, void *prv)
>  {
>  	struct rockchip_rga *rga = prv;
> +	struct vb2_v4l2_buffer *src, *dst;
> +	struct rga_ctx *ctx = rga->curr;
> +	enum rga_irq_result result;
>  
> -	if (rga->hw->handle_irq(rga)) {
> -		struct vb2_v4l2_buffer *src, *dst;
> -		struct rga_ctx *ctx = rga->curr;
> +	result = rga->hw->handle_irq(rga);
> +	if (result == RGA_IRQ_IGNORE)
> +		return IRQ_HANDLED;
>  
> -		WARN_ON(!ctx);
> +	WARN_ON(!ctx);
>  
> -		rga->curr = NULL;
> +	rga->curr = NULL;
>  
> -		src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> -		dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
> +	src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
> +	dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
>  
> -		WARN_ON(!src);
> -		WARN_ON(!dst);
> +	WARN_ON(!src);
> +	WARN_ON(!dst);
>  
> -		v4l2_m2m_buf_copy_metadata(src, dst, true);
> +	v4l2_m2m_buf_copy_metadata(src, dst, true);
>  
> -		dst->sequence = ctx->csequence++;
> +	dst->sequence = ctx->csequence++;
>  
> +	if (result == RGA_IRQ_DONE) {
>  		v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE);
>  		v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE);
> -		v4l2_m2m_job_finish(rga->m2m_dev, ctx->fh.m2m_ctx);
> +	} else {
> +		v4l2_m2m_buf_done(src, VB2_BUF_STATE_ERROR);
> +		v4l2_m2m_buf_done(dst, VB2_BUF_STATE_ERROR)

I'm not fan of assumption that its an error on else case. If often lead to
multiple calls. Please use an explicit error return.

> ;
>  	}
>  
> +	v4l2_m2m_job_finish(rga->m2m_dev, ctx->fh.m2m_ctx);

What if you get an IRQ and none of the flags are raised ? I did see that in the
past, and that least to bad things happening.

> +
>  	return IRQ_HANDLED;
>  }
>  
> diff --git a/drivers/media/platform/rockchip/rga/rga.h
> b/drivers/media/platform/rockchip/rga/rga.h
> index
> e19c4c82aca5ae2056f52d525138093fbbb81af8..dc4bb85707d12f5378c4891098cd7ea4a4d7
> 5e2d 100644
> --- a/drivers/media/platform/rockchip/rga/rga.h
> +++ b/drivers/media/platform/rockchip/rga/rga.h
> @@ -143,6 +143,12 @@ static inline void rga_mod(struct rockchip_rga *rga, u32
> reg, u32 val, u32 mask)
>  	rga_write(rga, reg, temp);
>  };
>  
> +enum rga_irq_result {
> +	RGA_IRQ_IGNORE,
> +	RGA_IRQ_DONE,
> +	RGA_IRQ_ERROR,
> +};
> +
>  struct rga_hw {
>  	const char *card_type;
>  	bool has_internal_iommu;
> @@ -152,7 +158,7 @@ struct rga_hw {
>  
>  	void (*start)(struct rockchip_rga *rga,
>  		      struct rga_vb_buffer *src, struct rga_vb_buffer *dst);
> -	bool (*handle_irq)(struct rockchip_rga *rga);
> +	enum rga_irq_result (*handle_irq)(struct rockchip_rga *rga);
>  	void (*get_version)(struct rockchip_rga *rga);
>  	void *(*try_format)(u32 *fourcc, bool is_output);
>  	int (*enum_format)(struct v4l2_fmtdesc *f);

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-10-07 18:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  8:31 [PATCH 00/16] media: platform: rga: Add RGA3 support Sven Püschel
2025-10-07  8:31 ` [PATCH 01/16] media: rockchip: rga: use clk_bulk api Sven Püschel
2025-10-07  8:31 ` [PATCH 02/16] media: rockchip: rga: use stride for offset calculation Sven Püschel
2025-10-07  8:31 ` [PATCH 03/16] media: rockchip: rga: align stride to 16 bytes Sven Püschel
2025-10-07 18:19   ` Nicolas Dufresne
2025-12-02 14:36     ` Sven Püschel
2025-10-07  8:31 ` [PATCH 04/16] media: rockchip: rga: move hw specific parts to a dedicated struct Sven Püschel
2025-10-07  8:31 ` [PATCH 05/16] media: rockchip: rga: use card type to specify rga type Sven Püschel
2025-10-07  8:31 ` [PATCH 06/16] media: rockchip: rga: change offset to dma_addresses Sven Püschel
2025-10-07  8:32 ` [PATCH 07/16] media: rockchip: rga: support external iommus Sven Püschel
2025-10-07  8:32 ` [PATCH 08/16] media: rockchip: rga: remove size from rga_frame Sven Püschel
2025-10-07  8:32 ` [PATCH 09/16] media: rockchip: rga: remove stride " Sven Püschel
2025-10-07  8:32 ` [PATCH 10/16] media: rockchip: rga: move rga_fmt to rga-hw.h Sven Püschel
2025-10-07  8:32 ` [PATCH 11/16] media: rockchip: rga: add iommu restore function Sven Püschel
2025-10-07 18:30   ` Nicolas Dufresne
2025-10-10  8:45     ` Sven Püschel
2025-10-10 13:10       ` Nicolas Dufresne
2025-10-07  8:32 ` [PATCH 12/16] media: rockchip: rga: handle error interrupt Sven Püschel
2025-10-07 18:47   ` Nicolas Dufresne [this message]
2025-10-07  8:32 ` [PATCH 13/16] media: dt-bindings: media: rockchip-rga: add rockchip,rk3588-rga3 Sven Püschel
2025-10-07  8:38   ` Krzysztof Kozlowski
2025-10-07 18:12     ` Nicolas Dufresne
2025-10-07  8:32 ` [PATCH 14/16] arm64: dts: rockchip: add rga3 dt nodes Sven Püschel
2025-10-07  8:32 ` [PATCH 15/16] arm64: dts: rockchip: increase rga3 clock speed Sven Püschel
2025-10-07  8:39   ` Krzysztof Kozlowski
2025-10-07  8:32 ` [PATCH 16/16] media: rockchip: rga: add rga3 support Sven Püschel
2025-10-07  8:39   ` Krzysztof Kozlowski
2025-10-07 16:05     ` Sven Püschel
2025-10-08  1:55       ` Krzysztof Kozlowski
2025-10-07 18:54     ` Nicolas Dufresne
2025-10-07 19:41   ` Nicolas Dufresne
2025-10-10  9:21     ` Sven Püschel
2025-12-03  9:49     ` Sven Püschel
2025-12-03 18:17       ` Nicolas Dufresne
2025-10-11  5:32   ` kernel test robot
2025-10-07 18:06 ` [PATCH 00/16] media: platform: rga: Add RGA3 support Nicolas Dufresne
2025-10-10  8:33   ` Sven Püschel
2025-10-10 13:05     ` Nicolas Dufresne
2025-10-09 22:03 ` Rob Herring (Arm)

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=a57669be1d58e71229dedcf4acbe6eda201e45ea.camel@ndufresne.ca \
    --to=nicolas@ndufresne.ca \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=heiko@sntech.de \
    --cc=jacob-chen@iotwrt.com \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=s.pueschel@pengutronix.de \
    /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

all inboxes | Powered by JetHome®