Skip to contentSkip to conversation

omap: add sched_clock for omap1 based on MPU timer

PATCH In review Tim Bird 2 participants 2 messages May 22, 2009

Subsystems (3)
lore
Share & tools
lore

Tim Bird

author
#0 lore raw

PATCH 1/1 omap: add sched_clock for omap1 based on MPU timer

Define a higher-resolution sched_clock for OMAP
using the MPU timer, when it is configured on.

This produces better results from ftrace.

---
 arch/arm/mach-omap1/time.c  |    9 +++++++++
 arch/arm/plat-omap/common.c |    2 ++
 2 files changed, 11 insertions(+)
arch/arm/mach-omap1/time.c +9 -0
@@ -212,6 +212,15 @@ static struct clocksource clocksource_mp
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+unsigned long long notrace sched_clock(void)
+{
+	unsigned long long ret;
+
+	ret = (unsigned long long) ~omap_mpu_timer_read(1);
+	ret = (ret * clocksource_mpu.mult_orig) >> clocksource_mpu.shift;
+	return ret;
+}
+
 static void __init omap_init_clocksource(unsigned long rate)
 {
 	static char err[] __initdata = KERN_ERR
arch/arm/plat-omap/common.c +2 -0
@@ -199,6 +199,7 @@ static struct clocksource clocksource_32
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+#ifndef CONFIG_OMAP_MPU_TIMER
 /*
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
@@ -211,6 +212,7 @@ unsigned long long notrace sched_clock(v
 	ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift;
 	return ret;
 }
+#endif
 
 static int __init omap_init_clocksource_32k(void)
 {
#1 lore raw
Quoted 16 lines · Tim Bird

Define a higher-resolution sched_clock for OMAP
using the MPU timer, when it is configured on.

This produces better results from ftrace.

---
 arch/arm/mach-omap1/time.c  |    9 +++++++++
 arch/arm/plat-omap/common.c |    2 ++
 2 files changed, 11 insertions(+)
arch/arm/mach-omap1/time.c +0 -0
@@ -212,6 +212,15 @@ static struct clocksource clocksource_mp
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };

arch/arm/mach-omap1/time.c static struct clocksource clocksource_mp · line 223

Quoted 10 lines
arch/arm/mach-omap1/time.c +9 -0
 
+unsigned long long notrace sched_clock(void)
+{
+	unsigned long long ret;
+
+	ret = (unsigned long long) ~omap_mpu_timer_read(1);
+	ret = (ret * clocksource_mpu.mult_orig) >> clocksource_mpu.shift;
+	return ret;
+}
+

Minor nit: I think this should rather look something like:

     cycle_t c;

     c = clocksource_read(&clocksource_mpu);
     return cyc2ns(&clocksource_mpu, c);

This way, if the clocksource implementation is changed (to use a different timer for example) this doesn't have to be changed as well.

Kevin

Quoted 21 lines
arch/arm/mach-omap1/time.c +0 -0
 static void __init omap_init_clocksource(unsigned long rate)
 {
 	static char err[] __initdata = KERN_ERR
arch/arm/plat-omap/common.c +2 -0
@@ -199,6 +199,7 @@ static struct clocksource clocksource_32
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+#ifndef CONFIG_OMAP_MPU_TIMER
 /*
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
@@ -211,6 +212,7 @@ unsigned long long notrace sched_clock(v
 	ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift;
 	return ret;
 }
+#endif
 
 static int __init omap_init_clocksource_32k(void)
 {