MIPS: Octeon: Add sched_clock() to csrc-octeon.c
authorDavid Daney <ddaney@caviumnetworks.com>
Wed, 23 Dec 2009 21:18:54 +0000 (13:18 -0800)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 12 Jan 2010 17:19:34 +0000 (18:19 +0100)
With the advent of function graph tracing on MIPS, Octeon needs a high
precision sched_clock() implementation.  Without it, most timing
numbers are reported as 0.000.

This new sched_clock just uses the 64-bit cycle counter appropriately
scaled.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Patchwork: http://patchwork.linux-mips.org/patch/805/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/cavium-octeon/csrc-octeon.c

index 96110f217dcd6ac79d1aa7c8e644d2036a7d9113..96df821fbd81f56ba3909c01b576289327011675 100644 (file)
@@ -50,6 +50,13 @@ static struct clocksource clocksource_mips = {
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+unsigned long long notrace sched_clock(void)
+{
+       return clocksource_cyc2ns(read_c0_cvmcount(),
+                                 clocksource_mips.mult,
+                                 clocksource_mips.shift);
+}
+
 void __init plat_time_init(void)
 {
        clocksource_mips.rating = 300;