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 03:50:49 +0000 |
commit | c7138bf8f638b3f487baaf998bcbe4aecb5eaaca (patch) | |
tree | c12728093faf13917edc5fb75b587b0a9460ff56 | |
parent | c0aab9e1b94d7501bdc310098789373784c7ff98 (diff) | |
download | chrome-ec-c7138bf8f638b3f487baaf998bcbe4aecb5eaaca.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>
(cherry picked from commit 2ffc903ae4c772f2b12897634e24fa8e0c1791ef)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2986849
Reviewed-by: 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 5b04e079fb..449b27db2a 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]; @@ -293,7 +293,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); |