summaryrefslogtreecommitdiff
path: root/drivers/media/platform/coda/coda-common.c
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2019-06-18 12:45:30 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-06-24 14:44:26 -0400
commit9ee50a9489f16048a82c94139f5436f4bb2620d9 (patch)
treed54aa68424c1ebf85667a7b9f269284e199a55eb /drivers/media/platform/coda/coda-common.c
parentcf895efc4d9c2dfb3cd03cf298ea55637feba901 (diff)
downloadlinux-9ee50a9489f16048a82c94139f5436f4bb2620d9.tar.gz
linux-9ee50a9489f16048a82c94139f5436f4bb2620d9.tar.bz2
linux-9ee50a9489f16048a82c94139f5436f4bb2620d9.zip
media: coda: lock capture queue wakeup against encoder stop command
Make sure that an encoder stop command running concurrently with an encoder finish_run always either flags the last returned buffer or wakes up the capture queue to signal the end of stream condition afterwards. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform/coda/coda-common.c')
-rw-r--r--drivers/media/platform/coda/coda-common.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 73c18be14cbf..95c233b2cbf8 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1034,19 +1034,27 @@ static int coda_encoder_cmd(struct file *file, void *fh,
if (ret < 0)
return ret;
+ mutex_lock(&ctx->wakeup_mutex);
buf = v4l2_m2m_last_src_buf(ctx->fh.m2m_ctx);
if (buf) {
+ /*
+ * If the last output buffer is still on the queue, make sure
+ * that decoder finish_run will see the last flag and report it
+ * to userspace.
+ */
buf->flags |= V4L2_BUF_FLAG_LAST;
} else {
/* Set the stream-end flag on this context */
ctx->bit_stream_param |= CODA_BIT_STREAM_END_FLAG;
- 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);
+ /*
+ * If the last output buffer has already been taken from the
+ * queue, wake up the capture queue and signal end of stream
+ * via the -EPIPE mechanism.
+ */
+ coda_wake_up_capture_queue(ctx);
}
+ mutex_unlock(&ctx->wakeup_mutex);
return 0;
}
@@ -2466,6 +2474,7 @@ static int coda_open(struct file *file)
mutex_init(&ctx->bitstream_mutex);
mutex_init(&ctx->buffer_mutex);
+ mutex_init(&ctx->wakeup_mutex);
INIT_LIST_HEAD(&ctx->buffer_meta_list);
spin_lock_init(&ctx->buffer_meta_lock);