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 /power | |
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 'power')
-rw-r--r-- | power/common.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/power/common.c b/power/common.c index 0cdabca0fa..b3200fd186 100644 --- a/power/common.c +++ b/power/common.c @@ -1049,10 +1049,15 @@ DECLARE_HOOK(HOOK_INIT, restore_enable_5v_state, HOOK_PRIO_FIRST); static void preserve_enable_5v_state(void) { - mutex_lock(&pwr_5v_ctl_mtx); + /* Must not call mutex_lock() before task_start(). */ + int use_mutex = task_start_called(); + + if (use_mutex) + mutex_lock(&pwr_5v_ctl_mtx); system_add_jump_tag(P5_SYSJUMP_TAG, 0, sizeof(pwr_5v_en_req), &pwr_5v_en_req); - mutex_unlock(&pwr_5v_ctl_mtx); + if (use_mutex) + mutex_unlock(&pwr_5v_ctl_mtx); } DECLARE_HOOK(HOOK_SYSJUMP, preserve_enable_5v_state, HOOK_PRIO_DEFAULT); #endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ |