[4/6] media: mediatek: vcodec: add one empty lat buffer as the last one to decode

Message ID 20230417054816.17097-5-yunfei.dong@mediatek.com
State New
Headers
Series media: mediatek: vcodec: Fix decoder under flow and plt test fails randomly |

Commit Message

Yunfei Dong (董云飞) April 17, 2023, 5:48 a.m. UTC
  Adding one empty lat buffer with the parameter 'is_empty_flag = true' used
to flush core work queue decode.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c | 5 +++++
 drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h | 6 ++++++
 2 files changed, 11 insertions(+)
  

Comments

AngeloGioacchino Del Regno April 17, 2023, 9:35 a.m. UTC | #1
Il 17/04/23 07:48, Yunfei Dong ha scritto:
> Adding one empty lat buffer with the parameter 'is_empty_flag = true' used
> to flush core work queue decode.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

Since commit [6/6] depends on this one, you should either squash this with [6/6]
or add the same Fixes tag to this.

I think that the most sensible option is to squash it.


Regards,
Angelo
  
Yunfei Dong (董云飞) April 17, 2023, 12:11 p.m. UTC | #2
Hi AngeloGioacchino,

Thanks for your suggestion.
On Mon, 2023-04-17 at 11:35 +0200, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Il 17/04/23 07:48, Yunfei Dong ha scritto:
> > Adding one empty lat buffer with the parameter 'is_empty_flag =
> > true' used
> > to flush core work queue decode.
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> 
> Since commit [6/6] depends on this one, you should either squash this
> with [6/6]
> or add the same Fixes tag to this.
> 
> I think that the most sensible option is to squash it.
> 
Fixed in patch v2.

Best Regards,
Yunfei Dong
> 
> Regards,
> Angelo
  

Patch

diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
index 03f8d7cd8edd..ef141f9d7bb1 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
+++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
@@ -317,6 +317,10 @@  int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
 	msg_queue->wdma_rptr_addr = msg_queue->wdma_addr.dma_addr;
 	msg_queue->wdma_wptr_addr = msg_queue->wdma_addr.dma_addr;
 
+	msg_queue->empty_lat_buf.ctx = ctx;
+	msg_queue->empty_lat_buf.core_decode = NULL;
+	msg_queue->empty_lat_buf.is_last_frame = true;
+
 	for (i = 0; i < NUM_BUFFER_COUNT; i++) {
 		lat_buf = &msg_queue->lat_buf[i];
 
@@ -342,6 +346,7 @@  int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
 
 		lat_buf->ctx = ctx;
 		lat_buf->core_decode = core_decode;
+		lat_buf->is_last_frame = false;
 		err = vdec_msg_queue_qbuf(&msg_queue->lat_ctx, lat_buf);
 		if (err) {
 			mtk_v4l2_err("failed to qbuf buf[%d]", i);
diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
index a21ee3aece5c..a80b9853cec9 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
+++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
@@ -57,6 +57,8 @@  struct vdec_msg_queue_ctx {
  * @core_decode: different codec use different decode callback function
  * @lat_list: add lat buffer to lat head list
  * @core_list: add lat buffer to core head list
+ *
+ * @is_last_frame: meaning this buffer is the last frame
  */
 struct vdec_lat_buf {
 	struct mtk_vcodec_mem wdma_err_addr;
@@ -69,6 +71,8 @@  struct vdec_lat_buf {
 	core_decode_cb_t core_decode;
 	struct list_head lat_list;
 	struct list_head core_list;
+
+	bool is_last_frame;
 };
 
 /**
@@ -83,6 +87,7 @@  struct vdec_lat_buf {
  *
  * @lat_list_cnt: used to record each instance lat list count
  * @core_list_cnt: used to record each instance core list count
+ * @empty_lat_buf: the last lat buf used to flush decode
  * @core_dec_done: core work queue decode done event
  * @status: current context decode status for core hardware
  */
@@ -99,6 +104,7 @@  struct vdec_msg_queue {
 
 	atomic_t lat_list_cnt;
 	atomic_t core_list_cnt;
+	struct vdec_lat_buf empty_lat_buf;
 	wait_queue_head_t core_dec_done;
 	int status;
 };