From 90197eabab127513e0db9a2b4440f0fdf08f57f3 Mon Sep 17 00:00:00 2001 From: "apollo.ling" Date: Tue, 22 Sep 2020 14:49:29 +0800 Subject: [PATCH] decoder: Make correct waiting flag for workqueue [1/1] PD#SWPL-33743 Problem: CtsMediaTestCases 4 item fail, which reason is delay. The delay is introduced by SWPL26671 Solution: Make correct waiting flag of workqueue Verify: u212 Change-Id: Iac1b8887d748b86d535cbb3fb3ca1392025544e7 Signed-off-by: apollo.ling --- drivers/frame_provider/decoder/avs2/vavs2.c | 6 ----- .../decoder/avs_multi/avs_multi.c | 7 ------ .../decoder/h264_multi/vmh264.c | 15 +++++++----- drivers/frame_provider/decoder/h265/vh265.c | 13 +++++++---- .../decoder/mjpeg/vmjpeg_multi.c | 6 ----- .../decoder/mpeg12/vmpeg12_multi.c | 23 ++++++++++--------- .../decoder/mpeg4/vmpeg4_multi.c | 6 ----- drivers/frame_provider/decoder/vav1/vav1.c | 6 ----- 8 files changed, 30 insertions(+), 52 deletions(-) diff --git a/drivers/frame_provider/decoder/avs2/vavs2.c b/drivers/frame_provider/decoder/avs2/vavs2.c index 90b91ae..4bef13a 100644 --- a/drivers/frame_provider/decoder/avs2/vavs2.c +++ b/drivers/frame_provider/decoder/avs2/vavs2.c @@ -6946,12 +6946,6 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) if (dec->eos) return ret; - if (work_pending(&dec->work) || - work_busy(&dec->work)) { - avs2_print(dec, PRINT_FLAG_VDEC_DETAIL, - "avs2 work pending,not ready for run.\n"); - return 0; - } if (!dec->first_sc_checked) { int size = decoder_mmu_box_sc_check(dec->mmu_box, tvp); dec->first_sc_checked = 1; diff --git a/drivers/frame_provider/decoder/avs_multi/avs_multi.c b/drivers/frame_provider/decoder/avs_multi/avs_multi.c index 61d4bab..e0856f9 100644 --- a/drivers/frame_provider/decoder/avs_multi/avs_multi.c +++ b/drivers/frame_provider/decoder/avs_multi/avs_multi.c @@ -2493,13 +2493,6 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) int ret = 1; unsigned buf_busy_mask = (1 << hw->vf_buf_num_used) - 1; - if (work_pending(&hw->work) || - work_busy(&hw->work)) { - debug_print(hw, PRINT_FLAG_RUN_FLOW, - "avs work pending,not ready for run.\n"); - return 0; - } - #ifdef DEBUG_MULTI_FRAME_INS if ((DECODE_ID(hw) == 0) && run_count[0] > run_count[1] && run_count[1] < max_run_count[1]) diff --git a/drivers/frame_provider/decoder/h264_multi/vmh264.c b/drivers/frame_provider/decoder/h264_multi/vmh264.c index be1cac8..bc8d85a 100644 --- a/drivers/frame_provider/decoder/h264_multi/vmh264.c +++ b/drivers/frame_provider/decoder/h264_multi/vmh264.c @@ -800,6 +800,7 @@ struct vdec_h264_hw_s { struct dec_sysinfo vh264_amstream_dec_info; int dec_result; + u32 timeout_processing; struct work_struct work; struct work_struct notify_work; struct work_struct timeout_work; @@ -7006,8 +7007,8 @@ static void timeout_process(struct vdec_h264_hw_s *hw) */ if (work_pending(&hw->work) || work_busy(&hw->work) || - work_pending(&hw->timeout_work) || - work_busy(&hw->timeout_work)) { + work_busy(&hw->timeout_work) || + work_pending(&hw->timeout_work)) { pr_err("%s h264[%d] work pending, do nothing.\n",__func__, vdec->id); return; } @@ -9114,7 +9115,9 @@ static void vh264_timeout_work(struct work_struct *work) if (work_pending(&hw->work)) return; + hw->timeout_processing = 1; vh264_work_implement(hw, vdec, 1); + } static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) @@ -9125,14 +9128,14 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) int tvp = vdec_secure(hw_to_vdec(hw)) ? CODEC_MM_FLAGS_TVP : 0; - if (work_pending(&hw->work) || - work_busy(&hw->work) || - work_pending(&hw->timeout_work) || - work_busy(&hw->timeout_work)) { + if (hw->timeout_processing && + (work_pending(&hw->work) || work_busy(&hw->work) || + work_pending(&hw->timeout_work) || work_busy(&hw->timeout_work))) { dpb_print(DECODE_ID(hw), PRINT_FLAG_VDEC_DETAIL, "h264 work pending, not ready for run.\n"); return 0; } + hw->timeout_processing = 0; if (!hw->first_sc_checked && hw->mmu_enable) { int size = decoder_mmu_box_sc_check(hw->mmu_box, tvp); hw->first_sc_checked =1; diff --git a/drivers/frame_provider/decoder/h265/vh265.c b/drivers/frame_provider/decoder/h265/vh265.c index c00f193..cdc3654 100644 --- a/drivers/frame_provider/decoder/h265/vh265.c +++ b/drivers/frame_provider/decoder/h265/vh265.c @@ -1507,6 +1507,7 @@ struct hevc_state_s { void *vdec_cb_arg; struct vframe_chunk_s *chunk; int dec_result; + u32 timeout_processing; struct work_struct work; struct work_struct timeout_work; struct work_struct notify_work; @@ -12082,7 +12083,7 @@ static void timeout_process(struct hevc_state_s *hevc) */ if (work_pending(&hevc->work) || work_busy(&hevc->work) || - work_pending(&hevc->timeout_work) || + work_busy(&hevc->timeout_work) || work_pending(&hevc->timeout_work)) { pr_err("%s h265[%d] work pending, do nothing.\n",__func__, hevc->index); return; @@ -12436,6 +12437,7 @@ static void vh265_work_implement(struct hevc_state_s *hevc, if (run_ready(vdec, VDEC_HEVC)) { int r; int decode_size; + r = vdec_prepare_input(vdec, &hevc->chunk); if (r < 0) { hevc->dec_result = DEC_RESULT_GET_DATA_RETRY; @@ -12843,6 +12845,7 @@ static void vh265_timeout_work(struct work_struct *work) if (work_pending(&hevc->work)) return; + hevc->timeout_processing = 1; vh265_work_implement(hevc, vdec, 1); } @@ -12870,14 +12873,16 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) if (hevc->eos) return 0; - if (work_pending(&hevc->work) || + if (hevc->timeout_processing && + (work_pending(&hevc->work) || work_busy(&hevc->work) || - work_pending(&hevc->timeout_work) || - work_pending(&hevc->timeout_work)) { + work_busy(&hevc->timeout_work) || + work_pending(&hevc->timeout_work))) { hevc_print(hevc, PRINT_FLAG_VDEC_STATUS, "h265 work pending,not ready for run.\n"); return 0; } + hevc->timeout_processing = 0; if (!hevc->first_sc_checked && hevc->mmu_enable) { int size = decoder_mmu_box_sc_check(hevc->mmu_box, tvp); hevc->first_sc_checked =1; diff --git a/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c b/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c index 83a748f..ba4c9f5 100644 --- a/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c +++ b/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c @@ -1255,12 +1255,6 @@ static unsigned long run_ready(struct vdec_s *vdec, hw->not_run_ready++; if (hw->eos) return 0; - if (work_pending(&hw->work) || - work_busy(&hw->work)) { - mmjpeg_debug_print(DECODE_ID(hw), PRINT_FLAG_RUN_FLOW, - "mjpeg work pending,not ready for run.\n"); - return 0; - } if (vdec_stream_based(vdec) && (hw->init_flag == 0) && pre_decode_buf_level != 0) { u32 rp, wp, level; diff --git a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c index a2f5703..59e096d 100644 --- a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c +++ b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c @@ -266,6 +266,7 @@ struct vdec_mpeg12_hw_s { s32 refs[2]; int dec_result; + u32 timeout_processing; struct work_struct work; struct work_struct timeout_work; struct work_struct notify_work; @@ -2297,6 +2298,11 @@ static void vmpeg12_work_implement(struct vdec_mpeg12_hw_s *hw, amvdec_stop(); hw->stat &= ~STAT_VDEC_RUN; } + /*disable mbox interrupt */ + WRITE_VREG(ASSIST_MBOX1_MASK, 0); + del_timer_sync(&hw->check_timer); + hw->stat &= ~STAT_TIMER_ARM; + wait_vmmpeg12_search_done(hw); if (from == 1) { /*This is a timeout work*/ @@ -2310,15 +2316,10 @@ static void vmpeg12_work_implement(struct vdec_mpeg12_hw_s *hw, } } - /*disable mbox interrupt */ - WRITE_VREG(ASSIST_MBOX1_MASK, 0); - wait_vmmpeg12_search_done(hw); if (vdec->parallel_dec == 1) vdec_core_finish_run(vdec, CORE_MASK_VDEC_1); else vdec_core_finish_run(vdec, CORE_MASK_VDEC_1 | CORE_MASK_HEVC); - del_timer_sync(&hw->check_timer); - hw->stat &= ~STAT_TIMER_ARM; if (hw->is_used_v4l) { struct aml_vcodec_ctx *ctx = @@ -2352,6 +2353,7 @@ static void vmpeg12_timeout_work(struct work_struct *work) return; } + hw->timeout_processing = 1; vmpeg12_work_implement(hw, vdec, 1); } @@ -2732,8 +2734,8 @@ static void timeout_process(struct vdec_mpeg12_hw_s *hw) if (work_pending(&hw->work) || work_busy(&hw->work) || - work_pending(&hw->timeout_work) || - work_busy(&hw->timeout_work)) { + work_busy(&hw->timeout_work) || + work_pending(&hw->timeout_work)) { pr_err("%s mpeg12[%d] timeout_process return befor do anything.\n",__func__, vdec->id); return; } @@ -3049,10 +3051,9 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) (struct vdec_mpeg12_hw_s *)vdec->private; if (hw->eos) return 0; - if (work_pending(&hw->work) || - work_busy(&hw->work) || - work_pending(&hw->timeout_work) || - work_busy(&hw->timeout_work)) { + if (hw->timeout_processing && + (work_pending(&hw->work) || work_busy(&hw->work) || + work_pending(&hw->timeout_work) || work_busy(&hw->timeout_work))) { debug_print(DECODE_ID(hw), PRINT_FLAG_VDEC_STATUS, "mpeg12 work pending,not ready for run.\n"); return 0; diff --git a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c index 12d458d..1ef8ced 100644 --- a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c +++ b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c @@ -2259,12 +2259,6 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) if (hw->eos) return 0; - if (work_pending(&hw->work) || - work_busy(&hw->work)) { - mmpeg4_debug_print(DECODE_ID(hw), PRINT_FLAG_VDEC_STATUS, - "mpeg4 work pending,not ready for run.\n"); - return 0; - } if (vdec_stream_based(vdec) && (hw->init_flag == 0) && pre_decode_buf_level != 0) { u32 rp, wp, level; diff --git a/drivers/frame_provider/decoder/vav1/vav1.c b/drivers/frame_provider/decoder/vav1/vav1.c index 072c7bf..c9e4cba 100644 --- a/drivers/frame_provider/decoder/vav1/vav1.c +++ b/drivers/frame_provider/decoder/vav1/vav1.c @@ -9543,12 +9543,6 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) CODEC_MM_FLAGS_TVP : 0; unsigned long ret = 0; - if (work_pending(&hw->work) || - work_busy(&hw->work)) { - av1_print(hw, PRINT_FLAG_VDEC_DETAIL, - "av1 work pending,not ready for run.\n"); - return 0; - } if (!hw->pic_list_init_done2 || hw->eos) return ret; -- 2.20.1