From 5aeff69cdcf2c8ed897340c432afcc8a1284b939 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Fri, 25 Apr 2014 10:14:23 -0700 Subject: [PATCH] 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 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 Reviewed-by: Vic Yang Commit-Queue: Vincent Palatin --- board/zinger/runtime.c | 3 +++ 1 file changed, 3 insertions(+) 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; }