[PATCH 0/4] media: rkvdec: Switch to using a bitwriter
From: Detlev Casanova <detlev.casanova@collabora.com>
Date: 2026-03-27 15:16:06
Also in:
linux-media, linux-rockchip, lkml, llvm
Using bitfields in large structures where fields are mostly unaligned can be hard on the compiler. Issues have been reported with clang ([1], [2]) and, even though those issues are addressed by clang devs, some setup can't or won't update clang just to compile a driver. Even when fixed, the compiler still might have to allocate a bigger stack frame to manage misalignement. Coupled with other features like KASAN, the stack becomes larger than the kernel's maximum [3]. To avoid this, let's drop the bitfield implementation and switch to a bitwriter. There is already one for the older variants, so make it global and use it in other variants. Note that only buffer structures are switched to the bitwriter. The registers representation structures are kept with bitfields, as they are properly aligned every 32 bits and don't require heavy stack overhead. Also note that the VDPU381 SPS and PPS structs are kept with bitfields, for the same reason that they are small and aligned enough not to require heavy stack overhead. [1]: https://lore.kernel.org/oe-kbuild-all/202601211924.rqKS2Ihm-lkp@intel.com/ (local) [2]: https://github.com/llvm/llvm-project/issues/178535 [3]: https://yhbt.net/lore/llvm/20260121230406.GA2625738@ax162/T/#mad878ec24a8224e1387ef5e73cb77b9ada55e3f2 Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com> --- Detlev Casanova (4): media: rkvdec: Introduce a global bitwriter helper media: rkvdec: Use the global bitwriter instead of local one media: rkvdec: common: Drop bitfields for the bitwriter media: rkvdec: vdpu383: Drop bitfields for the bitwriter drivers/media/platform/rockchip/rkvdec/Makefile | 1 + .../platform/rockchip/rkvdec/rkvdec-bitwriter.c | 30 ++ .../platform/rockchip/rkvdec/rkvdec-bitwriter.h | 25 + .../platform/rockchip/rkvdec/rkvdec-h264-common.c | 51 +-- .../platform/rockchip/rkvdec/rkvdec-h264-common.h | 40 +- .../media/platform/rockchip/rkvdec/rkvdec-h264.c | 109 ++--- .../platform/rockchip/rkvdec/rkvdec-hevc-common.c | 92 +--- .../platform/rockchip/rkvdec/rkvdec-hevc-common.h | 57 +-- .../media/platform/rockchip/rkvdec/rkvdec-hevc.c | 171 +++---- .../platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c | 351 ++++++-------- .../platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c | 502 +++++++++------------ 11 files changed, 578 insertions(+), 851 deletions(-) --- base-commit: bbeb83d3182abe0d245318e274e8531e5dd7a948 change-id: 20260327-rkvdec-use-bitwriter-f1d149b3cf7c Best regards, -- Detlev Casanova [off-list ref]