[ltt-dev] [PATCH 2/3] ltt: rework trace clock code for SH
Giuseppe CAVALLARO
peppe.cavallaro at st.com
Tue Apr 6 10:20:22 EDT 2010
Trace clock definitions for SuperH are broken in the new Kernels.
This patch reworks the 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.
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro at st.com>
---
arch/sh/include/asm/trace-clock.h | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/arch/sh/include/asm/trace-clock.h b/arch/sh/include/asm/trace-clock.h
index 7dfa042..667530b 100644
--- a/arch/sh/include/asm/trace-clock.h
+++ b/arch/sh/include/asm/trace-clock.h
@@ -8,8 +8,7 @@
#ifndef _ASM_SH_TRACE_CLOCK_H
#define _ASM_SH_TRACE_CLOCK_H
-#include <linux/timer.h>
-#include <asm/clock.h>
+#include <linux/clocksource.h>
/*
* Number of hardware clock bits. The higher order bits are expected to be 0.
@@ -23,11 +22,15 @@
/* Expected maximum interrupt latency in ms : 15ms, *2 for security */
#define TC_EXPECTED_INTERRUPT_LATENCY 30
+static struct clocksource *clock;
+
extern u64 trace_clock_read_synthetic_tsc(void);
static inline u32 trace_clock_read32(void)
{
- return get_cycles();
+ if (likely(clock))
+ return (u32) clock->read(clock);
+ return 0;
}
static inline u64 trace_clock_read64(void)
@@ -37,13 +40,16 @@ static inline u64 trace_clock_read64(void)
static inline u64 trace_clock_frequency(void)
{
- u64 rate;
- struct clk *tmu1_clk;
+ clock = clocksource_get_next();
- tmu1_clk = clk_get(NULL, "tmu1_clk");
- rate = clk_get_rate(tmu1_clk);
+ if (unlikely(!clock)) {
+ pr_err("%s: clocksource not found\n", __func__);
+ return 0;
+ } else
+ pr_debug("%s: %s clocksource found (rating: %d)\n",
+ __func__, clock->name, clock->rating);
- return rate;
+ return (u64) (clock->rating * 1000000);
}
static inline u32 trace_clock_freq_scale(void)
--
1.6.0.4
More information about the lttng-dev
mailing list