From: Daniel Golle <daniel@makrotopia.org>
To: Detlev Casanova <detlev.casanova@collabora.com>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Alex Bee <knaerzche@gmail.com>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
Jonas Karlman <jonas@kwiboo.se>,
Sebastian Fricke <sebastian.fricke@collabora.com>,
linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 6/7] media: rkvdec: hevc: cache every short-term RPS set
Date: Fri, 20 Nov 2026 23:43:51 +0000 [thread overview]
Message-ID: <1628863e476edf7ea506eb269a742449721bbfbd.1795217229.git.daniel@makrotopia.org> (raw)
In-Reply-To: <cover.1795217229.git.daniel@makrotopia.org>
The driver rebuilds the short-term RPS table of the hardware only when
the EXT_SPS_ST_RPS control changed, but it compares just the first set
with a cached copy. A change in a later set or in the number of sets
goes unnoticed, and the hardware keeps the old table. As the cache
starts zeroed, a stream whose first set is all zero never gets a table
at all. Inter pictures are then decoded with wrong references, as seen
with JCT-VC DELTAQP_A_BRCM_4 on an RK3568.
Cache all sets together with their number. The control framework limits
the number of sets to 64, which is the size of the cache.
Fixes: c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
Changes since v1:
- Rewrite the commit message
- No code change
.../platform/rockchip/rkvdec/rkvdec-hevc-common.c | 12 ++++++++----
.../platform/rockchip/rkvdec/rkvdec-hevc-common.h | 9 ++++++++-
.../platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c | 2 +-
.../platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c | 2 +-
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
index 3b281c16a75ed..e3449ab0d415b 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
@@ -330,14 +330,17 @@ static void st_ref_pic_set_calculate(struct rkvdec_hevc_run *run, int idx,
}
static void rkvdec_hevc_prepare_hw_st_rps(struct rkvdec_hevc_run *run, struct rkvdec_rps *rps,
- struct v4l2_ctrl_hevc_ext_sps_st_rps *cache)
+ struct rkvdec_hevc_st_rps_cache *cache)
{
+ u8 num_sets = run->sps->num_short_term_ref_pic_sets;
+ size_t size;
int idx;
if (!run->ext_sps_st_rps)
return;
- if (!memcmp(cache, run->ext_sps_st_rps, sizeof(struct v4l2_ctrl_hevc_ext_sps_st_rps)))
+ size = num_sets * sizeof(*cache->sets);
+ if (cache->num_sets == num_sets && !memcmp(cache->sets, run->ext_sps_st_rps, size))
return;
struct calculated_rps_st_set *calculated_rps_st_sets =
@@ -357,11 +360,12 @@ static void rkvdec_hevc_prepare_hw_st_rps(struct rkvdec_hevc_run *run, struct rk
kfree(calculated_rps_st_sets);
- memcpy(cache, run->ext_sps_st_rps, sizeof(struct v4l2_ctrl_hevc_ext_sps_st_rps));
+ memcpy(cache->sets, run->ext_sps_st_rps, size);
+ cache->num_sets = num_sets;
}
void rkvdec_hevc_assemble_hw_rps(struct rkvdec_hevc_run *run, struct rkvdec_rps *rps,
- struct v4l2_ctrl_hevc_ext_sps_st_rps *st_cache)
+ struct rkvdec_hevc_st_rps_cache *st_cache)
{
rkvdec_hevc_prepare_hw_st_rps(run, rps, st_cache);
rkvdec_hevc_assemble_hw_lt_rps(run, rps);
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h
index 2a9b7719ab2d5..f6a3dec6ff4ad 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h
@@ -35,10 +35,17 @@
#define RKVDEC_RPS_HEVC_SIZE ALIGN(1032 + 64 * 384, 128)
+#define RKVDEC_HEVC_MAX_SHORT_TERM_REF_PIC_SETS 64
+
struct rkvdec_rps {
u32 info[RKVDEC_RPS_HEVC_SIZE / 8 / 4];
} __packed;
+struct rkvdec_hevc_st_rps_cache {
+ struct v4l2_ctrl_hevc_ext_sps_st_rps sets[RKVDEC_HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
+ u8 num_sets;
+};
+
struct rkvdec_hevc_run {
struct rkvdec_run base;
const struct v4l2_ctrl_hevc_slice_params *slices_params;
@@ -65,7 +72,7 @@ void compute_tiles_non_uniform(struct rkvdec_hevc_run *run, u16 log2_min_cb_size
u16 width, u16 height, s32 pic_in_cts_width,
s32 pic_in_cts_height, u16 *column_width, u16 *row_height);
void rkvdec_hevc_assemble_hw_rps(struct rkvdec_hevc_run *run, struct rkvdec_rps *rps,
- struct v4l2_ctrl_hevc_ext_sps_st_rps *st_cache);
+ struct rkvdec_hevc_st_rps_cache *st_cache);
void rkvdec_hevc_assemble_hw_scaling_list(struct rkvdec_ctx *ctx,
struct rkvdec_hevc_run *run,
struct scaling_factor *scaling_factor,
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
index db836536e601b..8388421a68a48 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
@@ -117,7 +117,7 @@ struct rkvdec_hevc_priv_tbl {
struct rkvdec_hevc_ctx {
struct rkvdec_aux_buf priv_tbl;
struct v4l2_ctrl_hevc_scaling_matrix scaling_matrix_cache;
- struct v4l2_ctrl_hevc_ext_sps_st_rps st_cache;
+ struct rkvdec_hevc_st_rps_cache st_cache;
struct rkvdec_vdpu381_regs_hevc regs;
};
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
index c409d21c08598..47f236295f1e5 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
@@ -124,7 +124,7 @@ struct rkvdec_hevc_priv_tbl {
struct rkvdec_hevc_ctx {
struct rkvdec_aux_buf priv_tbl;
struct v4l2_ctrl_hevc_scaling_matrix scaling_matrix_cache;
- struct v4l2_ctrl_hevc_ext_sps_st_rps st_cache;
+ struct rkvdec_hevc_st_rps_cache st_cache;
struct vdpu383_regs_h26x regs;
};
--
2.56.1
next prev parent reply other threads:[~2026-11-20 23:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 23:41 [PATCH v2 0/7] media: rkvdec: Fix the HEVC reference picture set handling Daniel Golle
2026-11-20 23:41 ` [PATCH v2 1/7] media: rkvdec: hevc: apply request controls first Daniel Golle
2026-11-20 23:41 ` [PATCH v2 2/7] media: rkvdec: vdpu383: complete refused HEVC requests Daniel Golle
2026-11-20 23:42 ` [PATCH v2 3/7] media: rkvdec: vdpu381: refuse HEVC jobs without RPS sets Daniel Golle
2026-11-20 23:42 ` [PATCH v2 4/7] media: rkvdec: hevc: refuse RPS controls shorter than the SPS counts Daniel Golle
2026-11-20 23:43 ` [PATCH v2 5/7] media: rkvdec: hevc: bound predicted short-term RPS sets Daniel Golle
2026-11-20 23:43 ` Daniel Golle [this message]
2026-11-20 23:44 ` [PATCH v2 7/7] media: rkvdec: hevc: check the RPS scratch allocation Daniel Golle
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=1628863e476edf7ea506eb269a742449721bbfbd.1795217229.git.daniel@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=detlev.casanova@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=hverkuil+cisco@kernel.org \
--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=nicolas.dufresne@collabora.com \
--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
all inboxes | Powered by JetHome®