summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2020-07-18 19:08:06 -0600
committerCommit Bot <commit-bot@chromium.org>2020-08-06 23:23:45 +0000
commit8d46141f4d45c65712a9ca7509b7b60128fa4d89 (patch)
tree3a8685f5351f2e7a41019ca5583f8e27e4e2fdee /core
parentda7d2c02f003d4ec739987624a13a3e7ac639613 (diff)
downloadchrome-ec-8d46141f4d45c65712a9ca7509b7b60128fa4d89.tar.gz
task: Fix mutex_lock() assert (reland)
mutex_lock() must not be used in interrupt context. Add an assert to catch this. Also assert task_start_called() since task ID is not valid before this. Also remove an old assert since comparing id with TASK_ID_INVALID doesn't make sense. This was first submitted as CL:2309057, then reverted by CL:2323704 because it broke jump to RW (b/162302011). Fix this by adding check for task_start_called() to chip/npcx/flash.c and common/i2c_master.c. BUG=b:160975910 BRANCH=none TEST=boot AP, jump to RW Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I070a265a95d2128643b536814e608509d81adbe3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335738 Reviewed-by: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/cortex-m/task.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index 75fbf99155..61697d2684 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -860,7 +860,13 @@ void mutex_lock(struct mutex *mtx)
uint32_t value;
uint32_t id = 1 << task_get_current();
- ASSERT(id != TASK_ID_INVALID);
+ /*
+ * mutex_lock() must not be used in interrupt context (because we wait
+ * if there is contention). Task ID is not valid before task_start()
+ * (since current_task is scratchpad).
+ */
+ ASSERT(!in_interrupt_context() && task_start_called());
+
atomic_or(&mtx->waiters, id);
do {