vdec: add work to substitude directly calling vp9_recycle_mmu_buf [1/1]
authorapollo.ling <apollo.ling@amlogic.com>
Mon, 21 Oct 2019 05:07:18 +0000 (13:07 +0800)
committerapollo.ling <apollo.ling@amlogic.com>
Sat, 4 Jan 2020 03:10:20 +0000 (11:10 +0800)
PD#SWPL-13765

Problem:
BuildRoot S905X2 mutex_lock called in timer context

Solution:
add work to substitude directly calling vp9_recycle_mmu_buf

Verify:
u212

Change-Id: I329579c7f24beddaa18092fdde1409f3f26f0076
Signed-off-by: apollo.ling <apollo.ling@amlogic.com>
drivers/frame_provider/decoder/vp9/vvp9.c

index 6db0aa301564b91a721d5df462ffd25ad875b7b2..3eb18df282cd960bf8cacde2159b8df386578b0b 100644 (file)
@@ -994,6 +994,7 @@ struct VP9Decoder_s {
        struct vframe_chunk_s *chunk;
        int dec_result;
        struct work_struct work;
+       struct work_struct recycle_mmu_work;
        struct work_struct set_clk_work;
        u32 start_shift_bytes;
 
@@ -7450,6 +7451,14 @@ static void vp9_recycle_mmu_buf(struct VP9Decoder_s *pbi)
                pbi->used_4k_num = -1;
        }
 }
+
+void vp9_recycle_mmu_work(struct work_struct *work)
+{
+       struct VP9Decoder_s *pbi = container_of(work,
+               struct VP9Decoder_s, recycle_mmu_work);
+
+       vp9_recycle_mmu_buf(pbi);
+}
 #endif
 
 
@@ -7461,8 +7470,13 @@ static void dec_again_process(struct VP9Decoder_s *pbi)
                PROC_STATE_DECODESLICE) {
                pbi->process_state =
                PROC_STATE_SENDAGAIN;
-               if (pbi->mmu_enable)
-                       vp9_recycle_mmu_buf(pbi);
+               if (pbi->mmu_enable) {
+                       /*
+                        * Because vp9_recycle_mmu_buf has sleep function,we can't
+                        * call it directly. Use a recycle_mmu_work to substitude it.
+                        */
+                       vdec_schedule_work(&pbi->recycle_mmu_work);
+               }
        }
        reset_process_time(pbi);
        vdec_schedule_work(&pbi->work);
@@ -9017,6 +9031,7 @@ static s32 vvp9_init(struct VP9Decoder_s *pbi)
                pbi->stat |= STAT_ISR_REG;*/
 
                INIT_WORK(&pbi->work, vp9_work);
+               INIT_WORK(&pbi->recycle_mmu_work, vp9_recycle_mmu_work);
 #ifdef SUPPORT_FB_DECODING
                if (pbi->used_stage_buf_num > 0)
                        INIT_WORK(&pbi->s1_work, vp9_s1_work);
@@ -9134,6 +9149,7 @@ static int vmvp9_stop(struct VP9Decoder_s *pbi)
        vp9_local_uninit(pbi);
        reset_process_time(pbi);
        cancel_work_sync(&pbi->work);
+       cancel_work_sync(&pbi->recycle_mmu_work);
 #ifdef SUPPORT_FB_DECODING
        if (pbi->used_stage_buf_num > 0)
                cancel_work_sync(&pbi->s1_work);
@@ -9189,6 +9205,7 @@ static int vvp9_stop(struct VP9Decoder_s *pbi)
                        cancel_work_sync(&pbi->s1_work);
 #endif
                cancel_work_sync(&pbi->work);
+               cancel_work_sync(&pbi->recycle_mmu_work);
        } else
                amhevc_disable();
 #else