zinger: keyborg: fix runtime bug with task_wait_event()

Fix zinger and keyborg to use correct event mask when
timing out from task_wait_event(): TASK_EVENT_TIMER.

On zinger, move storing the last event to after enabling
interrupts. This gives an opportunity to interrupt
handler to set the wake event.

BUG=chrome-os-partner:30135
BRANCH=none
TEST=load on zinger, and test PD communication with samus.
notably tested sending rw_hash vdm from samus, which is known
to cause zinger to retry the following ping transmit. The
retry on the ping transmit uses task_wait_event(), and without
this fix we were getting false wake events that had been stored
up from the last rx received event. with this fix, the retry
mechanism works.

Change-Id: I9a6902ceaab49a00d3660f9813ca7761cf38f190
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213560
Reviewed-by: Todd Broch <tbroch@chromium.org>
This commit is contained in:
Alec Berg
2014-08-21 08:32:37 -07:00
committed by chrome-internal-fetch
parent 7b1a0dc795
commit 3e844ec271
2 changed files with 6 additions and 4 deletions

View File

@@ -68,7 +68,7 @@ void tim2_interrupt(void)
if (STM32_TIM_CNT(3) == last_deadline >> 16) {
STM32_TIM_DIER(2) = 0;
task_clear_pending_irq(STM32_IRQ_TIM2);
last_event = 1 << 29 /* task event wake */;
last_event = TASK_EVENT_TIMER;
need_wfi = 0;
} else {
need_wfi = 1;

View File

@@ -56,7 +56,7 @@ void tim2_interrupt(void)
{
STM32_TIM_DIER(2) = 0; /* disable match interrupt */
task_clear_pending_irq(STM32_IRQ_TIM2);
last_event = 1 << 29 /* task event wake */;
last_event = TASK_EVENT_TIMER;
}
DECLARE_IRQ(STM32_IRQ_TIM2, tim2_interrupt, 1);
@@ -85,10 +85,12 @@ uint32_t task_wait_event(int timeout_us)
asm volatile("wfi");
STM32_TIM_DIER(2) = 0; /* disable match interrupt */
evt = last_event;
last_event = 0;
asm volatile("cpsie i ; isb");
/* note: interrupt that woke us up will run here */
evt = last_event;
last_event = 0;
return evt;
}