[ERD][RAMEN9610-20296][COMMON] driver: chub: handle invalid logbuf index
authorSukwon Ryoo <sw.ryoo@samsung.com>
Thu, 26 Sep 2019 07:20:56 +0000 (16:20 +0900)
committerrobot <robot@samsung.com>
Mon, 7 Oct 2019 05:06:34 +0000 (14:06 +0900)
When an invalid logbuffer index issue happened,
1. reset eq and dq to 0
2. chub dump
also resolves prevent CID 275510, 275336 and 276075

Change-Id: I6b2f9205b4b8ed31f135e1f04a6963b9aa8bb4f0
Signed-off-by: Sukwon Ryoo <sw.ryoo@samsung.com>
drivers/staging/nanohub/chub.c
drivers/staging/nanohub/chub_ipc.c
drivers/staging/nanohub/chub_ipc.h

index cc5e6876d1e853be74d3daa4455e638080ad9645..75f51f4498eb07891c515f9f5328fc443455175e 100644 (file)
@@ -465,7 +465,8 @@ void contexthub_print_rtlog(struct contexthub_ipc_info *ipc, bool loop)
                        dev_warn(ipc->dev, "%s: get token\n", __func__);
                        return;
                }
-               ipc_logbuf_outprint(&ipc->chub_rt_log, loop);
+               if (ipc_logbuf_outprint(&ipc->chub_rt_log, loop))
+                       chub_dbg_dump_hw(ipc, CHUB_ERR_NANOHUB);
                contexthub_put_token(ipc);
        }
 }
@@ -488,7 +489,8 @@ retry:
        }
        ipc_logbuf_flush_on(1);
        mutex_lock(&log_mutex);
-       ipc_logbuf_outprint(&ipc->chub_rt_log, 100);
+       if (ipc_logbuf_outprint(&ipc->chub_rt_log, 100))
+               chub_dbg_dump_hw(ipc, CHUB_ERR_NANOHUB);
        mutex_unlock(&log_mutex);
        ipc_logbuf_flush_on(0);
        contexthub_put_token(ipc);
@@ -506,7 +508,7 @@ int contexthub_ipc_read(struct contexthub_ipc_info *ipc, uint8_t *rx, int max_le
 {
        unsigned long flag;
        int size = 0;
-       int ret;
+       int ret = 0;
        void *rxbuf;
        u64 time = 0; /* for debug */
 
@@ -1307,8 +1309,8 @@ static irqreturn_t contexthub_irq_handler(int irq, void *data)
                } else {
                        err = CHUB_ERR_EVTQ_EMTPY;
                        CSP_PRINTF_ERROR
-                                        ("%s: evt-empty irq:%d(%d+%d), evt:%d, status:0x%x->0x%x(SR:0x%x)\n", __func__,
-                                         irq_num, cur_evt->irq, start_index, evt, status_org, status, ipc_hw_read_int_status_reg(AP));
+                                        ("%s: evt-empty irq:%d(%d), evt:%d, status:0x%x->0x%x(SR:0x%x)\n", __func__,
+                                         irq_num, start_index, evt, status_org, status, ipc_hw_read_int_status_reg(AP));
                        break;
                }
                ipc_hw_clear_int_pend_reg(AP, irq_num);
index 63ebc434dc2b4e066f16595b186c5042c50636c0..76c2826b06bdeaf729a8d0757db06ceffa8dd65c 100644 (file)
@@ -563,7 +563,7 @@ out:
 #endif
        if (!get_evt) {
                CSP_PRINTF_ERROR("%s:%s: fails pending wait (%d): irq:%d, evt:%d\n",
-                       NAME_PREFIX, __func__, trycnt, cur_evt->irq, cur_evt->evt);
+                       NAME_PREFIX, __func__, trycnt, cur_evt ? cur_evt->irq : -1, cur_evt ? cur_evt->evt : -1);
                ipc_dump();
        }
        ENABLE_IRQ(LOCK_ADD_EVT, &flag);
@@ -956,7 +956,7 @@ bool ipc_logbuf_filled(void)
        return 0;
 }
 
-void ipc_logbuf_outprint(struct runtimelog_buf *rt_buf, u32 loop)
+int ipc_logbuf_outprint(struct runtimelog_buf *rt_buf, u32 loop)
 {
        if (ipc_map) {
                struct logbuf_content *log;
@@ -969,7 +969,8 @@ retry:
                eq = logbuf->eq;
                if (eq >= LOGBUF_NUM || logbuf->dq >= LOGBUF_NUM) {
                        pr_err("%s: index err:%d, eq:%d, dq:%d\n", __func__, eq, logbuf->dq);
-                       return;
+                       logbuf->eq = logbuf->dq = 0;
+                       return -1;
                }
 
                if (logbuf->full) {
@@ -1009,6 +1010,7 @@ retry:
                if (logbuf->flush_req)
                        logbuf->flush_req = 0;
        }
+       return 0;
 }
 
 enum ipc_fw_loglevel ipc_logbuf_loglevel(enum ipc_fw_loglevel loglevel, int set)
index 687cdf68bc71b3e1b3153761419fcdded8caa12f..e8ffe672105fee40c7b62506e3519066ba222d62 100644 (file)
@@ -544,7 +544,7 @@ enum ipc_fw_loglevel ipc_logbuf_loglevel(enum ipc_fw_loglevel loglevel, int set)
 void *ipc_logbuf_inbase(bool force);
 void ipc_logbuf_flush_on(bool on);
 bool ipc_logbuf_filled(void);
-void ipc_logbuf_outprint(struct runtimelog_buf *rt_buf, u32 loop);
+int ipc_logbuf_outprint(struct runtimelog_buf *rt_buf, u32 loop);
 void ipc_logbuf_req_flush(struct logbuf_content *log);
 void ipc_logbuf_set_req_num(struct logbuf_content *log);
 struct logbuf_content *ipc_logbuf_get_curlogbuf(struct logbuf_content *log);