[PATCH 1/7] media: s5p-mfc: clear the EOS flag when a buffer is queued
From: Shigeaki Asai via B4 Relay
Date: Mon Nov 30 2026 - 08:03:50 EST
From: Shigeaki Asai <y-asai.0816@xxxxxxxxxxxx>
V4L2_DEC_CMD_STOP marks the last queued source buffer with
MFC_BUF_FLAG_EOS. The flag is kept in the per-index buffer state and is
never cleared, so it is still set when the application queues the same
buffer index again after the drain. Decoding then stops (the context
enters the FINISHING state) every time that buffer is used, for example
after a seek in Kodi, which drains the decoder first.
The same applies to the destination buffers, which are marked with
MFC_BUF_FLAG_EOS when all frames are extracted.
Clear MFC_BUF_FLAG_EOS together with MFC_BUF_FLAG_USED when a buffer is
queued.
Tested on an ODROID-XU4 (Exynos5422) with Kodi/FFmpeg on a 7.3.4
kernel (LibreELEC).
The problem was investigated and this patch was prepared with the help
of Claude (AI).
Fixes: a34026e75bd1 ("[media] s5p-mfc: Add support for EOS command and EOS event in video decoder")
Fixes: 4d0b0ed63660 ("[media] s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue")
Signed-off-by: Shigeaki Asai <y-asai.0816@xxxxxxxxxxxx>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index afd28beabfde..1b6ea99bd415 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -1137,14 +1137,14 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
mfc_buf = &ctx->src_bufs[vb->index];
- mfc_buf->flags &= ~MFC_BUF_FLAG_USED;
+ mfc_buf->flags &= ~(MFC_BUF_FLAG_USED | MFC_BUF_FLAG_EOS);
spin_lock_irqsave(&dev->irqlock, flags);
list_add_tail(&mfc_buf->list, &ctx->src_queue);
ctx->src_queue_cnt++;
spin_unlock_irqrestore(&dev->irqlock, flags);
} else if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
mfc_buf = &ctx->dst_bufs[vb->index];
- mfc_buf->flags &= ~MFC_BUF_FLAG_USED;
+ mfc_buf->flags &= ~(MFC_BUF_FLAG_USED | MFC_BUF_FLAG_EOS);
/* Mark destination as available for use by MFC */
spin_lock_irqsave(&dev->irqlock, flags);
set_bit(vb->index, &ctx->dec_dst_flag);
--
2.43.0