pru: Fix race condition in clearing of irq flags

Each irq flag must only be cleared after it has been serviced.  This
fixes a race condition that could cause incoming commands to be
delayed for extended period.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-09-08 10:36:58 -04:00
parent 91b9634198
commit 121c747cc8
1 changed files with 4 additions and 2 deletions

View File

@ -80,14 +80,16 @@ static void
_irq_poll(void)
{
uint32_t secr0 = CT_INTC.SECR0;
if (secr0 & (1 << KICK_PRU1_EVENT))
if (secr0 & (1 << KICK_PRU1_EVENT)) {
CT_INTC.SECR0 = 1 << KICK_PRU1_EVENT;
sched_wake_tasks();
}
if (secr0 & (1 << IEP_EVENT)) {
CT_IEP.TMR_CMP_STS = 0xff;
uint32_t next = timer_dispatch_many();
timer_set(next);
CT_INTC.SECR0 = 1 << IEP_EVENT;
}
CT_INTC.SECR0 = (1 << IEP_EVENT) | (1 << KICK_PRU1_EVENT);
}
void __attribute__((optimize("O2")))
irq_poll(void)