Skip to contentSkip to conversation

clocksource/drivers/rda: Add sched_clock_register for RDA8810PL SoC

PATCH Applied Enlin Mu 3 participants 5 messages Nov 7, 2025 – Nov 26, 2025

Subsystems (2)
lore
Share & tools
lore

Enlin Mu

author
#0 lore raw

PATCH v2 1/1 clocksource/drivers/rda: Add sched_clock_register for RDA8810PL SoC

From: Enlin Mu <[email protected]>

The current system log timestamp accuracy is tick, which can not meet the usage requirements and needs to reach nanoseconds. Therefore, the sched_clock_register funciton needs to be add.

---
 drivers/clocksource/timer-rda.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/timer-rda.c +8 -1
index fd1199c189bf..0be8e05970e2 100644
@@ -13,6 +13,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 
 #include "timer-of.h"
 
@@ -153,7 +154,7 @@ static struct timer_of rda_ostimer_of = {
 	},
 };
 
-static u64 rda_hwtimer_read(struct clocksource *cs)
+static u64 rda_hwtimer_clocksource_read(void)
 {
 	void __iomem *base = timer_of_base(&rda_ostimer_of);
 	u32 lo, hi;
@@ -167,6 +168,11 @@ static u64 rda_hwtimer_read(struct clocksource *cs)
 	return ((u64)hi << 32) | lo;
 }
 
+static u64 rda_hwtimer_read(struct clocksource *cs)
+{
+	return rda_hwtimer_clocksource_read();
+}
+
 static struct clocksource rda_hwtimer_clocksource = {
 	.name           = "rda-timer",
 	.rating         = 400,
@@ -185,6 +191,7 @@ static int __init rda_timer_init(struct device_node *np)
 		return ret;
 
 	clocksource_register_hz(&rda_hwtimer_clocksource, rate);
+	sched_clock_register(rda_hwtimer_clocksource_read, 64, rate);
 
 	clockevents_config_and_register(&rda_ostimer_of.clkevt, rate,
 					0x2, UINT_MAX);
Signature · 1 line
2.39.5
author
#1 lore raw

Hi Everyone

Who can help review this patch?

thanks

Quoted 52 lines · Enlin Mu

From: Enlin Mu <[email protected]>

The current system log timestamp accuracy is tick, which can not meet the usage requirements and needs to reach nanoseconds. Therefore, the sched_clock_register funciton needs to be add.

---
  drivers/clocksource/timer-rda.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/timer-rda.c +8 -1
index fd1199c189bf..0be8e05970e2 100644
@@ -13,6 +13,7 @@
 
  #include <linux/init.h>
  #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 
  #include "timer-of.h"
 
@@ -153,7 +154,7 @@ static struct timer_of rda_ostimer_of = {
  	},
  };
 
-static u64 rda_hwtimer_read(struct clocksource *cs)
+static u64 rda_hwtimer_clocksource_read(void)
  {
  	void __iomem *base = timer_of_base(&rda_ostimer_of);
  	u32 lo, hi;
@@ -167,6 +168,11 @@ static u64 rda_hwtimer_read(struct clocksource *cs)
  	return ((u64)hi << 32) | lo;
  }
 
+static u64 rda_hwtimer_read(struct clocksource *cs)
+{
+	return rda_hwtimer_clocksource_read();
+}
+
  static struct clocksource rda_hwtimer_clocksource = {
  	.name           = "rda-timer",
  	.rating         = 400,
@@ -185,6 +191,7 @@ static int __init rda_timer_init(struct device_node *np)
  		return ret;
 
  	clocksource_register_hz(&rda_hwtimer_clocksource, rate);
+	sched_clock_register(rda_hwtimer_clocksource_read, 64, rate);
 
  	clockevents_config_and_register(&rda_ostimer_of.clkevt, rate,
  					0x2, UINT_MAX);
#2 lore raw
In reply to Enlin Mu
Quoted 4 lines · Enlin Mu

From: Enlin Mu <[email protected]>

The current system log timestamp accuracy is tick, which can not meet the usage requirements and needs to reach nanoseconds.

Which 'usage requirement' you are referring here?

Quoted 3 lines

Therefore, the sched_clock_register funciton needs to be add.

But I'm happy to see a patch from Unisoc for RDA Micro SoC :)

- Mani

Quoted 48 lines
---
 drivers/clocksource/timer-rda.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/timer-rda.c +8 -1
index fd1199c189bf..0be8e05970e2 100644
@@ -13,6 +13,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 
 #include "timer-of.h"
 
@@ -153,7 +154,7 @@ static struct timer_of rda_ostimer_of = {
 	},
 };
 
-static u64 rda_hwtimer_read(struct clocksource *cs)
+static u64 rda_hwtimer_clocksource_read(void)
 {
 	void __iomem *base = timer_of_base(&rda_ostimer_of);
 	u32 lo, hi;
@@ -167,6 +168,11 @@ static u64 rda_hwtimer_read(struct clocksource *cs)
 	return ((u64)hi << 32) | lo;
 }
 
+static u64 rda_hwtimer_read(struct clocksource *cs)
+{
+	return rda_hwtimer_clocksource_read();
+}
+
 static struct clocksource rda_hwtimer_clocksource = {
 	.name           = "rda-timer",
 	.rating         = 400,
@@ -185,6 +191,7 @@ static int __init rda_timer_init(struct device_node *np)
 		return ret;
 
 	clocksource_register_hz(&rda_hwtimer_clocksource, rate);
+	sched_clock_register(rda_hwtimer_clocksource_read, 64, rate);
 
 	clockevents_config_and_register(&rda_ostimer_of.clkevt, rate,
 					0x2, UINT_MAX);
Signature · 1 line
2.39.5
Signature · 1 line
மணிவண்ணன் சதாசிவம்
author
#3 lore raw
Quoted 7 lines · Manivannan Sadhasivam
Quoted 4 lines · Enlin Mu

From: Enlin Mu <[email protected]>

The current system log timestamp accuracy is tick, which can not meet the usage requirements and needs to reach nanoseconds.

Which 'usage requirement' you are referring here?

Hi Mani

When using this chip,the timestamp accuracy of the kernel log is tick, which makes it difficult to analyze some system exceptions. Therefore, it is neccessary to adujst the accuracy of the sched_clock function.

Quoted 58 lines
Quoted 4 lines

Therefore, the sched_clock_register funciton needs to be add.

But I'm happy to see a patch from Unisoc for RDA Micro SoC :)

- Mani

Quoted 48 lines
---
  drivers/clocksource/timer-rda.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/timer-rda.c +8 -1
index fd1199c189bf..0be8e05970e2 100644
@@ -13,6 +13,7 @@
 
  #include <linux/init.h>
  #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 
  #include "timer-of.h"
 
@@ -153,7 +154,7 @@ static struct timer_of rda_ostimer_of = {
  	},
  };
 
-static u64 rda_hwtimer_read(struct clocksource *cs)
+static u64 rda_hwtimer_clocksource_read(void)
  {
  	void __iomem *base = timer_of_base(&rda_ostimer_of);
  	u32 lo, hi;
@@ -167,6 +168,11 @@ static u64 rda_hwtimer_read(struct clocksource *cs)
  	return ((u64)hi << 32) | lo;
  }
 
+static u64 rda_hwtimer_read(struct clocksource *cs)
+{
+	return rda_hwtimer_clocksource_read();
+}
+
  static struct clocksource rda_hwtimer_clocksource = {
  	.name           = "rda-timer",
  	.rating         = 400,
@@ -185,6 +191,7 @@ static int __init rda_timer_init(struct device_node *np)
  		return ret;
 
  	clocksource_register_hz(&rda_hwtimer_clocksource, rate);
+	sched_clock_register(rda_hwtimer_clocksource_read, 64, rate);
 
  	clockevents_config_and_register(&rda_ostimer_of.clkevt, rate,
  					0x2, UINT_MAX);
Signature · 1 line
2.39.5
merge bot Applied
#4 lore raw
In reply to Enlin Mu
The following commit has been merged into the timers/clocksource branch of tip:

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

Commit-ID:     627f3f3716a3591f5e6a6bd124c95eef85444080
Gitweb:        https://git.kernel.org/tip/627f3f3716a3591f5e6a6bd124c95eef85444080
Author:        Enlin Mu <[email protected]>
AuthorDate:    Fri, 07 Nov 2025 14:33:47 +08:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 26 Nov 2025 11:25:11 +01:00

clocksource/drivers/rda: Add sched_clock_register for RDA8810PL SoC

The current system log timestamp accuracy is tick based, which can not meet the usage requirements and needs to reach nanoseconds. Therefore, the sched_clock_register function needs to be added.

[ dlezcano: Fixed typos ]

---
 drivers/clocksource/timer-rda.c |  9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/timer-rda.c +8 -1
index fd1199c..0be8e05 100644
@@ -13,6 +13,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 
 #include "timer-of.h"
 
@@ -153,7 +154,7 @@ static struct timer_of rda_ostimer_of = {
 	},
 };
 
-static u64 rda_hwtimer_read(struct clocksource *cs)
+static u64 rda_hwtimer_clocksource_read(void)
 {
 	void __iomem *base = timer_of_base(&rda_ostimer_of);
 	u32 lo, hi;
@@ -167,6 +168,11 @@ static u64 rda_hwtimer_read(struct clocksource *cs)
 	return ((u64)hi << 32) | lo;
 }
 
+static u64 rda_hwtimer_read(struct clocksource *cs)
+{
+	return rda_hwtimer_clocksource_read();
+}
+
 static struct clocksource rda_hwtimer_clocksource = {
 	.name           = "rda-timer",
 	.rating         = 400,
@@ -185,6 +191,7 @@ static int __init rda_timer_init(struct device_node *np)
 		return ret;
 
 	clocksource_register_hz(&rda_hwtimer_clocksource, rate);
+	sched_clock_register(rda_hwtimer_clocksource_read, 64, rate);
 
 	clockevents_config_and_register(&rda_ostimer_of.clkevt, rate,
 					0x2, UINT_MAX);