diff options
author | Dino Li <Dino.Li@ite.com.tw> | 2020-11-17 16:34:32 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-18 02:48:10 +0000 |
commit | eb665ee6e1768177dacfa0cadfee783ad8a5d09a (patch) | |
tree | f4e02074bd22697246032f9023c4c4e71e0e7e74 | |
parent | 9dc95ac4be74d4ad900955f4857a42ce7bf74613 (diff) | |
download | chrome-ec-eb665ee6e1768177dacfa0cadfee783ad8a5d09a.tar.gz |
nds32/task: return invalid task id if task scheduling is not yet start
The send_to_cr50() uses task_disable_task() to disable console task,
and task_disable_task() will also suspend a task if it is the current
task (tskid == task_get_current()).
But send_to_cr50() is called in main routine (task scheduling is not
yet start). If a specified FW image hits condition of
"tskid == task_get_current()", EC will start scheduling with unexpected
status.
(eg. at CL:2540390: current_task=0x80880, tasks=0x877a8, and
uint8_t current_task - tasks = 9 )
BUG=b:172460745
BRANCH=none
TEST=No WDT loops on drawcia
Change-Id: If42ef14a198ab5f99686f8e7212151b2d6b573f5
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2544291
Tested-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | core/nds32/switch.S | 5 | ||||
-rw-r--r-- | core/nds32/task.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/core/nds32/switch.S b/core/nds32/switch.S index 8696ef5f00..b891aeb2a5 100644 --- a/core/nds32/switch.S +++ b/core/nds32/switch.S @@ -81,6 +81,11 @@ __switch_task: */ .global __task_start __task_start: + /* + * Disable global interrupt here to ensure below sequence won't be + * broken. The "iret" instruction of ISR will enable GIE again. + */ + setgie.d /* area used as thread stack for the first switch */ la $r3, scratchpad diff --git a/core/nds32/task.c b/core/nds32/task.c index 6c0766635f..f4446bdacb 100644 --- a/core/nds32/task.c +++ b/core/nds32/task.c @@ -236,7 +236,8 @@ task_id_t task_get_current(void) /* If we haven't done a context switch then our task ID isn't valid */ ASSERT(current_task != (task_ *)scratchpad); #endif - return current_task - tasks; + /* return invalid task id if task scheduling is not yet start */ + return start_called ? (current_task - tasks) : TASK_ID_INVALID; } uint32_t *task_get_event_bitmap(task_id_t tskid) |