diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-10-30 10:01:26 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-17 23:37:26 -0800 |
commit | 6432c52a72cdc58ccdd16b0a045bcf578d889bbe (patch) | |
tree | 26d1fe43f5d3ec1804317037736fa7291d0f3375 /chip/stm32 | |
parent | 7b5b83055cbf8b4e67e6e63e72dd8f8038f80635 (diff) | |
download | chrome-ec-6432c52a72cdc58ccdd16b0a045bcf578d889bbe.tar.gz |
stm32/usb: usb_wake: Update STM32_USB_CNTR with interrupts off
STM32_USB_CNTR may be written from both interrupt context, and
usb_wake (not necessarily in interrupt context). Let's disable
interrupts to make sure the operation is atomic.
BRANCH=none
BUG=b:35775088
BUG=b:67766202
BUG=b:71688150
TEST=Flash hammer, hammer can wake from USB autosuspend
Change-Id: I9c2a3259902ecb759a6d0d89c7746c7aa72ae73d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/744282
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/stm32')
-rw-r--r-- | chip/stm32/usb.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index c97c68f03c..dfec42b5f8 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -456,8 +456,12 @@ void usb_wake(void) * 2 and 3 ms. */ esof_count = 3; + + /* STM32_USB_CNTR can also be updated from interrupt context. */ + interrupt_disable(); STM32_USB_CNTR |= STM32_USB_CNTR_RESUME | - STM32_USB_CNTR_ESOFM | STM32_USB_CNTR_SOFM; + STM32_USB_CNTR_ESOFM | STM32_USB_CNTR_SOFM; + interrupt_enable(); /* Try side-band wake as well. */ board_usb_wake(); |