[PATCH 6/7] media: rkvdec: Wait for all buffers before stop_streaming

From: Detlev Casanova

Date: Thu Apr 09 2026 - 09:59:31 EST


Because the jobs are marked as finished before the buffer are marked
as done, the stop_streaming callback can be called while the decoder
is still running.

This could even go further and deallocate buffers that are still
being used by the hardware.

Fortunately, to avoid that, the vb2_wait_for_all_buffers() function
can be used at the beginning of the stop_streaming callback to make sure
that cleanup functions are called after the last buffer has been returned
to the queue.

Signed-off-by: Detlev Casanova <detlev.casanova@xxxxxxxxxxxxx>
---
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 5667d625f016..c2818f1575ef 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -1027,6 +1027,8 @@ static void rkvdec_stop_streaming(struct vb2_queue *q)

if (desc->ops->stop)
desc->ops->stop(ctx);
+
+ vb2_wait_for_all_buffers(q);
}

rkvdec_queue_cleanup(q, VB2_BUF_STATE_ERROR);

--
2.53.0