diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2021-06-24 17:49:03 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-25 01:19:46 +0000 |
commit | 2ffc903ae4c772f2b12897634e24fa8e0c1791ef (patch) | |
tree | 10052eb0fdf70943ff0b36279d5b90288341ce9a | |
parent | 6754bd6b6c3a8b80b6bdca073a65f526997781d4 (diff) | |
download | chrome-ec-2ffc903ae4c772f2b12897634e24fa8e0c1791ef.tar.gz |
i2c_controller: add volatile for i2c_port_active_list
With the LTO enabled, the i2c_port_active_list might be
reordered by linker and causes the i2c lock checking failure.
BUG=b:191444593
TEST=i2c waveform looks good, no "Access i2c without lock" complain
BRANCH=none
Change-Id: I96996c7288b65e74f1734fd14a82f069b6ff11ff
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2984257
Tested-by: Eric Yilun Lin <yllin@google.com>
Tested-by: Hsu Alvis <alvishsu@google.com>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Commit-Queue: Eric Yilun Lin <yllin@google.com>
-rw-r--r-- | common/i2c_controller.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/i2c_controller.c b/common/i2c_controller.c index 09eb255a22..2e9e1b4b76 100644 --- a/common/i2c_controller.c +++ b/common/i2c_controller.c @@ -50,7 +50,7 @@ static mutex_t port_mutex[I2C_CONTROLLER_COUNT + I2C_BITBANG_PORT_COUNT]; /* A bitmap of the controllers which are currently servicing a request. */ -static uint32_t i2c_port_active_list; +static volatile uint32_t i2c_port_active_list; BUILD_ASSERT(ARRAY_SIZE(port_mutex) < 32); static uint8_t port_protected[I2C_PORT_COUNT + I2C_BITBANG_PORT_COUNT]; @@ -295,7 +295,7 @@ void i2c_lock(int port, int lock) /* Disable interrupt during changing counter for preemption. */ irq_lock_key = irq_lock(); - i2c_port_active_list |= 1 << port; + i2c_port_active_list |= BIT(port); /* EC cannot enter sleep if there's any i2c port active. */ disable_sleep(SLEEP_MASK_I2C_CONTROLLER); |