* [PATCH] clocksource: timer-sp804: Fix an Oops when read_current_timer is called on ARM32 platforms where the SP804 is not registered as the sched_clock.
@ 2025-12-19 4:59 Stephen Eta Zhou
2025-12-24 22:05 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Eta Zhou @ 2025-12-19 4:59 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner; +Cc: linux-kernel, groeck7, Stephen Eta Zhou
On SP804, the delay timer shares the same clkevt instance with
sched_clock.
On some platforms, when sp804_clocksource_and_sched_clock_init
is called with use_sched_clock not set to 1,
sched_clkevt is not properly initialized. However,
sp804_register_delay_timer is invoked unconditionally,
and read_current_timer() subsequently calls sp804_read
on an uninitialized sched_clkevt, leading to a kernel
Oops when accessing sched_clkevt->value.
Declare a dedicated clkevt instance exclusively for delay timer,
instead of sharing the same clkevt with sched_clock.
This ensures that read_current_timer continues to work correctly
regardless of whether SP804 is selected as the sched_clock.
Fixes: 640594a04f11 ("clocksource/drivers/timer-sp804: Fix read_current_timer() issue when clock source is not registered")
Signed-off-by: Stephen Eta Zhou <stephen.eta.zhou@gmail.com>
---
drivers/clocksource/timer-sp804.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c
index e82a95ea472478ae096b2bf7abea0d65a7bca480..bf4d40058a2a54899804dc97744bf1255ceb4eb3 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -106,21 +106,25 @@ static u64 notrace sp804_read(void)
return ~readl_relaxed(sched_clkevt->value);
}
+/* Register delay timer backed by the hardware counter */
#ifdef CONFIG_ARM
static struct delay_timer delay;
+struct sp804_clkevt *delay_clkevt;
+
static unsigned long sp804_read_delay_timer_read(void)
{
- return sp804_read();
+ return ~readl_relaxed(delay_clkevt->value);
}
-static void sp804_register_delay_timer(int freq)
+static void sp804_register_delay_timer(struct sp804_clkevt *clk, int freq)
{
+ delay_clkevt = clk;
delay.freq = freq;
delay.read_current_timer = sp804_read_delay_timer_read;
register_current_timer_delay(&delay);
}
#else
-static inline void sp804_register_delay_timer(int freq) {}
+static inline void sp804_register_delay_timer(struct sp804_clkevt *clk, int freq) {}
#endif
static int __init sp804_clocksource_and_sched_clock_init(void __iomem *base,
@@ -135,8 +139,6 @@ static int __init sp804_clocksource_and_sched_clock_init(void __iomem *base,
if (rate < 0)
return -EINVAL;
- sp804_register_delay_timer(rate);
-
clkevt = sp804_clkevt_get(base);
writel(0, clkevt->ctrl);
@@ -152,6 +154,8 @@ static int __init sp804_clocksource_and_sched_clock_init(void __iomem *base,
clocksource_mmio_init(clkevt->value, name,
rate, 200, 32, clocksource_mmio_readl_down);
+ sp804_register_delay_timer(clkevt, rate);
+
if (use_sched_clock) {
sched_clkevt = clkevt;
sched_clock_register(sp804_read, 32, rate);
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251217-fix_timersp804-7910e1c471d4
Best regards,
--
Stephen Eta Zhou <stephen.eta.zhou@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clocksource: timer-sp804: Fix an Oops when read_current_timer is called on ARM32 platforms where the SP804 is not registered as the sched_clock.
2025-12-19 4:59 [PATCH] clocksource: timer-sp804: Fix an Oops when read_current_timer is called on ARM32 platforms where the SP804 is not registered as the sched_clock Stephen Eta Zhou
@ 2025-12-24 22:05 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-12-24 22:05 UTC (permalink / raw)
To: Stephen Eta Zhou, Daniel Lezcano, Thomas Gleixner
Cc: oe-kbuild-all, linux-kernel, groeck7, Stephen Eta Zhou
Hi Stephen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 8f0b4cce4481fb22653697cced8d0d04027cb1e8]
url: https://github.com/intel-lab-lkp/linux/commits/Stephen-Eta-Zhou/clocksource-timer-sp804-Fix-an-Oops-when-read_current_timer-is-called-on-ARM32-platforms-where-the-SP804-is-not-register/20251219-130527
base: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
patch link: https://lore.kernel.org/r/20251219-fix_timersp804-v1-1-020e3cde7cf5%40gmail.com
patch subject: [PATCH] clocksource: timer-sp804: Fix an Oops when read_current_timer is called on ARM32 platforms where the SP804 is not registered as the sched_clock.
config: arm-randconfig-r134-20251224 (https://download.01.org/0day-ci/archive/20251225/202512250520.APOMkYRQ-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 4ef602d446057dabf5f61fb221669ecbeda49279)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251225/202512250520.APOMkYRQ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512250520.APOMkYRQ-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/clocksource/timer-sp804.c:112:21: sparse: sparse: symbol 'delay_clkevt' was not declared. Should it be static?
vim +/delay_clkevt +112 drivers/clocksource/timer-sp804.c
108
109 /* Register delay timer backed by the hardware counter */
110 #ifdef CONFIG_ARM
111 static struct delay_timer delay;
> 112 struct sp804_clkevt *delay_clkevt;
113
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-24 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-19 4:59 [PATCH] clocksource: timer-sp804: Fix an Oops when read_current_timer is called on ARM32 platforms where the SP804 is not registered as the sched_clock Stephen Eta Zhou
2025-12-24 22:05 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.