Skip to content

Commit 7cbdb6c

Browse files
Andy Rossandrewboie
authored andcommitted
drivers/timer: Restore non-tickless tick count behavior
The newer series of timer drivers will compare counters vs. the last tick boundary to compute a number of ticks to announce to the kernel. In the case of CONFIG_TICKLESS=n, this actually represents a change of behavior from our old scheme where "ticks" always reflected the number of interrupts received. The distinction only matters when an interrupt is delayed more than a full tick, of course. But that actually makes a difference to some timekeeping code. Restore the old behavior. This also has the benefit of further reducing code size when !TICKLESS and improving performance of the ISR by removing the division (remember Cortex M0 has no hardware divide!). Fixes #12409 Signed-off-by: Andy Ross <[email protected]>
1 parent ad2d7ca commit 7cbdb6c

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

drivers/timer/hpet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void hpet_isr(void *arg)
5353
}
5454

5555
k_spin_unlock(&lock, key);
56-
z_clock_announce(dticks);
56+
z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1);
5757
}
5858

5959
static void set_timer0_irq(unsigned int irq)

drivers/timer/nrf_rtc_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void rtc1_nrf_isr(void *arg)
8383
}
8484

8585
irq_unlock(key);
86-
z_clock_announce(dticks);
86+
z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1);
8787
}
8888

8989
int z_clock_driver_init(struct device *device)

drivers/timer/riscv_machine_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void timer_isr(void *arg)
6868
}
6969

7070
k_spin_unlock(&lock, key);
71-
z_clock_announce(dticks);
71+
z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1);
7272
}
7373

7474
int z_clock_driver_init(struct device *device)

drivers/timer/xtensa_sys_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void ccompare_isr(void *arg)
5454
}
5555

5656
k_spin_unlock(&lock, key);
57-
z_clock_announce(dticks);
57+
z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1);
5858
}
5959

6060
/* The legacy Xtensa platform code handles the timer interrupt via a

0 commit comments

Comments
 (0)