diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-04-25 10:14:23 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-04-29 03:10:59 +0000 |
commit | 5aeff69cdcf2c8ed897340c432afcc8a1284b939 (patch) | |
tree | c3195246ba5ff9ad47b3e4092902e682f9fe0470 | |
parent | 564fced7b8c424aadb29f069e98d5ec20d01b552 (diff) | |
download | chrome-ec-5aeff69cdcf2c8ed897340c432afcc8a1284b939.tar.gz |
zinger: remove race condition in event handling
In the micro runtime for Zinger, wait for events with interrupt disabled
to avoid race conditions where the event interrupt happens just after we
tested it and before going to sleep.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=make BOARD=zinger, test Zinger PD communication from Firefly.
Change-Id: I10b919450a61fac7ea50e84dd73bcc568150e179
Reviewed-on: https://chromium-review.googlesource.com/197051
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/zinger/runtime.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c index 24558693db..9393c8fe50 100644 --- a/board/zinger/runtime.c +++ b/board/zinger/runtime.c @@ -63,11 +63,13 @@ uint32_t task_wait_event(int timeout_us) { uint32_t evt; + asm volatile("cpsid i"); /* the event already happened */ if (last_event || !timeout_us) { evt = last_event; last_event = 0; + asm volatile("cpsie i ; isb"); return evt; } @@ -84,6 +86,7 @@ uint32_t task_wait_event(int timeout_us) STM32_TIM_DIER(2) = 0; /* disable match interrupt */ evt = last_event; last_event = 0; + asm volatile("cpsie i ; isb"); return evt; } |