chub: nanohub: don't reset on chub error status
authorBoojin Kim <boojin.kim@samsung.com>
Wed, 4 Jul 2018 02:13:55 +0000 (11:13 +0900)
committerBoojin Kim <boojin.kim@samsung.com>
Wed, 4 Jul 2018 02:24:22 +0000 (11:24 +0900)
Change-Id: I0f1da6039a0023674a7741203820ea98e866afc0
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
drivers/staging/nanohub/chub.c
drivers/staging/nanohub/chub.h
drivers/staging/nanohub/main.c

index 6bb91d53b125fd95066909b7d0304c97f5642e99..7df7302949db93095cf5cc587a31f7dbad4e0cf0 100644 (file)
@@ -777,32 +777,27 @@ int contexthub_download_image(struct contexthub_ipc_info *ipc, int bl)
 {
        const struct firmware *entry;
        int ret;
+       enum ipc_region reg;
+       char *name;
 
        if (bl) {
                ret = request_firmware(&entry, "bl.unchecked.bin", ipc->dev);
-               if (ret) {
-                       dev_err(ipc->dev, "%s, bl request_firmware failed\n",
-                               __func__);
-                       return ret;
-               }
-               memcpy(ipc_get_base(IPC_REG_BL), entry->data, entry->size);
-               dev_info(ipc->dev, "%s: bootloader(size:0x%x) on %lx\n",
-                        __func__, (int)entry->size,
-                        (unsigned long)ipc_get_base(IPC_REG_BL));
-               release_firmware(entry);
+               reg = IPC_REG_BL;
        } else {
                ret = request_firmware(&entry, ipc->os_name, ipc->dev);
-               if (ret) {
-                       dev_err(ipc->dev, "%s, %s request_firmware failed\n",
-                               __func__, ipc->os_name);
-                       return ret;
-               }
-               memcpy(ipc_get_base(IPC_REG_OS), entry->data, entry->size);
-               dev_info(ipc->dev, "%s: %s(size:0x%x) on %lx\n", __func__,
-                        ipc->os_name, (int)entry->size,
-                        (unsigned long)ipc_get_base(IPC_REG_OS));
-               release_firmware(entry);
+               reg = IPC_REG_OS;
+       }
+
+       if (ret) {
+               dev_err(ipc->dev, "%s, bl(%d) request_firmware failed\n",
+                       bl, __func__);
+               return ret;
        }
+       memcpy(ipc_get_base(reg), entry->data, entry->size);
+       dev_info(ipc->dev, "%s: bl:%d, bin(size:0x%x) on %lx\n",
+                __func__, bl, (int)entry->size,
+                (unsigned long)ipc_get_base(reg));
+       release_firmware(entry);
 
        return 0;
 }
@@ -942,6 +937,8 @@ do_reset:
                                if (ipc->irq_wdt)
                                        enable_irq(ipc->irq_wdt);
                }
+#else
+               atomic_set(&ipc->chub_status, CHUB_ST_HANG);
 #endif
        } else {
                /* dump log into file: DO NOT logbuf dueto sram corruption */
index 4494a729b1d258c46923287471000b79cfc7405b..f0660a507334fa0d243d6f427d0d05fb5fb6eedf 100644 (file)
@@ -92,6 +92,7 @@ enum chub_status {
        CHUB_ST_RUN,
        CHUB_ST_SHUTDOWN,
        CHUB_ST_NO_RESPONSE,
+       CHUB_ST_HANG,
 };
 
 struct read_wait {
index 2435a1dd42e29e31b98099d8d335e52c7e005f91..a3878dac6ec37e78f1fd86179542ad8617495969 100644 (file)
@@ -721,7 +721,11 @@ static int nanohub_hw_reset(struct nanohub_data *data)
                nanohub_wakeup_unlock(data);
        }
 #elif defined(CONFIG_NANOHUB_MAILBOX)
+#ifdef CHUB_RESET_ENABLE
        ret = contexthub_reset(data->pdata->mailbox_client);
+#else
+       ret = -EINVAL;
+#endif
 #endif
        return ret;
 }
@@ -1376,6 +1380,11 @@ static int nanohub_kthread(void *arg)
        static const struct sched_param param = {
                .sched_priority = (MAX_USER_RT_PRIO/2)-1,
        };
+#ifdef CONFIG_NANOHUB_MAILBOX
+#ifndef CHUB_RESET_ENABLE
+       struct contexthub_ipc_info *ipc;
+#endif
+#endif
 
        data->kthread_err_cnt = 0;
        sched_setscheduler(current, SCHED_FIFO, &param);
@@ -1405,6 +1414,15 @@ static int nanohub_kthread(void *arg)
                        }
                        msleep_interruptible(WAKEUP_TIMEOUT_MS);
                        nanohub_set_state(data, ST_RUNNING);
+#ifdef CONFIG_NANOHUB_MAILBOX
+#ifndef CHUB_RESET_ENABLE
+                       if (ret) {
+                               dev_warn(data->io[ID_NANOHUB_SENSOR].dev,
+                                       "%s fails. nanohub isn't running\n", __func__);
+                               return 0;
+                       }
+#endif
+#endif
                        break;
                case ST_RUNNING:
                        break;