summaryrefslogtreecommitdiff
path: root/chip
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 /chip
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 'chip')
-rw-r--r--chip/npcx/flash.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/chip/npcx/flash.c b/chip/npcx/flash.c
index 5bb8d209b4..b2b51d15df 100644
--- a/chip/npcx/flash.c
+++ b/chip/npcx/flash.c
@@ -60,8 +60,11 @@ static void flash_pinmux(int enable)
static void flash_execute_cmd(uint8_t code, uint8_t cts)
{
- /* Flash mutex must be held while executing UMA commands. */
- ASSERT(flash_lock.lock);
+ /*
+ * Flash mutex must be held while executing UMA commands after
+ * task_start().
+ */
+ ASSERT(!task_start_called() || flash_lock.lock);
/* set UMA_CODE */
NPCX_UMA_CODE = code;
@@ -723,6 +726,10 @@ int flash_pre_init(void)
void flash_lock_mapped_storage(int lock)
{
+ /* Must not call mutex_lock() before task_start(). */
+ if (!task_start_called())
+ return;
+
if (lock)
mutex_lock(&flash_lock);
else