From 482de93342b5d0dc1e738af4747393bdbd7de216 Mon Sep 17 00:00:00 2001 From: husong1 Date: Mon, 13 Oct 2025 10:46:50 +0800 Subject: [PATCH] arch/arm: Fix the arm timer's maximum delay to be a 64-bit integer. This commit fixed the arm generic timer's maximum delay. Signed-off-by: husong1 --- arch/arm/src/armv7-a/arm_timer.c | 6 ++++-- arch/arm/src/armv7-r/arm_timer.c | 6 ++++-- arch/arm/src/armv8-r/arm_timer.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm/src/armv7-a/arm_timer.c b/arch/arm/src/armv7-a/arm_timer.c index 18c94ed49aa..fcfc902736d 100644 --- a/arch/arm/src/armv7-a/arm_timer.c +++ b/arch/arm/src/armv7-a/arm_timer.c @@ -33,6 +33,8 @@ #include #include +#include + #include "arm_timer.h" #include "gic.h" @@ -102,7 +104,7 @@ static int arm_timer_interrupt(int irq, void *regs, void *arg) static clkcnt_t arm_oneshot_max_delay(struct oneshot_lowerhalf_s *lower) { - return UINT32_MAX; + return UINT64_MAX; } static clkcnt_t arm_oneshot_current(struct oneshot_lowerhalf_s *lower) @@ -121,7 +123,7 @@ static void arm_oneshot_start_absolute(struct oneshot_lowerhalf_s *lower, static void arm_oneshot_start(struct oneshot_lowerhalf_s *lower, clkcnt_t delta) { - arm_timer_phy_set_relative(delta); + arm_timer_phy_set_relative(MIN(UINT32_MAX, delta)); } static void arm_oneshot_cancel(struct oneshot_lowerhalf_s *lower) diff --git a/arch/arm/src/armv7-r/arm_timer.c b/arch/arm/src/armv7-r/arm_timer.c index f6ed610bc10..c38f118d749 100644 --- a/arch/arm/src/armv7-r/arm_timer.c +++ b/arch/arm/src/armv7-r/arm_timer.c @@ -32,6 +32,8 @@ #include +#include + #include "arm_timer.h" #include "gic.h" @@ -98,7 +100,7 @@ static int arm_timer_interrupt(int irq, void *regs, void *arg) static clkcnt_t arm_oneshot_max_delay(struct oneshot_lowerhalf_s *lower) { - return UINT32_MAX; + return UINT64_MAX; } static clkcnt_t arm_oneshot_current(struct oneshot_lowerhalf_s *lower) @@ -117,7 +119,7 @@ static void arm_oneshot_start_absolute(struct oneshot_lowerhalf_s *lower, static void arm_oneshot_start(struct oneshot_lowerhalf_s *lower, clkcnt_t delta) { - arm_timer_phy_set_relative(delta); + arm_timer_phy_set_relative(MIN(UINT32_MAX, delta)); arm_timer_phy_set_irq_mask(false); } diff --git a/arch/arm/src/armv8-r/arm_timer.c b/arch/arm/src/armv8-r/arm_timer.c index 57c1204340b..db79fbafa14 100644 --- a/arch/arm/src/armv8-r/arm_timer.c +++ b/arch/arm/src/armv8-r/arm_timer.c @@ -132,7 +132,7 @@ static int arm_oneshot_compare_isr(int irq, void *regs, void *arg) static clkcnt_t arm_oneshot_max_delay(struct oneshot_lowerhalf_s *lower) { - return UINT32_MAX; + return UINT64_MAX; } static clkcnt_t arm_oneshot_current(struct oneshot_lowerhalf_s *lower) @@ -151,7 +151,7 @@ static void arm_oneshot_start_absolute(struct oneshot_lowerhalf_s *lower, static void arm_oneshot_start(struct oneshot_lowerhalf_s *lower, clkcnt_t delta) { - arm_timer_phy_set_relative(delta); + arm_timer_phy_set_relative(delta <= UINT32_MAX ? delta : UINT32_MAX); } static void arm_oneshot_cancel(struct oneshot_lowerhalf_s *lower)