decoder: Make correct waiting flag for workqueue [1/1]
authorapollo.ling <apollo.ling@amlogic.com>
Tue, 22 Sep 2020 06:49:29 +0000 (14:49 +0800)
committerApollo Ling <apollo.ling@amlogic.com>
Mon, 28 Sep 2020 09:33:13 +0000 (02:33 -0700)
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 <apollo.ling@amlogic.com>
drivers/frame_provider/decoder/avs2/vavs2.c
drivers/frame_provider/decoder/avs_multi/avs_multi.c
drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/h265/vh265.c
drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c
drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
drivers/frame_provider/decoder/vav1/vav1.c

index 90b91ae9e0efc921c66a9581fd484116d21c259d..4bef13af973b8f7f140ee7fcfb31177bd09c1d25 100644 (file)
@@ -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;
index 61d4bab60dbc38901b92006414708ba87c69bc8b..e0856f9cd3a756becc149ac347e8668dc5a823a8 100644 (file)
@@ -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])
index be1cac80f5dcfc227be694d0cda7f0ed70f0b008..bc8d85aadee62ec82d3f6f50b7591f7af0c2fc99 100644 (file)
@@ -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;
index c00f193191a6494a1493cd790a2f279616ad2298..cdc36545142fb7c13cf7701c392122a8ca4b73b3 100644 (file)
@@ -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;
index 83a748fecd6ec0fd6bd1cae325dc6ad654e23df7..ba4c9f5845ed0f173d902976d344d4546683d3f0 100644 (file)
@@ -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;
index a2f570335e249a240c4f4c1a54290211448dd578..59e096d96821ad86a43af46a1889a1ad0c065189 100644 (file)
@@ -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;
index 12d458dbe8e75757bb431bbd93bfce3d2d5839cb..1ef8ced58a3b940dbe25bf8df7ab6ae59e3d53e7 100644 (file)
@@ -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;
index 072c7bf507dfb147e02155244f7f22ee8e4e677c..c9e4cbae0d4a7909b1662f11e8eccabae59783f5 100644 (file)
@@ -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;