diff mbox series

[06/28] media: coda: fix V4L2_DEC_CMD_STOP when all buffers are already consumed

Message ID 20190618164535.20162-7-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series media: coda: fixes and improvements | expand

Commit Message

Philipp Zabel June 18, 2019, 4:45 p.m. UTC
From: Marco Felsch <m.felsch@pengutronix.de>

When the DEC_CMD_STOP command is issued after the context has already
consumed all the queued buffers, we need to make sure to wake the
destination queue with last_buffer_dequeued set, to allow userspace to
make progress in its EOS handling.

As there might still be picture run workers pending at that point, we
need to synchronize with them, so the sequence number comparison reads
stable values.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
[l.stach@pengutronix.de: rewrite to fix multi-context use-cases,
 reword commit message]
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-common.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 7dbeb80d40f4..232bda4b7016 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1071,6 +1071,12 @@  static int coda_decoder_cmd(struct file *file, void *fh,
 		coda_bit_stream_end_flag(ctx);
 		ctx->hold = false;
 		v4l2_m2m_try_schedule(ctx->fh.m2m_ctx);
+
+		flush_work(&ctx->pic_run_work);
+
+		/* If there is no buffer in flight, wake up */
+		if (!ctx->streamon_out || ctx->qsequence == ctx->osequence)
+			coda_wake_up_capture_queue(ctx);
 		break;
 	default:
 		return -EINVAL;