[PATCH 0/4] media: tegra-vde: less cache maintenance, reject CABAC early

From: Jerome Berclaz via B4 Relay

Date: Thu Nov 26 2026 - 19:56:17 EST


These patches came out of getting hardware H.264 playback working well on a
Tegra30 device (Microsoft Surface RT) with mpv and FFmpeg's V4L2 request
hwaccel. The decoder sits behind the SMMU there, so buffers use
vb2_dma_sg_memops with cached pages, and cache maintenance turned out to be
the largest kernel cost of playback.

Patches 1 and 3 shrink what gets cleaned for the bitstream (OUTPUT)
buffers: a smaller default size derived from the frame size, and cleaning
only the bytes the hardware reads instead of the whole buffer (FFmpeg
allocates width x height x 3/2, while a coded frame is usually a few KB).
Patch 2 lets clients that never read decoded frames through the CPU skip
the capture-side sync with the existing cache hint flags, as the MediaTek
decoder already allows. Patch 4 rejects CABAC in try_ctrl, so that setting
the controls fails right away instead of the decode job failing later.
Userspace that ignores buffer error flags otherwise shows broken frames.

Tested on the Surface RT with the same patches on a 7.3.1-based kernel
(720p/1080p H.264, mpv and GStreamer). On 720p playback, the v7/l2c210
cache maintenance functions had been about 21% of all CPU samples in the
decoding thread before patch 1. Build-tested on media/next for ARM
(tegra_defconfig, W=1), each patch individually.

A follow-up RFC will add CABAC, weighted prediction and High profile
support on Tegra30, by parsing slice headers in software. With it,
patch 4's check only remains for SoCs without that support.

These patches were developed with the help of an AI assistant;
I have reviewed them and tested them on the device.

---
Jerome Berclaz (4):
media: tegra-vde: size the bitstream buffer from the frame size
media: tegra-vde: allow cache hints on the capture queue
media: tegra-vde: clean only the used part of the bitstream buffer
media: tegra-vde: reject CABAC in the H.264 PPS control

drivers/media/platform/nvidia/tegra-vde/v4l2.c | 71 +++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 2 deletions(-)
---
base-commit: b7ac871daee981f1963f632586ff9b9d898ce5dd
change-id: 20261126-tegra-vde-fixes-ffe9cf098bf8

Best regards,
--
Jerome Berclaz <jerome.berclaz@xxxxxxxxx>