Hi Murali,

On Fri, Dec 16, 2011 at 04:50:54, Karicheri, Muralidharan wrote:
> Sekhar,
> 
> I made some searches on the internet. The schedule_clock() must return a 
> monotonous clock. One way to do this is to use cnt32_to_63() to convert the 
> 32bit clock count value to a 64bit value. I have tried this and it seems to 
> work. I am just curious as to how this is working on other davinci platforms? 
> So any response from you will be helpful.
> 

I checked this on AM18x and the clock there wraps around in about
180 seconds which is consistent with your observation given that
we have a 24 MHz timer clock there.

I did a quick implementation of sched_clock using the common sched_clock
infrastructure in arch/arm/kernel/sched_clock.c and that seemed to have
fixed the issue in some limited testing. Attached is the patch, can you
give it a shot?

Thanks,
Sekhar

----8<-----
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e084b7e..b5b630a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -924,6 +924,7 @@ config ARCH_DAVINCI
        select ARCH_REQUIRE_GPIOLIB
        select ZONE_DMA
        select HAVE_IDE
+       select HAVE_SCHED_CLOCK
        select CLKDEV_LOOKUP
        select GENERIC_ALLOCATOR
        select GENERIC_IRQ_CHIP
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index e1969ce..8396ba8 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
+#include <asm/sched_clock.h>
 #include <mach/cputype.h>
 #include <mach/time.h>
 #include "clock.h"
@@ -292,12 +293,18 @@ static struct clocksource clocksource_davinci = {
 /*
  * Overwrite weak default sched_clock with something more precise
  */
+static DEFINE_CLOCK_DATA(cd);
+
 unsigned long long notrace sched_clock(void)
 {
-       const cycle_t cyc = clocksource_davinci.read(&clocksource_davinci);
+       u32 cyc = clocksource_davinci.read(&clocksource_davinci);
+       return cyc_to_sched_clock(&cd, cyc, (u32)~0);
+}
 
-       return clocksource_cyc2ns(cyc, clocksource_davinci.mult,
-                               clocksource_davinci.shift);
+static void notrace davinci_update_sched_clock(void)
+{
+       u32 cyc = clocksource_davinci.read(&clocksource_davinci);
+       update_sched_clock(&cd, cyc, (u32)~0);
 }
 
 /*
@@ -399,6 +406,8 @@ static void __init davinci_timer_init(void)
        /* setup clocksource */
        clocksource_davinci.read = read_cycles;
        clocksource_davinci.name = id_to_name[clocksource_id];
+       init_sched_clock(&cd, davinci_update_sched_clock, 32,
+                        davinci_clock_tick_rate);
        if (clocksource_register_hz(&clocksource_davinci,
                                    davinci_clock_tick_rate))
                printk(err, clocksource_davinci.name);

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to