[clocksource: timers/drivers/next] clocksource/drivers/nxp-stm: Fix max_delta overflow on 64-bit platforms

From: clocksource-bot for Enric Balletbo i Serra

Date: Tue Dec 01 2026 - 05:28:28 EST


The following commit has been merged into the timers/drivers/next branch of clocksource:

Commit-ID: 9579481987f29a9e4702d94c28974f7d6603070d
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/daniel.lezcano/linux.git//9579481987f29a9e4702d94c28974f7d6603070d
Author: Enric Balletbo i Serra <eballetb@xxxxxxxxxx>
AuthorDate: Thu, 05 Nov 2026 09:18:32 +01:00
Committer: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
CommitterDate: Tue, 01 Dec 2026 11:10:59 +01:00

clocksource/drivers/nxp-stm: Fix max_delta overflow on 64-bit platforms

The NXP STM timer has a 32-bit counter and 32-bit compare registers.
Using ULONG_MAX as the max_delta parameter for
clockevents_config_and_register() is incorrect on 64-bit platforms where
unsigned long is 64 bits, as this exceeds the hardware's capability.

Cap the max_delta to 0x7FFFFFFFU to match the 32-bit compare channel
width, avoiding potential timer event misses or unexpected delays caused
by programming an unreachable compare value.

Fixes: cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
Signed-off-by: Enric Balletbo i Serra <eballetb@xxxxxxxxxx>
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Tested-by: Khristine Andreea Barbulescu <khristineandreea.barbulescu@xxxxxxxxxxx>
Link: https://patch.msgid.link/20261105-nxp-stm-fixes-v3-1-8129b912e74b@xxxxxxxxxx
---
drivers/clocksource/timer-nxp-stm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-nxp-stm.c b/drivers/clocksource/timer-nxp-stm.c
index dcf2bc8..87ae0ae 100644
--- a/drivers/clocksource/timer-nxp-stm.c
+++ b/drivers/clocksource/timer-nxp-stm.c
@@ -342,7 +342,7 @@ static int nxp_stm_clockevent_starting_cpu(unsigned int cpu)
* minimum ticks = (rate / MICRO) * 2
*/
clockevents_config_and_register(&stm_timer->ced, stm_timer->rate,
- (stm_timer->rate / MICRO) * 2, ULONG_MAX);
+ (stm_timer->rate / MICRO) * 2, 0x7FFFFFFFU);

return 0;
}