From 39a8f3b4f957ed0e50c848414891ad5fab4500bb Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Wed, 3 Mar 2021 12:16:35 -0800 Subject: [PATCH] kernel/idle: Replace stolen IRQ lock The removal of the abort handling also absconded with an IRQ lock that is required for reliable operation in the idle loop. Put it back. Once the idle loop has made a decision to enter idle, any interrupt that arrives needs to be masked and delivered AFTER the system enters idle. Otherwise we run the risk of races where the system accepts and processes an interrupt that should have prevented idle, but then goes to sleep anyway having already made the decision. Signed-off-by: Andy Ross --- kernel/idle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/idle.c b/kernel/idle.c index 8beb94f6ec..1b9d3c77b0 100644 --- a/kernel/idle.c +++ b/kernel/idle.c @@ -135,6 +135,8 @@ void idle(void *p1, void *unused2, void *unused3) k_yield(); #else + (void) arch_irq_lock(); + #ifdef CONFIG_SYS_CLOCK_EXISTS int32_t ticks = z_get_next_timeout_expiry();