* [PATCH v2] 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-25 8:16 Stephen Eta Zhou
2026-01-29 21:32 ` [tip: timers/clocksource] clocksource/drivers/timer-sp804: " tip-bot2 for Stephen Eta Zhou
2026-04-27 3:25 ` [PATCH v2] clocksource: timer-sp804: " Guenter Roeck
0 siblings, 2 replies; 5+ messages in thread
From: Stephen Eta Zhou @ 2025-12-25 8:16 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner
Cc: linux-kernel, Guenter Roeck, kernel test robot, 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")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512250520.APOMkYRQ-lkp@intel.com/
Signed-off-by: Stephen Eta Zhou <stephen.eta.zhou@gmail.com>
---
Changes in v2:
- Declared `delay_clkevt` as `static` to fix the sparse warning.
- Link to v1: https://lore.kernel.org/r/20251219-fix_timersp804-v1-1-020e3cde7cf5@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..d698584273596b99973afcc10da07c19d26cf8a5 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;
+static 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] 5+ messages in thread
* [tip: timers/clocksource] clocksource/drivers/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-25 8:16 [PATCH v2] 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
@ 2026-01-29 21:32 ` tip-bot2 for Stephen Eta Zhou
2026-04-27 3:25 ` [PATCH v2] clocksource: timer-sp804: " Guenter Roeck
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot2 for Stephen Eta Zhou @ 2026-01-29 21:32 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Stephen Eta Zhou, Daniel Lezcano, x86,
linux-kernel
The following commit has been merged into the timers/clocksource branch of tip:
Commit-ID: 694921a93f3e3621e067afc545cedf6fe3b234a9
Gitweb: https://git.kernel.org/tip/694921a93f3e3621e067afc545cedf6fe3b234a9
Author: Stephen Eta Zhou <stephen.eta.zhou@gmail.com>
AuthorDate: Thu, 25 Dec 2025 16:16:31 +08:00
Committer: Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Tue, 20 Jan 2026 18:06:54 +01:00
clocksource/drivers/timer-sp804: Fix an Oops when read_current_timer is called on ARM32 platforms where the SP804 is not registered as the sched_clock.
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")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512250520.APOMkYRQ-lkp@intel.com/
Signed-off-by: Stephen Eta Zhou <stephen.eta.zhou@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://patch.msgid.link/20251225-fix_timersp804-v2-1-a366d7157f58@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 e82a95e..d698584 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;
+static 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);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] 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-25 8:16 [PATCH v2] 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
2026-01-29 21:32 ` [tip: timers/clocksource] clocksource/drivers/timer-sp804: " tip-bot2 for Stephen Eta Zhou
@ 2026-04-27 3:25 ` Guenter Roeck
2026-04-27 3:39 ` Stephen Eta Zhou
1 sibling, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2026-04-27 3:25 UTC (permalink / raw)
To: Stephen Eta Zhou
Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, Guenter Roeck,
kernel test robot
Hi,
On Thu, Dec 25, 2025 at 04:16:31PM +0800, Stephen Eta Zhou wrote:
> 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")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512250520.APOMkYRQ-lkp@intel.com/
> Signed-off-by: Stephen Eta Zhou <stephen.eta.zhou@gmail.com>
I found that the integratorcp qemu emulation still hangs unpredictably
with this and the preceding patch in the tree.
I have no idea what is causing the problem, except that it disappears if I
revert this patch and 640594a04f11.
It appears that no one else has reported the problem, which suggests to me
that no one cares. Given that, I'll stop testing the upstream kernel against
the integratorcp qemu emulation.
This is just informational; no action expected or warranted.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] 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.
2026-04-27 3:25 ` [PATCH v2] clocksource: timer-sp804: " Guenter Roeck
@ 2026-04-27 3:39 ` Stephen Eta Zhou
2026-04-28 16:16 ` Guenter Roeck
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Eta Zhou @ 2026-04-27 3:39 UTC (permalink / raw)
To: Guenter Roeck
Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, Guenter Roeck,
kernel test robot
On 26/04/26 20:25, Guenter Roeck wrote:
> I found that the integratorcp qemu emulation still hangs unpredictably
> with this and the preceding patch in the tree.
Hi Guenter,
Thanks for the report.
Could you share the QEMU command line, kernel config, and the detailed
steps you used to reproduce the hang?
I will try to reproduce it locally and debug it from my side.
Thanks,
Stephen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] 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.
2026-04-27 3:39 ` Stephen Eta Zhou
@ 2026-04-28 16:16 ` Guenter Roeck
0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2026-04-28 16:16 UTC (permalink / raw)
To: Stephen Eta Zhou
Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, Guenter Roeck,
kernel test robot
Hi Stephen,
On Mon, Apr 27, 2026 at 11:39:42AM +0800, Stephen Eta Zhou wrote:
> On 26/04/26 20:25, Guenter Roeck wrote:
> > I found that the integratorcp qemu emulation still hangs unpredictably
> > with this and the preceding patch in the tree.
>
> Hi Guenter,
>
> Thanks for the report.
>
> Could you share the QEMU command line, kernel config, and the detailed
> steps you used to reproduce the hang?
>
> I will try to reproduce it locally and debug it from my side.
>
No worries. As I said, this was purely informational. Ever since 6.18
Linux started to break on more and more platforms in my tests. I can not
keep up with testing or analyzing the problems, so as I find issues I
report it and stop testing if the problem persists over a couple of
releases. As in this case, it is obvious that no either one cares, that
it is a problem with qemu, or a problem with my setup. Given all that,
even if the problem is not related to my setup, it would be a waste of time
trying to track it down or to keep testing.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-28 16:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-25 8:16 [PATCH v2] 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
2026-01-29 21:32 ` [tip: timers/clocksource] clocksource/drivers/timer-sp804: " tip-bot2 for Stephen Eta Zhou
2026-04-27 3:25 ` [PATCH v2] clocksource: timer-sp804: " Guenter Roeck
2026-04-27 3:39 ` Stephen Eta Zhou
2026-04-28 16:16 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox