[PATCH v2 3/7] media: rkvdec: vdpu381: refuse HEVC jobs without RPS sets
From: Daniel Golle
Date: Fri Nov 20 2026 - 18:42:28 EST
When a stream uses reference picture sets and userspace never set the
EXT_SPS_ST_RPS or EXT_SPS_LT_RPS control, the VDPU381 HEVC back end
only logs a warning and starts the decoder anyway. The hardware then
uses an RPS table which does not belong to the stream and gives wrong
pictures at best. On the VDPU346 of the RK3568, which uses this back
end, such a decode ends in a failed IOMMU reset and the system stops
responding until the hardware watchdog resets it.
Fail the job with -EINVAL before the hardware is started, as the
VDPU383 back end does.
Fixes: c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
Changes since v1:
- Move before the check of the control size, was 5/7
- Test ctx->has_sps_st_rps and ctx->has_sps_lt_rps as a result of the
new position, the next patch replaces them in both back ends
- Rewrite the commit message
.../rockchip/rkvdec/rkvdec-vdpu381-hevc.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
index e1936e87f45be..7627282c15f0a 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
@@ -596,21 +596,18 @@ static int rkvdec_hevc_run(struct rkvdec_ctx *ctx)
rkvdec_hevc_run_preamble(ctx, &run);
- rkvdec_hevc_assemble_hw_scaling_list(ctx, &run, &tbl->scaling_list,
- &hevc_ctx->scaling_matrix_cache);
- assemble_hw_pps(ctx, &run);
-
- /*
- * On vdpu381, not setting the long and short term ref sets will just output wrong frames.
- * Let's just warn about it and let the decoder run anyway.
- */
if ((!ctx->has_sps_lt_rps && run.sps->num_long_term_ref_pics_sps) ||
(!ctx->has_sps_st_rps && run.sps->num_short_term_ref_pic_sets)) {
- dev_warn_ratelimited(rkvdec->dev, "Long and short term RPS not set\n");
- } else {
- rkvdec_hevc_assemble_hw_rps(&run, &tbl->rps, &hevc_ctx->st_cache);
+ dev_err_ratelimited(rkvdec->dev, "Long and short term RPS not set\n");
+ rkvdec_run_postamble(ctx, &run.base);
+ return -EINVAL;
}
+ rkvdec_hevc_assemble_hw_scaling_list(ctx, &run, &tbl->scaling_list,
+ &hevc_ctx->scaling_matrix_cache);
+ assemble_hw_pps(ctx, &run);
+ rkvdec_hevc_assemble_hw_rps(&run, &tbl->rps, &hevc_ctx->st_cache);
+
config_registers(ctx, &run);
rkvdec_run_postamble(ctx, &run.base);
--
2.56.1