* [PATCH] omap: add sched_clock for omap1 based on MPU timer
@ 2009-05-22 19:47 Tim Bird
2009-05-22 20:41 ` Kevin Hilman
0 siblings, 1 reply; 2+ messages in thread
From: Tim Bird @ 2009-05-22 19:47 UTC (permalink / raw)
To: linux kernel; +Cc: Kevin Hilman, linux-arm-kernel, linux-omap-open-source
Define a higher-resolution sched_clock for OMAP
using the MPU timer, when it is configured on.
This produces better results from ftrace.
Signed-off-by: Tim Bird <tim.bird@am.sony.com>
---
arch/arm/mach-omap1/time.c | 9 +++++++++
arch/arm/plat-omap/common.c | 2 ++
2 files changed, 11 insertions(+)
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -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
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -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)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] omap: add sched_clock for omap1 based on MPU timer
2009-05-22 19:47 [PATCH] omap: add sched_clock for omap1 based on MPU timer Tim Bird
@ 2009-05-22 20:41 ` Kevin Hilman
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Hilman @ 2009-05-22 20:41 UTC (permalink / raw)
To: Tim Bird; +Cc: linux kernel, linux-arm-kernel, linux-omap-open-source
Tim Bird <tim.bird@am.sony.com> writes:
> Define a higher-resolution sched_clock for OMAP
> using the MPU timer, when it is configured on.
>
> This produces better results from ftrace.
>
> Signed-off-by: Tim Bird <tim.bird@am.sony.com>
> ---
> arch/arm/mach-omap1/time.c | 9 +++++++++
> arch/arm/plat-omap/common.c | 2 ++
> 2 files changed, 11 insertions(+)
>
> --- a/arch/arm/mach-omap1/time.c
> +++ b/arch/arm/mach-omap1/time.c
> @@ -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;
> +}
> +
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
> static void __init omap_init_clocksource(unsigned long rate)
> {
> static char err[] __initdata = KERN_ERR
> --- a/arch/arm/plat-omap/common.c
> +++ b/arch/arm/plat-omap/common.c
> @@ -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)
> {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-22 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-22 19:47 [PATCH] omap: add sched_clock for omap1 based on MPU timer Tim Bird
2009-05-22 20:41 ` Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox