]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: rkvdec: reduce stack usage in rkvdec_init_v4l2_vp9_count_tbl()
authorArnd Bergmann <arnd@arndb.de>
Mon, 2 Feb 2026 09:47:51 +0000 (10:47 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 18 Mar 2026 10:21:31 +0000 (11:21 +0100)
The deeply nested loop in rkvdec_init_v4l2_vp9_count_tbl() needs a lot
of registers, so when the clang register allocator runs out, it ends up
spilling countless temporaries to the stack:

drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c:966:12: error: stack frame size (1472) exceeds limit (1280) in 'rkvdec_vp9_start' [-Werror,-Wframe-larger-than]

Marking this function as noinline_for_stack keeps it out of
rkvdec_vp9_start(), giving the compiler more room for optimization.

The resulting code is good enough that both the total stack usage
and the loop get enough better to stay under the warning limit,
though it's still slow, and would need a larger rework if this
function ends up being called in a fast path.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c

index e4cdd2122873e38202ca2436a7f412b9db007656..2751f5396ee8017e53645c5fe9b03c52ffb37b1b 100644 (file)
@@ -893,7 +893,8 @@ out_update_last:
        update_ctx_last_info(vp9_ctx);
 }
 
-static void rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
+static noinline_for_stack void
+rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
 {
        struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv;
        struct rkvdec_vp9_intra_frame_symbol_counts *intra_cnts = vp9_ctx->count_tbl.cpu;