Messages in this thread |  | | From | Detlev Casanova <> | | Subject | [PATCH v3 0/4] media: rkvdec: Switch to using a bitwriter | | Date | Thu, 02 Apr 2026 10:06:35 -0400 |
| |
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/ [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> --- Changes in v3: - Change bitwriter function to static inline instead of its own object - Link to v2: https://patch.msgid.link/20260327-rkvdec-use-bitwriter-v2-0-a5a4754b0518@collabora.com
Changes in v2: - Don't use BW_FIELD to compute buffer size - Use correct size for buffers - Fix missed indentation issues - Link to v1: https://patch.msgid.link/20260327-rkvdec-use-bitwriter-v1-0-982cf872b590@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
.../platform/rockchip/rkvdec/rkvdec-bitwriter.h | 39 ++ .../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 | 93 +--- .../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 +++++++++------------ 9 files changed, 562 insertions(+), 851 deletions(-) --- base-commit: d0c3bcd5b8976159d835a897254048e078f447e6 change-id: 20260327-rkvdec-use-bitwriter-f1d149b3cf7c
Best regards, -- Detlev Casanova <detlev.casanova@collabora.com>
|  |