[PATCH 3/3] clocksource/drivers/nxp-stm: Increase min_delta to 20us for PREEMPT_RT

From: Enric Balletbo i Serra via B4 Relay

Date: Mon Oct 26 2026 - 04:48:23 EST


From: Enric Balletbo i Serra <eballetb@xxxxxxxxxx>

Under bus contention on PREEMPT_RT kernels, the 2us min_delta is too
small and the counter can advance past the programmed comparator value
before the overshoot check runs. While the -ETIME fallback handles this
case, repeated retries add latency. Increase min_delta to 20us to reduce
collision probability.

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Enric Balletbo i Serra <eballetb@xxxxxxxxxx>
---
drivers/clocksource/timer-nxp-stm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/timer-nxp-stm.c b/drivers/clocksource/timer-nxp-stm.c
index ed7662a4e2bc..a0761d7f8b01 100644
--- a/drivers/clocksource/timer-nxp-stm.c
+++ b/drivers/clocksource/timer-nxp-stm.c
@@ -335,14 +335,14 @@ static int nxp_stm_clockevent_starting_cpu(unsigned int cpu)
/*
* The timings measurement show reading the counter register
* and writing to the comparator register takes as a maximum
- * value 1100 ns at 133MHz rate frequency. The timer must be
- * set above this value and to be secure we set the minimum
- * value equal to 2000ns, so 2us.
+ * value 1100 ns at 133MHz rate frequency. However, under bus
+ * contention on PREEMPT_RT, 2us is too small and causes missed
+ * matches resulting in 32s wraparounds. Increase to 20us.
*
- * minimum ticks = (rate / MICRO) * 2
+ * minimum ticks = (rate / MICRO) * 20
*/
clockevents_config_and_register(&stm_timer->ced, stm_timer->rate,
- (stm_timer->rate / MICRO) * 2, 0x7FFFFFFFU);
+ (stm_timer->rate / MICRO) * 20, 0x7FFFFFFFU);

return 0;
}

--
2.52.0