[PATCH v1 0/9] fix decoder corruption, stalls and seek issues

From: Jackson.lee

Date: Tue Oct 06 2026 - 22:01:11 EST


From: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>

This series fixes a set of decoder problems in the wave5 driver that show
up as corrupted output, stalled or crashed instances, and lost frames
across seeks. All of them carry a Fixes: tag.

Locking and job ownership
1. Serialise removal of OUTPUT buffers between finish_decode(),
streamoff_output() and the start_decode() error path.
4. Acknowledge the interrupt only after it has been dispatched, so a
completion the VPU adds meanwhile is no longer dropped and does not
leave an instance waiting forever.
5. Finish each m2m job exactly once. A second v4l2_m2m_job_finish() from
the same context could clear curr_ctx under v4l2_m2m_try_run() and
oops in the m2m worker.

Decode scheduling
6. Issue DEC_PIC only when the ring buffer holds bitstream that no queued
command will consume. The current check compares two unrelated
counters, which sends commands against an empty ring or duplicates
one already in flight and corrupts the output. A delayed work restarts
an instance left idle with data still buffered.

Seek / flush
2. Drop the consumed-byte tally on OUTPUT streamoff, so it is not
credited to the first buffers queued after a seek.
3. Wait between FLUSH retries instead of spending the retry budget in
microseconds, and ignore dec_info when reading it failed.
8. Re-establish the display flags from the vb2 buffer states after a
flush, so buffers held by userspace are not decoded into.
9. Do not reset the frame buffers on a CAPTURE streamoff that is only
part of a seek.

Timestamps
7. Hand OUTPUT timestamps to decoded pictures in decode order. One
completion can consume several source buffers, and keeping only the
last timestamp lost the others ("Too old frames, bug in decoder" in
GStreamer).

Testing
-------
Tested on a TI J721S2 EVM (Wave521C, product code 0x521c, firmware
revision 363254) with GStreamer 1.24.13 and the v4l2h264dec/v4l2h265dec
elements.

fluster (GStreamer-H.264-V4L2-Gst1.0 / GStreamer-H.265-V4L2-Gst1.0):

JVT-AVC_V1 77/135 (-j1 and -j3, identical per vector)
JCT-VC-HEVC_V1 133/147 (-j1 and -j3, identical per vector)

The remaining AVC failures are interlaced, MBAFF/PAFF, FMO and SP slice
streams. 11 of the 14 HEVC failures are Main10 streams, which this SoC
does not decode ("no support for 10 bit depth"); the others are
PICSIZE_A_Bossen_1, PICSIZE_B_Bossen_1 and DELTAQP_A_BRCM_4.

No oops, call trace, workqueue warning or "invalid display frame index"
message was logged during the runs.

v4l2-compliance 1.28.1-5233, SHA: fc15e229d9d3:

Total for wave5-dec device /dev/video0: 47, Succeeded: 47, Failed: 0, Warnings: 2
Total for wave5-enc device /dev/video1: 47, Succeeded: 47, Failed: 0, Warnings: 0

Brandon Brnich (2):
media: chips-media: wave5: Ensure Atomic Access to src_buf list
media: chips-media: wave5: Stop FrameBuf Reset During Seek

Jackson Lee (7):
media: chips-media: wave5: drop the consumed-byte tally on OUTPUT
streamoff
media: chips-media: wave5: wait before retrying a refused flush
media: chips-media: wave5: ack the interrupt after dispatching it
media: chips-media: wave5: finish a job only once
media: chips-media: wave5: decode only when the ring holds unclaimed
bitstream
media: chips-media: wave5: stamp decoded pictures from a decode-order
queue
media: chips-media: wave5: restore the display flags after a flush

.../chips-media/wave5/wave5-vpu-dec.c | 312 +++++++++++++++---
.../platform/chips-media/wave5/wave5-vpu.c | 28 +-
.../platform/chips-media/wave5/wave5-vpuapi.c | 18 +-
.../platform/chips-media/wave5/wave5-vpuapi.h | 13 +
4 files changed, 310 insertions(+), 61 deletions(-)


base-commit: 58348f64125e9a3e44d3abb275ca7f4e6c9641e5
--
2.43.0