From 85af4797af45805db7ab2f66159c1aee8da5537b Mon Sep 17 00:00:00 2001 From: Cai YiWei Date: Fri, 26 Apr 2024 18:06:09 +0800 Subject: [PATCH] media: rockchip: isp: fix dmarx deadlock lock dmarx buf_done->vicap->rx_buffer->wait lock Change-Id: I02a48f1c53f2fb6bb7a8c86e9f80dfe3d9c2ba27 Signed-off-by: Cai YiWei --- drivers/media/platform/rockchip/isp/dmarx.c | 36 ++++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/rockchip/isp/dmarx.c b/drivers/media/platform/rockchip/isp/dmarx.c index 4015779ce8fe..77be7e0b439c 100644 --- a/drivers/media/platform/rockchip/isp/dmarx.c +++ b/drivers/media/platform/rockchip/isp/dmarx.c @@ -480,14 +480,31 @@ static struct streams_ops rkisp2_dmarx_streams_ops = { static int dmarx_frame_end(struct rkisp_stream *stream) { + struct rkisp_buffer *buf = NULL; unsigned long lock_flags = 0; spin_lock_irqsave(&stream->vbq_lock, lock_flags); if (stream->curr_buf) { - if (stream->curr_buf->other) { + buf = stream->curr_buf; + stream->curr_buf = NULL; + } + if (!list_empty(&stream->buf_queue)) { + stream->curr_buf = + list_first_entry(&stream->buf_queue, + struct rkisp_buffer, + queue); + list_del(&stream->curr_buf->queue); + } + + if (stream->curr_buf) + stream->ops->update_mi(stream); + spin_unlock_irqrestore(&stream->vbq_lock, lock_flags); + + if (buf) { + if (buf->other) { struct rkisp_device *dev = stream->ispdev; struct v4l2_subdev *sd = dev->active_sensor->sd; - struct rkisp_rx_buf *rx_buf = stream->curr_buf->other; + struct rkisp_rx_buf *rx_buf = buf->other; if (rx_buf->is_switch && stream->id == RKISP_STREAM_RAWRD2) { switch (dev->rd_mode) { @@ -513,22 +530,9 @@ static int dmarx_frame_end(struct rkisp_stream *stream) rx_buf->runtime_us = dev->isp_sdev.dbg.interval / 1000; v4l2_subdev_call(sd, video, s_rx_buffer, rx_buf, NULL); } else { - vb2_buffer_done(&stream->curr_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); } - stream->curr_buf = NULL; } - - if (!list_empty(&stream->buf_queue)) { - stream->curr_buf = - list_first_entry(&stream->buf_queue, - struct rkisp_buffer, - queue); - list_del(&stream->curr_buf->queue); - } - - if (stream->curr_buf) - stream->ops->update_mi(stream); - spin_unlock_irqrestore(&stream->vbq_lock, lock_flags); return 0; }