summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2015-01-27 14:18:23 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-28 01:56:15 +0000
commit3a1b5ec3dd91bac4833167cedcd68d9d4936ce6b (patch)
tree68d30e75a74d553aaab9a8cc1db1f9bf74cfbe60
parent7aa976d3a4832389f868b054297a239eb7d6d685 (diff)
downloadchrome-ec-3a1b5ec3dd91bac4833167cedcd68d9d4936ce6b.tar.gz
cortex-m: disallow rescheduling if task_start() has not yet run
Most GPIO/peripheral interrupts are enabled in HOOK_INIT or some other *_init() functions that are called before task_start(). Quite a lot of these IRQ handler wake some task to process the interrupt, and this causes a race condition. If the interrupt is triggered before task_start() is called, the system may crash/hang/whatever. Fix this by only allowing rescheduling tasks if task_start() is called. This is basically the cortex-m version of commit e541eeb2. BRANCH=Ryu BUG=None TEST=Without this fix, my Ryu P3 always crashes when cold resetting from bootloader mode. After applying this fix, it doesn't anymore. Change-Id: I0f81e90482ff97469c4f0423d6aa060f2ac76f74 Signed-off-by: Vic Yang <victoryang@google.com> Reviewed-on: https://chromium-review.googlesource.com/243626 Tested-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
-rw-r--r--core/cortex-m/task.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index b90f91ce00..69e93457cb 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -359,7 +359,8 @@ uint32_t task_set_event(task_id_t tskid, uint32_t event, int wait)
/* The receiver might run again */
atomic_or(&tasks_ready, 1 << tskid);
#ifndef CONFIG_TASK_PROFILING
- need_resched_or_profiling = 1;
+ if (start_called)
+ need_resched_or_profiling = 1;
#endif
} else {
if (wait)