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 6/7] media: rkvdec: hevc: cache every short-term RPS set
Date: Sat, 14 Nov 2026 10:23:13 +0000 [thread overview]
Message-ID: <bc2872729866f947057117ea6635cd44f4b4e749.1794645268.git.daniel@makrotopia.org> (raw)
In-Reply-To: <cover.1794645268.git.daniel@makrotopia.org>
rkvdec_hevc_prepare_hw_st_rps() skips building the short-term RPS
table when the first element of the EXT_SPS_ST_RPS control equals its
cache, which holds a single element and starts zeroed. When the first
element is all zero, e.g. for an empty first set, the table entries of
the remaining sets are never built, and an SPS that differs from the
previous one only after its first set, or only in
num_short_term_ref_pic_sets, keeps the previous table. Inter pictures
are then decoded with wrong references: JCT-VC DELTAQP_A_BRCM_4 decodes
its intra pictures correctly and its inter pictures wrongly on an
RK3568, whose VDPU346 uses the VDPU381 back end.
Cache all sets the SPS uses together with their number, for both the
VDPU381 and the VDPU383 back end. The SPS control validation bounds
num_short_term_ref_pic_sets to 64, 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>
---
.../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.0
next prev parent reply other threads:[~2026-11-14 10:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 10:22 [PATCH 0/7] media: rkvdec: Fix the HEVC reference picture set handling Daniel Golle
2026-11-14 10:22 ` [PATCH 1/7] media: rkvdec: hevc: apply request controls first Daniel Golle
2026-11-14 10:22 ` [PATCH 2/7] media: rkvdec: vdpu383: complete refused HEVC requests Daniel Golle
2026-11-14 10:22 ` [PATCH 3/7] media: rkvdec: hevc: bound the RPS reads by the control size Daniel Golle
2026-11-14 10:23 ` [PATCH 5/7] media: rkvdec: vdpu381: refuse HEVC jobs without RPS sets Daniel Golle
2026-11-14 10:23 ` Daniel Golle [this message]
2026-11-14 10:23 ` [PATCH 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=bc2872729866f947057117ea6635cd44f4b4e749.1794645268.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®