ppmgr: Add the value of stats_get to protect tb_task. [4/6]
authorrenjiang.han <renjiang.han@amlogic.com>
Tue, 4 Jun 2019 08:55:00 +0000 (16:55 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 24 Jun 2019 09:55:00 +0000 (02:55 -0700)
PD#SWPL-9350

Problem:
Low probability of system crash when play live channel

Solution:
Increase the value of stats_get to protect tb_task.

Verify:
on U212

Change-Id: I4a13a3f7f2a4259fc8d4dd6630dd28d82a8c2541
Signed-off-by: renjiang.han <renjiang.han@amlogic.com>
drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c

index f54e241..3502300 100644 (file)
@@ -3810,17 +3810,26 @@ static void tb_detect_init(void)
 static int tb_task(void *data)
 {
        int tbff_flag;
-       struct tbff_stats pReg;
+       struct tbff_stats *pReg = NULL;
        ulong y5fld[5];
        int is_top;
        int inited = 0;
+       int i;
+       int inter_flag;
        static const char * const detect_type[] = {"NC", "TFF", "BFF", "TBF"};
        struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1};
-
        sched_setscheduler(current, SCHED_FIFO, &param);
 
+       inter_flag = 0;
+       pReg = kmalloc(sizeof(struct tbff_stats), GFP_KERNEL);
+       if (IS_ERR_OR_NULL(pReg)) {
+               PPMGRVPP_INFO("pReg malloc fail\n");
+               return 0;
+       }
+       memset(pReg, 0, sizeof(struct tbff_stats));
+
        if (gfunc)
-               gfunc->stats_init((&pReg), TB_DETECT_H, TB_DETECT_W);
+               gfunc->stats_init(pReg, TB_DETECT_H, TB_DETECT_W);
        allow_signal(SIGTERM);
        while (down_interruptible(&tb_sem) == 0) {
                if (kthread_should_stop() || tb_quit_flag)
@@ -3840,14 +3849,30 @@ static int tb_task(void *data)
                y5fld[2] = detect_buf[tb_buff_rptr + 2].vaddr;
                y5fld[3] = detect_buf[tb_buff_rptr + 1].vaddr;
                y5fld[4] = detect_buf[tb_buff_rptr].vaddr;
-               if (gfunc)
-                       gfunc->stats_get(y5fld, &pReg);
-
+               if (gfunc) {
+                       if (IS_ERR_OR_NULL(pReg)) {
+                               PPMGRVPP_INFO("pReg is NULL!\n");
+                               return 0;
+                       }
+                       for (i = 0; i < 5; i++) {
+                               if (IS_ERR_OR_NULL((void *)(y5fld[i]))) {
+                                       PPMGRVPP_INFO(
+                                               "y5fld[%d] is NULL!\n", i);
+                                       inter_flag = 1;
+                                       break;
+                               }
+                       }
+                       if (inter_flag) {
+                               inter_flag = 0;
+                               continue;
+                       }
+                       gfunc->stats_get(y5fld, pReg);
+               }
                is_top = is_top ^ 1;
                tbff_flag = -1;
                if (gfunc)
                        tbff_flag = gfunc->fwalg_get(
-                               &pReg, is_top,
+                               pReg, is_top,
                                (tb_first_frame_type == 3) ? 0 : 1,
                                tb_buff_rptr,
                                atomic_read(&tb_skip_flag),
@@ -3894,6 +3919,7 @@ static int tb_task(void *data)
                }
        }
        atomic_set(&tb_run_flag, 0);
+       kfree(pReg);
        while (!kthread_should_stop())
                usleep_range(9000, 10000);
        return 0;