arc timer: Fix tickless idle tick announcement
Change-Id: Iad6806c7be76661987652a63deb70a740c0d8e15
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
diff --git a/drivers/timer/arcv2_timer0.c b/drivers/timer/arcv2_timer0.c
index 4b6be60..ae0032d 100644
--- a/drivers/timer/arcv2_timer0.c
+++ b/drivers/timer/arcv2_timer0.c
@@ -159,7 +159,8 @@
*
* @brief System clock periodic tick handler
*
- * This routine handles the system clock periodic tick interrupt.
+ * This routine handles the system clock periodic tick interrupt. It always
+ * announces one tick.
*
* @return N/A
*/
@@ -173,16 +174,11 @@
#if defined(CONFIG_TICKLESS_IDLE)
timer0_limit_register_set(cycles_per_tick - 1);
- _sys_idle_elapsed_ticks++;
+ _sys_idle_elapsed_ticks = 1;
+#endif
update_accumulated_count();
- if (_sys_idle_elapsed_ticks == 1) {
- _sys_clock_tick_announce();
- }
-#else
- update_accumulated_count();
_sys_clock_tick_announce();
-#endif
}
#if defined(CONFIG_TICKLESS_IDLE)
@@ -246,10 +242,6 @@
* timer out of idle mode and generating an interrupt at the next tick
* interval. It is expected that interrupts have been disabled.
*
- * Note that in this routine, _sys_idle_elapsed_ticks must be zero because the
- * ticker has done its work and consumed all the ticks. This has to be true
- * otherwise idle mode wouldn't have been entered in the first place.
- *
* RETURNS: N/A
*/
@@ -257,7 +249,6 @@
{
if (straddled_tick_on_idle_enter) {
/* Aborting the tickless idle due to a straddled tick. */
- _sys_idle_elapsed_ticks = 0;
straddled_tick_on_idle_enter = false;
return;
}
@@ -275,6 +266,8 @@
*/
_sys_idle_elapsed_ticks = programmed_ticks - 1;
+ update_accumulated_count();
+ _sys_clock_tick_announce();
return;
}
@@ -288,6 +281,7 @@
_sys_idle_elapsed_ticks = current_count / cycles_per_tick;
if (_sys_idle_elapsed_ticks > 0) {
+ update_accumulated_count();
_sys_clock_tick_announce();
}