From 0a8655e71478bf500ca34866d87cda4ec24f52e2 Mon Sep 17 00:00:00 2001 From: Boyoung Date: Tue, 11 Dec 2018 08:07:20 +0900 Subject: [PATCH] [ERD][APR-103] [COMMON]chub: add slient reset for chub error Change-Id: I18bdbc2ee03bde8cd7992e50c367db4652971fa1 Signed-off-by: Boyoung --- drivers/staging/nanohub/chub.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/staging/nanohub/chub.c b/drivers/staging/nanohub/chub.c index 7ceac250e682..fa9da88f1f53 100644 --- a/drivers/staging/nanohub/chub.c +++ b/drivers/staging/nanohub/chub.c @@ -342,6 +342,24 @@ static void contexthub_handle_debug(struct contexthub_ipc_info *ipc, dev_info(ipc->dev, "%s: err:%d(cnt:%d), enable_wq:%d\n", __func__, err, ipc->err_cnt[err], enable_wq); + /* set status in CHUB_ST_ERR */ + if ((err == CHUB_ERR_ITMON) || (err == CHUB_ERR_FW_WDT) || (err == CHUB_ERR_FW_FAULT) || (err == CHUB_ERR_CHUB_NO_RESPONSE)) { + atomic_set(&ipc->chub_status, CHUB_ST_ERR); + goto error_handler; + } + + if (err < CHUB_ERR_NEED_RESET) { + if (ipc->err_cnt[err] > CHUB_RESET_THOLD) { + atomic_set(&ipc->chub_status, CHUB_ST_ERR); + ipc->err_cnt[err] = 0; + dev_info(ipc->dev, "%s: err:%d(cnt:%d), enter error status\n", + __func__, err, ipc->err_cnt[err]); + } else { + ipc->err_cnt[err]++; + return; + } + } + /* get chub-fw err */ if (err == CHUB_ERR_NANOHUB) { enum ipc_debug_event fw_evt; @@ -362,10 +380,7 @@ static void contexthub_handle_debug(struct contexthub_ipc_info *ipc, contexthub_put_token(ipc); } - /* set status in CHUB_ST_ERR */ - if ((err == CHUB_ERR_ITMON) || (err == CHUB_ERR_FW_WDT) || (err == CHUB_ERR_FW_FAULT)) - atomic_set(&ipc->chub_status, CHUB_ST_ERR); - +error_handler: /* handle err */ if (enable_wq) { ipc->cur_err |= (1 << err); @@ -778,11 +793,16 @@ int contexthub_ipc_write_event(struct contexthub_ipc_info *ipc, } if (need_ipc) { - if (contexthub_get_token(ipc) || (atomic_read(&ipc->chub_status) != CHUB_ST_RUN)) { + if (atomic_read(&ipc->chub_status) != CHUB_ST_RUN) { dev_warn(ipc->dev, "%s event:%d/%d fails chub isn't active, status:%d, inreset:%d\n", __func__, event, MAILBOX_EVT_MAX, atomic_read(&ipc->chub_status), atomic_read(&ipc->in_reset)); return -EINVAL; } + if (contexthub_get_token(ipc)) { + dev_warn(ipc->dev, "%s event:%d/%d fails to get token, status:%d, inreset:%d\n", + __func__, event, MAILBOX_EVT_MAX, atomic_read(&ipc->chub_status), atomic_read(&ipc->in_reset)); + return -EINVAL; + } /* handle ipc */ switch (event) { -- 2.20.1