aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-09-08 10:36:58 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-09-08 11:50:21 -0400
commit121c747cc887e3548932bb6d10d834427e9cb4d8 (patch)
treeecfa1953fc8a010903ba6295be1a711b2c592a53 /src
parent91b9634198df0163f71d3f9c1c15f2f79eb42155 (diff)
downloadkutter-121c747cc887e3548932bb6d10d834427e9cb4d8.tar.gz
kutter-121c747cc887e3548932bb6d10d834427e9cb4d8.tar.xz
kutter-121c747cc887e3548932bb6d10d834427e9cb4d8.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/pru/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pru/main.c b/src/pru/main.c
index 3edce8ec..6019d087 100644
--- a/src/pru/main.c
+++ b/src/pru/main.c
@@ -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)