From de8b64ce6f03b49bfa591e7bc4569141502d9319 Mon Sep 17 00:00:00 2001 From: ming_qian Date: Mon, 14 Oct 2019 16:26:25 +0800 Subject: [PATCH] MLK-22753: VPU Decoder: fix stop timeout caused by waiting res change If firmware report sequence header twice, and the user don't support the format, such as 10-bit NV12, user may close vpu decoder directly, it will send stop cmd. but when driver receive the second sequence header event, it may waiting for resolution change done, it'll block the stop command, and cause it timeout. Signed-off-by: ming_qian Reviewed-by: Shijie Qin (cherry picked from commit 9e1d28861a6f89b9f25641131f8db1ef17b81d3a) --- drivers/mxc/vpu_malone/vpu_b0.c | 21 +++++++++++++-------- drivers/mxc/vpu_malone/vpu_b0.h | 1 - 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/mxc/vpu_malone/vpu_b0.c b/drivers/mxc/vpu_malone/vpu_b0.c index 9e17a8f6a646..8b7199913b49 100644 --- a/drivers/mxc/vpu_malone/vpu_b0.c +++ b/drivers/mxc/vpu_malone/vpu_b0.c @@ -2903,8 +2903,8 @@ static u32 transfer_buffer_to_firmware(struct vpu_ctx *ctx, void *input_buffer = (void *)vb2_plane_vaddr(vb, 0); uint32_t buffer_size = vb->planes[0].bytesused; - vpu_dbg(LVL_BIT_FUNC, "enter %s, start_flag %d, index=%d, firmware_started=%d\n", - __func__, ctx->start_flag, ctx->str_index, ctx->dev->firmware_started); + vpu_dbg(LVL_BIT_FUNC, "enter %s, index=%d, firmware_started=%d\n", + __func__, ctx->str_index, ctx->dev->firmware_started); vpu_dbg(LVL_WARN, "firmware version is %d.%d.%d\n", (pSharedInterface->FWVersion & 0x00ff0000) >> 16, @@ -2993,7 +2993,7 @@ static void v4l2_transfer_buffer_to_firmware(struct queue_data *This, struct vb2 u32 frame_bytes; int ret; - if (ctx->start_flag == true) { + if (ctx->firmware_stopped == true) { vpu_calculate_performance(ctx, 0xff, "alloc stream buffer begin"); ret = alloc_vpu_buffer(ctx); if (ret) { @@ -3021,7 +3021,7 @@ static void v4l2_transfer_buffer_to_firmware(struct queue_data *This, struct vb2 if (p_data_req->vb2_buf) vb2_buffer_done(p_data_req->vb2_buf, VB2_BUF_STATE_DONE); - ctx->start_flag = false; + ctx->firmware_stopped = false; } } @@ -4168,7 +4168,6 @@ static void vpu_api_event_handler(struct vpu_ctx *ctx, u_int32 uStrIdx, u_int32 ctx->q_data[V4L2_SRC].qbuf_count, ctx->q_data[V4L2_SRC].dqbuf_count); ctx->firmware_stopped = true; - ctx->start_flag = true; ctx->b_firstseq = true; ctx->frame_decoded = false; ctx->wait_rst_done = false; @@ -4283,8 +4282,13 @@ static void vpu_api_event_handler(struct vpu_ctx *ctx, u_int32 uStrIdx, u_int32 if (!check_seq_info_is_valid(ctx->str_index, &info)) break; - while (ctx->wait_res_change_done && wait_times++ < 100) + while (ctx->wait_res_change_done && wait_times++ < 100) { + if (!vpu_dec_is_active(ctx)) + break; mdelay(10); + } + if (!vpu_dec_is_active(ctx)) + break; if (ctx->wait_res_change_done) vpu_dbg(LVL_WARN, "warning: ctx[%d] update seq info when waiting res change\n", ctx->str_index); @@ -5872,7 +5876,9 @@ static bool vpu_dec_is_active(struct vpu_ctx *ctx) { if (!ctx) return false; - if (ctx->start_flag) + if (ctx->firmware_stopped) + return false; + if (ctx->pending && ctx->pending->request == VID_API_CMD_STOP) return false; return true; @@ -5935,7 +5941,6 @@ static int v4l2_open(struct file *filp) ctx->str_index = idx; dev->ctx[idx] = ctx; ctx->b_firstseq = true; - ctx->start_flag = true; ctx->wait_rst_done = false; ctx->wait_res_change_done = false; ctx->firmware_stopped = true; diff --git a/drivers/mxc/vpu_malone/vpu_b0.h b/drivers/mxc/vpu_malone/vpu_b0.h index 11801d0a97a1..8ea3007544f2 100644 --- a/drivers/mxc/vpu_malone/vpu_b0.h +++ b/drivers/mxc/vpu_malone/vpu_b0.h @@ -372,7 +372,6 @@ struct vpu_ctx { MediaIPFW_Video_SeqInfo seqinfo; bool b_dis_reorder; bool b_firstseq; - bool start_flag; bool wait_rst_done; bool wait_res_change_done; bool seek_flag; -- 2.17.1