diff options
author | Edward Hill <ecgh@chromium.org> | 2020-08-14 15:33:09 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-15 01:47:31 +0000 |
commit | 55554e281b65e4ca780bc1dfee28c2599e781efc (patch) | |
tree | a11b86da0b53206af0a6e98e3adffc340a764929 /core | |
parent | 29ad5a3e08fef053ffe8d56d004d868a8794481a (diff) | |
download | chrome-ec-55554e281b65e4ca780bc1dfee28c2599e781efc.tar.gz |
task: Change mutex_lock() assert
Instead of asserting that task_start() has not been called,
just return without doing any locking.
This avoids the need to fix every caller of mutex_lock() to check
task_start_called().
BUG=b:164461158
BRANCH=none
TEST=Esc+F3+Power enters recovery, does not assert.
Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: Ic157d7e7041185a67f257f0f5710fd02e45cd77f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357496
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Tested-by: Wai-Hong Tam <waihong@google.com>
Commit-Queue: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/task.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c index 61697d2684..d64f9400b6 100644 --- a/core/cortex-m/task.c +++ b/core/cortex-m/task.c @@ -858,14 +858,23 @@ static void __nvic_init_irqs(void) void mutex_lock(struct mutex *mtx) { uint32_t value; - uint32_t id = 1 << task_get_current(); + uint32_t id; /* * 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). + * if there is contention). */ - ASSERT(!in_interrupt_context() && task_start_called()); + ASSERT(!in_interrupt_context()); + + /* + * Task ID is not valid before task_start() (since current_task is + * scratchpad), and no need for mutex locking before task switching has + * begun. + */ + if (!task_start_called()) + return; + + id = 1 << task_get_current(); atomic_or(&mtx->waiters, id); |