linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Jonas Karlman <jonas@kwiboo.se>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Detlev Casanova	 <detlev.casanova@collabora.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Heiko Stuebner	 <heiko@sntech.de>,
	Alex Bee <knaerzche@gmail.com>,
	Sebastian Fricke	 <sebastian.fricke@collabora.com>,
	linux-media@vger.kernel.org, 	linux-rockchip@lists.infradead.org,
	devicetree@vger.kernel.org,
		linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/7] media: rkvdec: Disable QoS for HEVC and VP9 on RK3328
Date: Tue, 12 Aug 2025 09:00:15 -0400	[thread overview]
Message-ID: <f2908b2d35671e70e6a8b295de623e3a3ffe2212.camel@collabora.com> (raw)
In-Reply-To: <9dce97a9-92e6-4803-9e06-b2938e3c4999@kwiboo.se>

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

Le mardi 12 août 2025 à 01:08 +0200, Jonas Karlman a écrit :
> Hi Nicolas,
> 
> Missed some comments in my last mail.
> 
> On 8/11/2025 11:25 PM, Nicolas Dufresne wrote:
> > Le dimanche 10 août 2025 à 21:24 +0000, Jonas Karlman a écrit :
> > > From: Alex Bee <knaerzche@gmail.com>
> > > 
> > > The RK3328 VDEC has a HW quirk that require QoS to be disabled when HEVC
> > > or VP9 is decoded, otherwise the decoded picture may become corrupted.
> > > 
> > > Add a RK3328 variant with a quirk flag to disable QoS when before
> > > decoding is started.
> > > 
> > > Signed-off-by: Alex Bee <knaerzche@gmail.com>
> > > Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> > > ---
> > > Changes in v2:
> > > - No change
> > > ---
> > >  drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c |  9 +++++++++
> > >  drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h |  2 ++
> > >  drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c  | 10 ++++++++++
> > >  drivers/media/platform/rockchip/rkvdec/rkvdec.c      | 12 ++++++++++++
> > >  drivers/media/platform/rockchip/rkvdec/rkvdec.h      |  4 ++++
> > >  5 files changed, 37 insertions(+)
> > > 
> > > diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
> > > b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
> > > index 1994ea24f0be..f8bb8c4264f7 100644
> > > --- a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
> > > +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
> > > @@ -789,6 +789,15 @@ static int rkvdec_hevc_run(struct rkvdec_ctx *ctx)
> > >  	writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND);
> > >  	writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND);
> > >  
> > > +	if (rkvdec->quirks & RKVDEC_QUIRK_DISABLE_QOS) {
> > > +		u32 reg;
> > > +
> > > +		reg = readl(rkvdec->regs + RKVDEC_REG_QOS_CTRL);
> > > +		reg |= 0xFFFF;
> > > +		reg &= ~BIT(12);
> > 
> > I wonder if there is a better way to express that, if not, a comment for
> > future
> > readers would be nice. If read it will, we keep the upper 16bit, and
> > replaced
> > the lower bits with 0xEFFF (all bits set except 12) ? I'd rather not spend
> > time
> > thinking if I walk by this code again.
> 
> Vendor kernel use following comment to describe the purpose of this [1]:
> 
>   HW defeat workaround: VP9 and H.265 power save optimization cause
>   decoding corruption, disable optimization here.
> 
> From the TRM we can see following for rkvdec_swreg99_qos_ctrl:
> 
>   27:26 sw_axi_wr_hurry_level
>     00: hurry off 
>     01~11: hurry level 
>   25:24 sw_axi_rd_hurry_level
>     00: hurry off 
>     01~11: hurry level 
>   23:16 sw_bus2mc_buffer_qos_level
>     range is: 0~255
>     the value is means that left space <=
>     sw_bus2mc_buffer_qos_level, it will give hurry
>   15:0 swreg_block_gating_e
> 
> So yes this set swreg_block_gating_e to 0xEFFF. Possible this configure
> hw to not auto gate most internal clocks?
> 
> Could add a comment and possible use something like following:
> 
>   reg &= GENMASK(31, 16);
>   reg |= 0xEFFF;

Thanks for the information, I think this form is somewhat nicer indeed, and a
little comment, its fine to say that the QOS bits are undocumented.

Nicolas

> 
> [1]
> https://github.com/Kwiboo/linux-rockchip/blob/linux-6.1-stan-rkr6.1/drivers/video/rockchip/mpp/mpp_rkvdec.c#L857-L867
> 
> > 
> > > +		writel(reg, rkvdec->regs + RKVDEC_REG_QOS_CTRL);
> > > +	}
> > > +
> > >  	/* Start decoding! */
> > >  	reg = (run.pps->flags & V4L2_HEVC_PPS_FLAG_TILES_ENABLED) ?
> > >  		0 : RKVDEC_WR_DDR_ALIGN_EN;
> > > diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h
> > > b/drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h
> > > index 540c8bdf24e4..c627b6b6f53a 100644
> > > --- a/drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h
> > > +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h
> > > @@ -219,6 +219,8 @@
> > >  #define RKVDEC_REG_H264_ERR_E				0x134
> > >  #define RKVDEC_H264_ERR_EN_HIGHBITS(x)			((x) &
> > > 0x3fffffff)
> > >  
> > > +#define RKVDEC_REG_QOS_CTRL				0x18C
> > > +
> > >  #define RKVDEC_REG_PREF_LUMA_CACHE_COMMAND		0x410
> > >  #define RKVDEC_REG_PREF_CHR_CACHE_COMMAND		0x450
> > >  
> > > diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
> > > b/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
> > > index 0e7e16f20eeb..cadb9d592308 100644
> > > --- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
> > > +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c
> > > @@ -824,6 +824,16 @@ static int rkvdec_vp9_run(struct rkvdec_ctx *ctx)
> > >  	writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND);
> > >  
> > >  	writel(0xe, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN);
> > > +
> > > +	if (rkvdec->quirks & RKVDEC_QUIRK_DISABLE_QOS) {
> > > +		u32 reg;
> > > +
> > > +		reg = readl(rkvdec->regs + RKVDEC_REG_QOS_CTRL);
> > > +		reg |= 0xFFFF;
> > > +		reg &= ~BIT(12);
> > > +		writel(reg, rkvdec->regs + RKVDEC_REG_QOS_CTRL);
> > 
> > Can we deduplicate that ?
> 
> Guess so, any suggestion on how to best do that?
> 
> One possible way that comes to mind:
> 
>   if (rkvdec->quirks & RKVDEC_QUIRK_DISABLE_QOS)
> 	rkvdec_quirk_disable_qos(rkvdec);
> 
> > 
> > > +	}
> > > +
> > >  	/* Start decoding! */
> > >  	writel(RKVDEC_INTERRUPT_DEC_E | RKVDEC_CONFIG_DEC_CLK_GATE_E |
> > >  	       RKVDEC_TIMEOUT_E | RKVDEC_BUF_EMPTY_E,
> 
> [snip]

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

  reply	other threads:[~2025-08-12 16:28 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-10 21:24 [PATCH v2 0/7] media: rkvdec: Add HEVC backend Jonas Karlman
2025-08-10 21:24 ` [PATCH v2 2/7] media: rkvdec: Add variants support Jonas Karlman
2025-08-11 21:11   ` Nicolas Dufresne
2025-08-10 21:24 ` [PATCH v2 3/7] media: rkvdec: Implement capability filtering Jonas Karlman
2025-08-11 21:17   ` Nicolas Dufresne
2025-08-10 21:24 ` [PATCH v2 4/7] media: rkvdec: Add RK3288 variant Jonas Karlman
2025-08-11 21:17   ` Nicolas Dufresne
2025-08-10 21:24 ` [PATCH v2 5/7] media: rkvdec: Disable QoS for HEVC and VP9 on RK3328 Jonas Karlman
2025-08-11 21:25   ` Nicolas Dufresne
2025-08-11 22:22     ` Jonas Karlman
2025-08-12 12:47       ` Nicolas Dufresne
2025-08-11 23:08     ` Jonas Karlman
2025-08-12 13:00       ` Nicolas Dufresne [this message]
2025-08-17 16:18         ` Jonas Karlman
2025-08-10 21:24 ` [PATCH v2 6/7] media: dt-bindings: rockchip,vdec: Add RK3288 compatible Jonas Karlman
2025-08-10 21:24 ` [PATCH v2 7/7] ARM: dts: rockchip: Add vdec node for RK3288 Jonas Karlman
2025-08-11 21:52 ` [PATCH v2 0/7] media: rkvdec: Add HEVC backend Nicolas Dufresne
2025-08-12  0:00   ` Jonas Karlman
2025-08-12 12:38     ` Nicolas Dufresne
2025-08-12 12:44       ` Nicolas Dufresne
2025-08-12 17:31         ` Jonas Karlman
2025-08-12 18:26           ` Nicolas Dufresne
2025-08-12 18:52             ` Nicolas Dufresne
2025-08-17 16:33             ` Jonas Karlman
2025-08-12 19:57   ` Detlev Casanova
2025-08-12 21:11     ` Nicolas Dufresne
2025-08-12 12:11 ` Diederik de Haas
2025-08-12 12:55   ` Diederik de Haas
2025-08-12 13:27     ` Nicolas Dufresne
2025-08-12 14:09       ` Diederik de Haas
2025-08-14 21:25       ` Alex Bee
2025-08-12 17:11   ` Jonas Karlman
2025-08-12 18:28     ` Diederik de Haas
     [not found] ` <20250810212454.3237486-2-jonas@kwiboo.se>
     [not found]   ` <9c8cb837d10d3cdd54fe34dedfe40c10e848f648.camel@collabora.com>
2025-08-11 19:46     ` [PATCH v2 1/7] " Jonas Karlman
2025-08-11 20:27       ` Nicolas Dufresne
     [not found]   ` <bdb53663ab741fbc70dd83fb858432b838736219.camel@collabora.com>
2025-08-12  0:58     ` Jonas Karlman
2025-08-12 13:07       ` Nicolas Dufresne
2025-08-12 19:54         ` Detlev Casanova
2025-08-17 16:39           ` Jonas Karlman
2025-08-18  8:25             ` Detlev Casanova
2025-08-12 20:10   ` Detlev Casanova
2025-08-17 16:46     ` Jonas Karlman
     [not found]   ` <432ab63698b27ca5bce3a7a30d630685aff782b6.camel@collabora.com>
2025-09-03  7:28     ` Jonas Karlman
2025-09-03 13:44       ` 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=f2908b2d35671e70e6a8b295de623e3a3ffe2212.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=detlev.casanova@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=heiko@sntech.de \
    --cc=jonas@kwiboo.se \
    --cc=knaerzche@gmail.com \
    --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=sebastian.fricke@collabora.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;
as well as URLs for NNTP newsgroup(s).