diff options
author | Nicolas Boichat <drinkcat@google.com> | 2016-11-10 18:19:37 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-11-22 17:29:24 +0000 |
commit | 9b60ea9aeea5f885fb70448e361952278e9dec15 (patch) | |
tree | 4373564cda9008de552725c8adc9806a98f9f8bb | |
parent | 17f02252ecbefc2ba1734dcda852f9aadce7a3b6 (diff) | |
download | chrome-ec-9b60ea9aeea5f885fb70448e361952278e9dec15.tar.gz |
i2c-stm32f0: wait_isr: Try to read status again before timeout
When the EC is exceptionally busy (e.g., during software sync), it
is possible that wait_isr returns EC_ERROR_TIMEOUT even though
the status has already been updated. This patch gives us once
last chance to succeed.
BRANCH=none
BUG=chrome-os-partner:58750
TEST=100x fwupdatetest between 19.0 and 25.0, with custom EC RO.
Change-Id: Ic8288d281b54e292ae75d2169b8c48ba2a033a8f
Reviewed-on: https://chromium-review.googlesource.com/409752
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Trybot-Ready: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | chip/stm32/i2c-stm32f0.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index 8710d73be5..0f06712eed 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -72,7 +72,7 @@ static int wait_isr(int port, int mask) uint32_t start = __hw_clock_source_read(); uint32_t delta = 0; - do { + while (1) { int isr = STM32_I2C_ISR(port); /* Check for errors */ @@ -84,6 +84,9 @@ static int wait_isr(int port, int mask) if ((isr & mask) == mask) return EC_SUCCESS; + if (delta >= pdata[port].timeout_us) + return EC_ERROR_TIMEOUT; + delta = __hw_clock_source_read() - start; /** @@ -92,9 +95,7 @@ static int wait_isr(int port, int mask) */ if (delta >= busyloop_us[pdata[port].freq]) usleep(100); - } while (delta < pdata[port].timeout_us); - - return EC_ERROR_TIMEOUT; + } } /* Supported i2c input clocks */ |