diff options
author | Edward Hill <ecgh@chromium.org> | 2020-07-18 19:08:06 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-12 03:13:01 +0000 |
commit | e6956209119d2b2c1f45401855019e3a0a2f7dd5 (patch) | |
tree | dfe7c3b1e31cc449348a7627c4a7890aeca5154a /core | |
parent | dbcab40b7b8696d56b4708f37f84883ae3e0c8bf (diff) | |
download | chrome-ec-e6956209119d2b2c1f45401855019e3a0a2f7dd5.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.
Add check for task_start_called() for NPCX flash_lock, I2C port_mutex,
pwr_5v_ctl_mtx, STM32 bkpdata_write_mutex.
This was submitted CL:2309057, reverted CL:2323704, submitted
CL:2335738, reverted CL:2341706.
BUG=b:160975910
BRANCH=none
TEST=boot AP, jump to RW
Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: I0aadf29d073f0d3d798432099bd024a058332412
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2343450
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/task.c | 8 |
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 { |