[PATCH v1 2/9] media: chips-media: wave5: drop the consumed-byte tally on OUTPUT streamoff

From: Jackson.lee

Date: Tue Oct 06 2026 - 22:02:30 EST


From: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>

remaining_consumed_bytes is never cleared. On a seek the OUTPUT buffers
it accounts for are returned with VB2_BUF_STATE_ERROR, but the tally
survives and is credited to the first buffers queued afterwards, which
are then completed before the VPU has read them.

Clear it where last_rd_ptr is already being rebased.

Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>
Signed-off-by: Nas Chung <nas.chung@xxxxxxxxxxxxxxx>
---
.../media/platform/chips-media/wave5/wave5-vpu-dec.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
index 6af7d2e9a9f3..07dcb20ffdcb 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1495,6 +1495,18 @@ static int streamoff_output(struct vb2_queue *q)
inst->codec_info->dec_info.stream_rd_ptr = new_rd_ptr;
inst->codec_info->dec_info.stream_wr_ptr = new_rd_ptr;

+ /*
+ * remaining_consumed_bytes holds the consumed bytes that no source
+ * buffer has claimed yet. The buffers it belongs to are returned with
+ * VB2_BUF_STATE_ERROR just above, so the tally has to go with them --
+ * last_rd_ptr is being rebased for the same reason.
+ *
+ * Left behind it is credit against buffers that no longer exist, and
+ * wave5_handle_src_buffer() spends it on the first buffers queued after
+ * the seek, completing them before the VPU has read their payload.
+ */
+ inst->remaining_consumed_bytes = 0;
+
if (v4l2_m2m_has_stopped(m2m_ctx)) {
unsigned long flags;

--
2.43.0