summaryrefslogtreecommitdiff
path: root/core/nds32
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2018-03-12 18:31:58 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-13 04:50:05 -0700
commit70a258a192787766289a2804a012337ad0bccc17 (patch)
treee7f959588c4f43bc741e1142ea76b0aabc1ecf5f /core/nds32
parent1dfe3193e7110888268c98e1e9339e79b0ee5025 (diff)
downloadchrome-ec-70a258a192787766289a2804a012337ad0bccc17.tar.gz
nds32: task: allow context switching if task_start() is called
We got a symptom that keyboard didn't work without connecting servo board after this change (CL:897315) was merged. This is because our uart RX will receive a data (0) with framing error if RX level is low and trigger a re-scheduling request in uart ISR (HOOKS task will be wake at later and then start the task scheduling). And that will cause we don't return to main() function to finish all operations of initialization after uart_init() is called. I think we will get the same symptom if GPIO/peripheral interrupts are enabled and wake some task at initialization. This change makes sure we will start the task scheduling if task_start() is called. BUG=none BRANCH=none TEST=With this change, keyboard works after EC reboot without servo board connected. Change-Id: I0bda84b1cb56ced6aad2a38b0786d1b336e77211 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/956794 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core/nds32')
-rw-r--r--core/nds32/switch.S1
-rw-r--r--core/nds32/task.c6
2 files changed, 4 insertions, 3 deletions
diff --git a/core/nds32/switch.S b/core/nds32/switch.S
index a9633782b3..286ed6022d 100644
--- a/core/nds32/switch.S
+++ b/core/nds32/switch.S
@@ -92,6 +92,7 @@ __task_start:
addi $sp, $r3, 4 * 18
/* we are ready to re-schedule */
swi.gp $r4, [ + need_resched]
+ swi.gp $r4, [ + start_called]
/* trigger scheduling to execute the task with the highest priority */
syscall 0
diff --git a/core/nds32/task.c b/core/nds32/task.c
index 788f0c66bf..2de4c78303 100644
--- a/core/nds32/task.c
+++ b/core/nds32/task.c
@@ -166,7 +166,7 @@ static uint32_t tasks_ready = (1 << TASK_ID_HOOKS);
*/
static uint32_t tasks_enabled = (1 << TASK_ID_HOOKS) | (1 << TASK_ID_IDLE);
-static int start_called; /* Has task swapping started */
+int start_called; /* Has task swapping started */
/* interrupt number of sw interrupt */
static int sw_int_num;
@@ -457,7 +457,8 @@ uint32_t __ram_code task_set_event(task_id_t tskid, uint32_t event, int wait)
if (in_interrupt_context()) {
/* The receiver might run again */
atomic_or(&tasks_ready, 1 << tskid);
- need_resched = 1;
+ if (start_called)
+ need_resched = 1;
} else {
if (wait)
return __wait_evt(-1, tskid);
@@ -781,7 +782,6 @@ int task_start(void)
#ifdef CONFIG_TASK_PROFILING
task_start_time = exc_end_time = get_time().val;
#endif
- start_called = 1;
return __task_start();
}