media: mediatek: vcodec: change lat thread decode error condition
authorYunfei Dong <yunfei.dong@mediatek.com>
Wed, 1 Feb 2023 07:33:16 +0000 (07:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:14 +0000 (23:03 +0900)
[ Upstream commit 960badda95f10fb0c60f6f64978b19eafa9507a7 ]

If lat thread can't get lat buffer, it should be that current instance
don't be schedulded, the driver can't free the src buffer directly.

Fixes: 7b182b8d9c85 ("media: mediatek: vcodec: Refactor get and put capture buffer flow")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
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/mediatek/vcodec/mtk_vcodec_dec_stateless.c
drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c

index ab8f642..3000db9 100644 (file)
@@ -258,8 +258,10 @@ static void mtk_vdec_worker(struct work_struct *work)
                if (src_buf_req)
                        v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
        } else {
-               v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
-               v4l2_m2m_buf_done(vb2_v4l2_src, state);
+               if (ret != -EAGAIN) {
+                       v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
+                       v4l2_m2m_buf_done(vb2_v4l2_src, state);
+               }
                v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
        }
 }
index 955b2d0..999ce7e 100644 (file)
@@ -597,7 +597,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
        lat_buf = vdec_msg_queue_dqbuf(&inst->ctx->msg_queue.lat_ctx);
        if (!lat_buf) {
                mtk_vcodec_err(inst, "failed to get lat buffer");
-               return -EINVAL;
+               return -EAGAIN;
        }
        share_info = lat_buf->private_data;
        src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
index cbb6728..cf16cf2 100644 (file)
@@ -2070,7 +2070,7 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
        lat_buf = vdec_msg_queue_dqbuf(&instance->ctx->msg_queue.lat_ctx);
        if (!lat_buf) {
                mtk_vcodec_err(instance, "Failed to get VP9 lat buf\n");
-               return -EBUSY;
+               return -EAGAIN;
        }
        pfc = (struct vdec_vp9_slice_pfc *)lat_buf->private_data;
        if (!pfc) {