linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test
@ 2022-11-12  9:41 Yunfei Dong
  2022-11-12  9:41 ` [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer Yunfei Dong
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Yunfei Dong @ 2022-11-12  9:41 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Decoder may decode timeout or error when PLT test, fix some error
condition not reasonable.

patch 1 fix getting dst buffer NULL.
patch 2 fix inner racing mode fail condition.
patch 3 fix h264 crash.
patch 4 fix vp9 crash.
patch 5 fix core thread empty list.
---
Yunfei Dong (5):
  media: mediatek: vcodec: Fix getting NULL pointer for dst buffer
  media: mediatek: vcodec: Can't set dst buffer to done when lat decode
    error
  media: mediatek: vcodec: Fix h264 set lat buffer error
  media: mediatek: vcodec: Setting lat buf to lat_list when lat decode
    error
  media: mediatek: vcodec: Core thread depends on core_list

 .../vcodec/mtk_vcodec_dec_stateless.c         | 13 +++++++----
 .../vcodec/vdec/vdec_h264_req_multi_if.c      | 23 ++++++++++++-------
 .../vcodec/vdec/vdec_vp9_req_lat_if.c         | 15 ++++++++----
 .../platform/mediatek/vcodec/vdec_msg_queue.c |  2 +-
 4 files changed, 34 insertions(+), 19 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer
  2022-11-12  9:41 [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test Yunfei Dong
@ 2022-11-12  9:41 ` Yunfei Dong
  2022-11-14 11:15   ` AngeloGioacchino Del Regno
  2022-11-12  9:41 ` [PATCH 2/5] media: mediatek: vcodec: Can't set dst buffer to done when lat decode error Yunfei Dong
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Yunfei Dong @ 2022-11-12  9:41 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

The driver may can't get v4l2 buffer when lat or core decode timeout,
will lead to crash when call v4l2_m2m_buf_done to set dst buffer
(NULL pointer) done.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../mediatek/vcodec/mtk_vcodec_dec_stateless.c        | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
index c45bd2599bb2..e86809052a9f 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
@@ -138,10 +138,13 @@ static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_ctx *ctx, int error
 		state = VB2_BUF_STATE_DONE;
 
 	vb2_dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
-	v4l2_m2m_buf_done(vb2_dst, state);
-
-	mtk_v4l2_debug(2, "free frame buffer id:%d to done list",
-		       vb2_dst->vb2_buf.index);
+	if (vb2_dst) {
+		v4l2_m2m_buf_done(vb2_dst, state);
+		mtk_v4l2_debug(2, "free frame buffer id:%d to done list",
+			       vb2_dst->vb2_buf.index);
+	} else {
+		mtk_v4l2_err("dst buffer is NULL");
+	}
 
 	if (src_buf_req)
 		v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] media: mediatek: vcodec: Can't set dst buffer to done when lat decode error
  2022-11-12  9:41 [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test Yunfei Dong
  2022-11-12  9:41 ` [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer Yunfei Dong
@ 2022-11-12  9:41 ` Yunfei Dong
  2022-11-12  9:41 ` [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error Yunfei Dong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Yunfei Dong @ 2022-11-12  9:41 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Core thread will call v4l2_m2m_buf_done to set dst buffer done for
lat architecture. If lat call v4l2_m2m_buf_done_and_job_finish to
free dst buffer when lat decode error, core thread will access kernel
NULL pointer dereference, then crash.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
index e86809052a9f..ffbcee04dc26 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
@@ -253,7 +253,7 @@ static void mtk_vdec_worker(struct work_struct *work)
 
 	state = ret ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE;
 	if (!IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch) ||
-	    ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME || ret) {
+	    ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME) {
 		v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx, state);
 		if (src_buf_req)
 			v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error
  2022-11-12  9:41 [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test Yunfei Dong
  2022-11-12  9:41 ` [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer Yunfei Dong
  2022-11-12  9:41 ` [PATCH 2/5] media: mediatek: vcodec: Can't set dst buffer to done when lat decode error Yunfei Dong
@ 2022-11-12  9:41 ` Yunfei Dong
  2022-11-14 11:26   ` AngeloGioacchino Del Regno
  2022-11-12  9:41 ` [PATCH 4/5] media: mediatek: vcodec: Setting lat buf to lat_list when lat decode error Yunfei Dong
  2022-11-12  9:41 ` [PATCH 5/5] media: mediatek: vcodec: Core thread depends on core_list Yunfei Dong
  4 siblings, 1 reply; 10+ messages in thread
From: Yunfei Dong @ 2022-11-12  9:41 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Will set lat buffer to lat_list two times when lat decode timeout for
inner racing mode.

If core thread can't get frame buffer, need to return error value.

Fixes: 59fba9eed5a7 ("media: mediatek: vcodec: support stateless H.264 decoding for mt8192")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../vcodec/vdec/vdec_h264_req_multi_if.c      | 23 ++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
index 4cc92700692b..2b7576265f48 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
+++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
@@ -471,6 +471,12 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
 	       sizeof(share_info->h264_slice_params));
 
 	fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx);
+	if (!fb) {
+		err = -EBUSY;
+		mtk_vcodec_err(inst, "fb buffer is NULL");
+		goto vdec_dec_end;
+	}
+
 	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
 	vdec_fb_va = (unsigned long)fb;
 
@@ -630,7 +636,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 	err = vpu_dec_start(vpu, data, 2);
 	if (err) {
 		mtk_vcodec_debug(inst, "lat decode err: %d", err);
-		goto err_scp_decode;
+		goto err_free_fb_out;
 	}
 
 	share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr +
@@ -647,12 +653,17 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 	/* wait decoder done interrupt */
 	timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
 					       WAIT_INTR_TIMEOUT_MS, MTK_VDEC_LAT0);
+	if (timeout)
+		mtk_vcodec_err(inst, "lat decode timeout: pic_%d", inst->slice_dec_num);
 	inst->vsi->dec.timeout = !!timeout;
 
 	err = vpu_dec_end(vpu);
-	if (err == SLICE_HEADER_FULL || timeout || err == TRANS_BUFFER_FULL) {
-		err = -EINVAL;
-		goto err_scp_decode;
+	if (err == SLICE_HEADER_FULL || err == TRANS_BUFFER_FULL) {
+		if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability))
+			vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
+		inst->slice_dec_num++;
+		mtk_vcodec_err(inst, "lat dec fail: pic_%d err:%d", inst->slice_dec_num, err);
+		return -EINVAL;
 	}
 
 	share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr +
@@ -669,10 +680,6 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 
 	inst->slice_dec_num++;
 	return 0;
-
-err_scp_decode:
-	if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability))
-		vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
 err_free_fb_out:
 	vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
 	mtk_vcodec_err(inst, "slice dec number: %d err: %d", inst->slice_dec_num, err);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] media: mediatek: vcodec: Setting lat buf to lat_list when lat decode error
  2022-11-12  9:41 [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test Yunfei Dong
                   ` (2 preceding siblings ...)
  2022-11-12  9:41 ` [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error Yunfei Dong
@ 2022-11-12  9:41 ` Yunfei Dong
  2022-11-12  9:41 ` [PATCH 5/5] media: mediatek: vcodec: Core thread depends on core_list Yunfei Dong
  4 siblings, 0 replies; 10+ messages in thread
From: Yunfei Dong @ 2022-11-12  9:41 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Need to set lat buf to lat_list when lat decode error, or lat buffer will lost.

Fixes: 5d418351ca8f ("media: mediatek: vcodec: support stateless VP9 decoding")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c    | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
index fb1c36a3592d..cbb6728b8a40 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
+++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
@@ -2073,21 +2073,23 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 		return -EBUSY;
 	}
 	pfc = (struct vdec_vp9_slice_pfc *)lat_buf->private_data;
-	if (!pfc)
-		return -EINVAL;
+	if (!pfc) {
+		ret = -EINVAL;
+		goto err_free_fb_out;
+	}
 	vsi = &pfc->vsi;
 
 	ret = vdec_vp9_slice_setup_lat(instance, bs, lat_buf, pfc);
 	if (ret) {
 		mtk_vcodec_err(instance, "Failed to setup VP9 lat ret %d\n", ret);
-		return ret;
+		goto err_free_fb_out;
 	}
 	vdec_vp9_slice_vsi_to_remote(vsi, instance->vsi);
 
 	ret = vpu_dec_start(&instance->vpu, NULL, 0);
 	if (ret) {
 		mtk_vcodec_err(instance, "Failed to dec VP9 ret %d\n", ret);
-		return ret;
+		goto err_free_fb_out;
 	}
 
 	if (instance->irq) {
@@ -2107,7 +2109,7 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 	/* LAT trans full, no more UBE or decode timeout */
 	if (ret) {
 		mtk_vcodec_err(instance, "VP9 decode error: %d\n", ret);
-		return ret;
+		goto err_free_fb_out;
 	}
 
 	mtk_vcodec_debug(instance, "lat dma addr: 0x%lx 0x%lx\n",
@@ -2120,6 +2122,9 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 	vdec_msg_queue_qbuf(&ctx->dev->msg_queue_core_ctx, lat_buf);
 
 	return 0;
+err_free_fb_out:
+	vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf);
+	return ret;
 }
 
 static int vdec_vp9_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] media: mediatek: vcodec: Core thread depends on core_list
  2022-11-12  9:41 [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test Yunfei Dong
                   ` (3 preceding siblings ...)
  2022-11-12  9:41 ` [PATCH 4/5] media: mediatek: vcodec: Setting lat buf to lat_list when lat decode error Yunfei Dong
@ 2022-11-12  9:41 ` Yunfei Dong
  2022-11-14 11:27   ` AngeloGioacchino Del Regno
  4 siblings, 1 reply; 10+ messages in thread
From: Yunfei Dong @ 2022-11-12  9:41 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	AngeloGioacchino Del Regno, Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Core thread will continue to work when core_list is not empty, not
depends on lat_list.

Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core hardware decode")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
index ae500980ad45..dc2004790a47 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
+++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
@@ -221,7 +221,7 @@ static void vdec_msg_queue_core_work(struct work_struct *work)
 	mtk_vcodec_dec_disable_hardware(ctx, MTK_VDEC_CORE);
 	vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf);
 
-	if (!list_empty(&ctx->msg_queue.lat_ctx.ready_queue)) {
+	if (!list_empty(&dev->msg_queue_core_ctx.ready_queue)) {
 		mtk_v4l2_debug(3, "re-schedule to decode for core: %d",
 			       dev->msg_queue_core_ctx.ready_num);
 		queue_work(dev->core_workqueue, &msg_queue->core_work);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer
  2022-11-12  9:41 ` [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer Yunfei Dong
@ 2022-11-14 11:15   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-11-14 11:15 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Il 12/11/22 10:41, Yunfei Dong ha scritto:
> The driver may can't get v4l2 buffer when lat or core decode timeout,
> will lead to crash when call v4l2_m2m_buf_done to set dst buffer
> (NULL pointer) done.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

This commit needs a Fixes tag.

Regards,
Angelo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error
  2022-11-12  9:41 ` [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error Yunfei Dong
@ 2022-11-14 11:26   ` AngeloGioacchino Del Regno
  2022-11-17  9:29     ` Yunfei Dong (董云飞)
  0 siblings, 1 reply; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-11-14 11:26 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Il 12/11/22 10:41, Yunfei Dong ha scritto:
> Will set lat buffer to lat_list two times when lat decode timeout for
> inner racing mode.
> 
> If core thread can't get frame buffer, need to return error value.
> 
> Fixes: 59fba9eed5a7 ("media: mediatek: vcodec: support stateless H.264 decoding for mt8192")
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> ---
>   .../vcodec/vdec/vdec_h264_req_multi_if.c      | 23 ++++++++++++-------
>   1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> index 4cc92700692b..2b7576265f48 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> @@ -471,6 +471,12 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
>   	       sizeof(share_info->h264_slice_params));
>   
>   	fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx);
> +	if (!fb) {
> +		err = -EBUSY;
> +		mtk_vcodec_err(inst, "fb buffer is NULL");
> +		goto vdec_dec_end;
> +	}
> +
>   	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;

If you're jumping to vdec_dec_end, this check becomes pointless as y_fb_dma
will never be set to 0, so you can remove the conditional on assigning
the dma address to `y_fb_dma`.

Same comment a few lines later for `c_fb_dma`.

Regards,
Angelo


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/5] media: mediatek: vcodec: Core thread depends on core_list
  2022-11-12  9:41 ` [PATCH 5/5] media: mediatek: vcodec: Core thread depends on core_list Yunfei Dong
@ 2022-11-14 11:27   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-11-14 11:27 UTC (permalink / raw)
  To: Yunfei Dong, Chen-Yu Tsai, Nicolas Dufresne, Hans Verkuil,
	Benjamin Gaignard, Tiffany Lin
  Cc: Mauro Carvalho Chehab, Matthias Brugger, George Sun, Xiaoyong Lu,
	Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, Project_Global_Chrome_Upstream_Group

Il 12/11/22 10:41, Yunfei Dong ha scritto:
> Core thread will continue to work when core_list is not empty, not
> depends on lat_list.
> 
> Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core hardware decode")
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error
  2022-11-14 11:26   ` AngeloGioacchino Del Regno
@ 2022-11-17  9:29     ` Yunfei Dong (董云飞)
  0 siblings, 0 replies; 10+ messages in thread
From: Yunfei Dong (董云飞) @ 2022-11-17  9:29 UTC (permalink / raw)
  To: wenst, Tiffany Lin (林慧珊),
	nicolas, angelogioacchino.delregno, benjamin.gaignard,
	hverkuil-cisco
  Cc: Xiaoyong Lu (卢小勇),
	linux-kernel, George Sun (孙林),
	frkoenig, stevecho, linux-media, devicetree, linux-mediatek,
	mchehab, daniel, Project_Global_Chrome_Upstream_Group, hsinyi,
	linux-arm-kernel, matthias.bgg

Hi AngeloGioacchino,

Thanks for your detail comments.

Change the driver according to your suggestion in v2.

Best Regards,
Yunfei Dong

On Mon, 2022-11-14 at 12:26 +0100, AngeloGioacchino Del Regno wrote:
> Il 12/11/22 10:41, Yunfei Dong ha scritto:
> > Will set lat buffer to lat_list two times when lat decode timeout
> > for
> > inner racing mode.
> > 
> > If core thread can't get frame buffer, need to return error value.
> > 
> > Fixes: 59fba9eed5a7 ("media: mediatek: vcodec: support stateless
> > H.264 decoding for mt8192")
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> >   .../vcodec/vdec/vdec_h264_req_multi_if.c      | 23 ++++++++++++
> > -------
> >   1 file changed, 15 insertions(+), 8 deletions(-)
> > 
> > diff --git
> > a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
> > f.c
> > b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
> > f.c
> > index 4cc92700692b..2b7576265f48 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
> > f.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
> > f.c
> > @@ -471,6 +471,12 @@ static int vdec_h264_slice_core_decode(struct
> > vdec_lat_buf *lat_buf)
> >   	       sizeof(share_info->h264_slice_params));
> >   
> >   	fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx);
> > +	if (!fb) {
> > +		err = -EBUSY;
> > +		mtk_vcodec_err(inst, "fb buffer is NULL");
> > +		goto vdec_dec_end;
> > +	}
> > +
> >   	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
> 
> If you're jumping to vdec_dec_end, this check becomes pointless as
> y_fb_dma
> will never be set to 0, so you can remove the conditional on
> assigning
> the dma address to `y_fb_dma`.
> 
> Same comment a few lines later for `c_fb_dma`.
> 
> Regards,
> Angelo
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-17  9:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-12  9:41 [PATCH 0/5] media: mediatek: vcodec: Fix decode random crash for PLT test Yunfei Dong
2022-11-12  9:41 ` [PATCH 1/5] media: mediatek: vcodec: Fix getting NULL pointer for dst buffer Yunfei Dong
2022-11-14 11:15   ` AngeloGioacchino Del Regno
2022-11-12  9:41 ` [PATCH 2/5] media: mediatek: vcodec: Can't set dst buffer to done when lat decode error Yunfei Dong
2022-11-12  9:41 ` [PATCH 3/5] media: mediatek: vcodec: Fix h264 set lat buffer error Yunfei Dong
2022-11-14 11:26   ` AngeloGioacchino Del Regno
2022-11-17  9:29     ` Yunfei Dong (董云飞)
2022-11-12  9:41 ` [PATCH 4/5] media: mediatek: vcodec: Setting lat buf to lat_list when lat decode error Yunfei Dong
2022-11-12  9:41 ` [PATCH 5/5] media: mediatek: vcodec: Core thread depends on core_list Yunfei Dong
2022-11-14 11:27   ` AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).