From d7b35c9bd60270b00a1e8a675b20de8763ec03cd Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Sat, 22 Sep 2018 09:13:13 -0700 Subject: [PATCH] idle: Remove needless "expired" logic in sys_power_save_idle() This code (just refactored as part of the timer API work) turns out to be needless. It's trying to detect the case where we're being asked to idle for zero time, but that's not possible with a properly functioning timer driver: the call to z_clock_announce() must happen out of an interrupt, and this is the idle thread, which must sit below any possible interrupt priority. The call to z_clock_uptime() must not ever return "too late" until after the timer interrupt has fired, at which point we'll be inspecting the next timeout (which itself is guaranteed to be in the future for the same reason). Signed-off-by: Andy Ross --- kernel/idle.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/kernel/idle.c b/kernel/idle.c index 48415499956..eeceefd1b06 100644 --- a/kernel/idle.c +++ b/kernel/idle.c @@ -13,8 +13,6 @@ #include #include -extern u64_t z_last_tick_announced; - #if defined(CONFIG_TICKLESS_IDLE) /* * Idle time must be this value or higher for timer to go into tickless idle @@ -72,22 +70,6 @@ static void set_kernel_idle_time_in_ticks(s32_t ticks) #ifndef CONFIG_SMP static void sys_power_save_idle(s32_t ticks) { -#ifdef CONFIG_TICKLESS_KERNEL - if (ticks != K_FOREVER) { - ticks -= (int)(z_clock_uptime() - z_last_tick_announced); - if (!ticks) { - /* - * Timer has expired or about to expire - * No time for power saving operations - * - * Note that it will never be zero unless some time - * had elapsed since timer was last programmed. - */ - k_cpu_idle(); - return; - } - } -#endif if (_must_enter_tickless_idle(ticks)) { /* * Stop generating system timer interrupts until it's time for