[ltt-dev] [PATCH] ltt: rework trace clock code for SH (version 2)

Giuseppe CAVALLARO peppe.cavallaro at st.com
Wed Apr 7 04:14:47 EDT 2010


LTTng trace clock definitions for SuperH were broken for the new Kernels.
The patch reviews this code using the clocksource API to handle trace clock.
For example, on ST Kernels the TMU channel 1 continues to be used as
clocksource and all works fine for LTT (tested on SH4 STM platforms based).
Concerning the TMU frequency, it comes from the module_clk clock available
on SuperH platforms.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro at st.com>
---
 arch/sh/include/asm/trace-clock.h |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/arch/sh/include/asm/trace-clock.h b/arch/sh/include/asm/trace-clock.h
index 7dfa042..14a00e2 100644
--- a/arch/sh/include/asm/trace-clock.h
+++ b/arch/sh/include/asm/trace-clock.h
@@ -8,7 +8,7 @@
 #ifndef _ASM_SH_TRACE_CLOCK_H
 #define _ASM_SH_TRACE_CLOCK_H
 
-#include <linux/timer.h>
+#include <linux/clocksource.h>
 #include <asm/clock.h>
 
 /*
@@ -23,11 +23,18 @@
 /* Expected maximum interrupt latency in ms : 15ms, *2 for security */
 #define TC_EXPECTED_INTERRUPT_LATENCY	30
 
+static struct clocksource *clksrc;
+
 extern u64 trace_clock_read_synthetic_tsc(void);
 
 static inline u32 trace_clock_read32(void)
 {
-	return get_cycles();
+	u32 value = 0;
+
+	if (likely(clksrc))
+		value = (u32) clksrc->read(clksrc);
+
+	return value;
 }
 
 static inline u64 trace_clock_read64(void)
@@ -37,11 +44,18 @@ static inline u64 trace_clock_read64(void)
 
 static inline u64 trace_clock_frequency(void)
 {
-	u64 rate;
-	struct clk *tmu1_clk;
+	u64 rate = 0;
+	struct clk *clk;
+
+	/* Get the Clock rate for the TMU channels */
+	clk = clk_get(NULL, "module_clk");
+	if (likely(clk))
+		rate = clk_get_rate(clk) / 4;
 
-	tmu1_clk = clk_get(NULL, "tmu1_clk");
-	rate = clk_get_rate(tmu1_clk);
+	/* Get the clocksource needed to read the timer counter register */
+	clksrc = clocksource_get_next();
+	if (unlikely(!clksrc))
+		pr_err("%s: no clocksource found\n", __func__);
 
 	return rate;
 }
-- 
1.6.0.4





More information about the lttng-dev mailing list