lkml.org 
[lkml]   [2020]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 5.4 101/205] media: coda: fix deadlock between decoder picture run and start command
    Date
    From: Philipp Zabel <p.zabel@pengutronix.de>

    [ Upstream commit a3fd80198de6ab98a205cf7fb148d88e9e1c44bb ]

    The BIT decoder picture run temporarily locks the bitstream mutex while
    the coda device mutex is locked, to refill the bitstream ring buffer.
    Consequently, the decoder start command, which locks both mutexes when
    flushing the bitstream ring buffer, must lock the coda device mutex
    first as well, to avoid an ABBA deadlock.

    Fixes: e7fd95849b3c ("media: coda: flush bitstream ring buffer on decoder restart")
    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@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/media/platform/coda/coda-common.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
    index 73222c0615c0..834f11fe9dc2 100644
    --- a/drivers/media/platform/coda/coda-common.c
    +++ b/drivers/media/platform/coda/coda-common.c
    @@ -1084,16 +1084,16 @@ static int coda_decoder_cmd(struct file *file, void *fh,

    switch (dc->cmd) {
    case V4L2_DEC_CMD_START:
    - mutex_lock(&ctx->bitstream_mutex);
    mutex_lock(&dev->coda_mutex);
    + mutex_lock(&ctx->bitstream_mutex);
    coda_bitstream_flush(ctx);
    - mutex_unlock(&dev->coda_mutex);
    dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
    V4L2_BUF_TYPE_VIDEO_CAPTURE);
    vb2_clear_last_buffer_dequeued(dst_vq);
    ctx->bit_stream_param &= ~CODA_BIT_STREAM_END_FLAG;
    coda_fill_bitstream(ctx, NULL);
    mutex_unlock(&ctx->bitstream_mutex);
    + mutex_unlock(&dev->coda_mutex);
    break;
    case V4L2_DEC_CMD_STOP:
    stream_end = false;
    --
    2.20.1
    \
     
     \ /
      Last update: 2020-01-16 17:53    [W:7.995 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site