mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: shomenkow@gmail.com,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	 Philipp Zabel <p.zabel@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Chen-Yu Tsai <wenst@chromium.org>,
	Hugues Fruchet <hugues.fruchet@foss.st.com>,
	linux-media@vger.kernel.org,  linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	 linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org,  stable@vger.kernel.org
Subject: Re: [PATCH v2 1/3] media: verisilicon: stop the VEPU1 JPEG encoder after an unfinished frame
Date: Mon, 23 Nov 2026 16:00:47 -0500	[thread overview]
Message-ID: <855103db6f4103f30c57af2f8d3fb03818c3d8b3.camel@collabora.com> (raw)
In-Reply-To: <20261110-hantro-buflimit-v2-1-ff7790def9fc@gmail.com>

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

Le mardi 10 novembre 2026 à 15:41 +0300, Sergei Khomenkov via B4 Relay a écrit :
> From: Sergei Khomenkov <shomenkow@gmail.com>
> 
> When the JPEG stream reaches the stream buffer limit, the H1 raises a
> buffer-full interrupt and pauses with the enable bit of H1_REG_ENC_CTRL
> still set. rockchip_vpu1_vepu_irq() does not stop it, so the next job is
> programmed into the paused encoder and times out.
> 
> Clear only the enable bit when an interrupt does not report a finished
> frame, and warn (rate limited) about each fault bit that is set, as
> hantro_g2_irq() does.
> 
> Found with an LLM coding assistant while porting mainline Linux to a
> Rockchip RK3026 board; the assistant also drafted this change. Tested
> on that board, with the next patch applied: a frame that does not fit
> now ends with the ERROR flag and one interrupt, and the following jobs
> complete. Not tested on other SoCs.
> 
> Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sergei Khomenkov <shomenkow@gmail.com>
> ---
>  drivers/media/platform/verisilicon/hantro_h1_regs.h  |  4 ++++
>  drivers/media/platform/verisilicon/rockchip_vpu_hw.c | 18 ++++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/media/platform/verisilicon/hantro_h1_regs.h b/drivers/media/platform/verisilicon/hantro_h1_regs.h
> index 8650cc489392..a7f18683dac1 100644
> --- a/drivers/media/platform/verisilicon/hantro_h1_regs.h
> +++ b/drivers/media/platform/verisilicon/hantro_h1_regs.h
> @@ -11,6 +11,10 @@
>  
>  /* Encoder registers. */
>  #define H1_REG_INTERRUPT				0x004
> +#define     H1_REG_INTERRUPT_TIMEOUT			BIT(6)
> +#define     H1_REG_INTERRUPT_BUFFER_FULL		BIT(5)
> +#define     H1_REG_INTERRUPT_RESET			BIT(4)
> +#define     H1_REG_INTERRUPT_BUS_ERROR			BIT(3)
>  #define     H1_REG_INTERRUPT_FRAME_RDY			BIT(2)
>  #define     H1_REG_INTERRUPT_DIS_BIT			BIT(1)
>  #define     H1_REG_INTERRUPT_BIT			BIT(0)
> diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
> index 02673be9878e..d201b058e5e8 100644
> --- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
> +++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
> @@ -376,6 +376,24 @@ static irqreturn_t rockchip_vpu1_vepu_irq(int irq, void *dev_id)
>  	state = (status & H1_REG_INTERRUPT_FRAME_RDY) ?
>  		VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR;
>  
> +	if (status & H1_REG_INTERRUPT_BUFFER_FULL)
> +		dev_warn_ratelimited(vpu->dev, "stream buffer full\n");
> +	if (status & H1_REG_INTERRUPT_BUS_ERROR)
> +		dev_warn_ratelimited(vpu->dev, "bus error detected\n");
> +	if (status & H1_REG_INTERRUPT_TIMEOUT)
> +		dev_warn_ratelimited(vpu->dev, "frame encode timed out\n");
> +	if (status & H1_REG_INTERRUPT_RESET)
> +		dev_warn_ratelimited(vpu->dev, "encoder reset\n");
> +
> +	/* After a buffer full the encoder pauses, still enabled: stop it. */
> +	if (!(status & H1_REG_INTERRUPT_FRAME_RDY)) {
> +		u32 ctrl = vepu_read(vpu, H1_REG_ENC_CTRL);
> +
> +		if (ctrl & H1_REG_ENC_CTRL_EN_BIT)
> +			vepu_write(vpu, ctrl & ~H1_REG_ENC_CTRL_EN_BIT,
> +				   H1_REG_ENC_CTRL);
> +	}
> +

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

>  	vepu_write(vpu, 0, H1_REG_INTERRUPT);
>  	vepu_write(vpu, 0, H1_REG_AXI_CTRL);
>  

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

  reply	other threads:[~2026-11-23 21:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 12:41 [PATCH v2 0/3] media: verisilicon: fix VEPU1 JPEG encoder writes past the CAPTURE buffer Sergei Khomenkov via B4 Relay
2026-11-10 12:41 ` [PATCH v2 1/3] media: verisilicon: stop the VEPU1 JPEG encoder after an unfinished frame Sergei Khomenkov via B4 Relay
2026-11-23 21:00   ` Nicolas Dufresne [this message]
2026-11-10 12:41 ` [PATCH v2 2/3] media: verisilicon: program the H1 JPEG stream limit in 64-bit words Sergei Khomenkov via B4 Relay
2026-11-23 21:13   ` Nicolas Dufresne
2026-11-10 12:41 ` [PATCH v2 3/3] media: verisilicon: leave room for the JPEG header and one stream burst Sergei Khomenkov via B4 Relay
2026-11-23 21:23   ` Nicolas Dufresne

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=855103db6f4103f30c57af2f8d3fb03818c3d8b3.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=heiko@sntech.de \
    --cc=hugues.fruchet@foss.st.com \
    --cc=hverkuil@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=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=shomenkow@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=wenst@chromium.org \
    /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®