diff mbox series

[5/5] media: mediatek: vcodec: remove unused lat_buf

Message ID 20221210073218.17350-6-yunfei.dong@mediatek.com
State New
Headers show
Series media: mediatek: vcodec: Fix power_VideoCall test fail | expand

Commit Message

Yunfei Dong (董云飞) Dec. 10, 2022, 7:32 a.m. UTC
Remove unused lat_buf from core list, or leading to core list access
NULL point.

Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core hardware decode")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../platform/mediatek/vcodec/vdec_msg_queue.c | 20 ++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
index 9bbbd3fa20eb..3f18eca7dbdd 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
+++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
@@ -185,7 +185,7 @@  bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue)
 	struct vdec_lat_buf *buf, *tmp;
 	struct vdec_msg_queue_ctx *core_ctx;
 	long timeout_jiff;
-	int ret;
+	int ret, count = 0;
 
 	core_ctx = &msg_queue->ctx->dev->msg_queue_core_ctx;
 	spin_lock(&core_ctx->ready_lock);
@@ -209,8 +209,22 @@  bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue)
 			       msg_queue->lat_ctx.ready_num);
 		return true;
 	}
-	mtk_v4l2_err("failed with lat buf isn't full: %d",
-		     msg_queue->lat_ctx.ready_num);
+
+	spin_lock(&core_ctx->ready_lock);
+	list_for_each_entry_safe(buf, tmp, &core_ctx->ready_queue, core_list) {
+		if (buf && buf->ctx == msg_queue->ctx) {
+			count++;
+			spin_lock(&msg_queue->lat_ctx.ready_lock);
+			list_del(&buf->core_list);
+			spin_unlock(&msg_queue->lat_ctx.ready_lock);
+		}
+	}
+	spin_unlock(&core_ctx->ready_lock);
+
+	mtk_v4l2_err("failed with lat buf isn't full: list(%d %d) count:%d",
+		     atomic_read(&msg_queue->lat_list_cnt),
+		     atomic_read(&msg_queue->core_list_cnt), count);
+
 	return false;
 }