From: Igor Nabirushkin Date: Thu, 5 Jun 2014 05:52:29 +0000 (+0400) Subject: misc: tegra-profiler: use cntvct as time source X-Git-Tag: daily-2014.08.28.0_rel-st8-r2.4-partner~15 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/sojka/nv-tegra/linux-3.10.git/commitdiff_plain/af2c5bdc72d85b31d116a8b91a69f2fef8618ed4 misc: tegra-profiler: use cntvct as time source Tegra Profiler: use Virtual Count register (CNTVCT) as time source. Bug 1508327 Change-Id: If37e2dbe0a256ec28575d7c1b7d601d6bc1090f5 Signed-off-by: Igor Nabirushkin Reviewed-on: http://git-master/r/419305 (cherry picked from commit 2e5fe3f706a404a087e110a9289818dd6c855c15) Reviewed-on: http://git-master/r/454458 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Tested-by: Maxim Morin Reviewed-by: Mitch Luban --- diff --git a/drivers/misc/tegra-profiler/hrt.c b/drivers/misc/tegra-profiler/hrt.c index 9bbcb30c990..13b131bec5e 100644 --- a/drivers/misc/tegra-profiler/hrt.c +++ b/drivers/misc/tegra-profiler/hrt.c @@ -24,9 +24,11 @@ #include #include #include +#include #include #include +#include #include @@ -91,7 +93,7 @@ static void init_hrtimer(struct quadd_cpu_context *cpu_ctx) cpu_ctx->hrtimer.function = hrtimer_handler; } -u64 quadd_get_time(void) +static inline u64 get_posix_clock_monotonic_time(void) { struct timespec ts; @@ -99,6 +101,25 @@ u64 quadd_get_time(void) return timespec_to_ns(&ts); } +static inline u64 get_arch_time(struct timecounter *tc) +{ + cycle_t value; + const struct cyclecounter *cc = tc->cc; + + value = cc->read(cc); + return cyclecounter_cyc2ns(cc, value); +} + +u64 quadd_get_time(void) +{ + struct timecounter *tc = hrt.tc; + + if (tc) + return get_arch_time(tc); + else + return get_posix_clock_monotonic_time(); +} + static void put_header(void) { int nr_events = 0, max_events = QUADD_MAX_COUNTERS; @@ -616,6 +637,7 @@ struct quadd_hrt_ctx *quadd_hrt_init(struct quadd_ctx *ctx) hrt.ma_period = 0; atomic64_set(&hrt.counter_samples, 0); + hrt.tc = arch_timer_get_timecounter(); hrt.cpu_ctx = alloc_percpu(struct quadd_cpu_context); if (!hrt.cpu_ctx) diff --git a/drivers/misc/tegra-profiler/hrt.h b/drivers/misc/tegra-profiler/hrt.h index ef1f6738baa..32b891da4f9 100644 --- a/drivers/misc/tegra-profiler/hrt.h +++ b/drivers/misc/tegra-profiler/hrt.h @@ -39,6 +39,8 @@ struct quadd_cpu_context { atomic_t nr_active; }; +struct timecounter; + struct quadd_hrt_ctx { struct quadd_cpu_context * __percpu cpu_ctx; u64 sample_period; @@ -54,6 +56,8 @@ struct quadd_hrt_ctx { unsigned long vm_size_prev; unsigned long rss_size_prev; + + struct timecounter *tc; }; #define QUADD_HRT_MIN_FREQ 100 diff --git a/drivers/misc/tegra-profiler/main.c b/drivers/misc/tegra-profiler/main.c index da0c15ff491..555cc259a0c 100644 --- a/drivers/misc/tegra-profiler/main.c +++ b/drivers/misc/tegra-profiler/main.c @@ -432,6 +432,9 @@ static void get_capabilities(struct quadd_comm_cap *cap) extra |= QUADD_COMM_CAP_EXTRA_UNWIND_MIXED; extra |= QUADD_COMM_CAP_EXTRA_UNW_ENTRY_TYPE; + if (ctx.hrt->tc) + extra |= QUADD_COMM_CAP_EXTRA_USE_ARCH_TIMER; + cap->reserved[QUADD_COMM_CAP_IDX_EXTRA] = extra; } diff --git a/drivers/misc/tegra-profiler/quadd_proc.c b/drivers/misc/tegra-profiler/quadd_proc.c index 8f656fae213..12f5fc90cd9 100644 --- a/drivers/misc/tegra-profiler/quadd_proc.c +++ b/drivers/misc/tegra-profiler/quadd_proc.c @@ -96,6 +96,8 @@ static int show_capabilities(struct seq_file *f, void *offset) YES_NO(extra & QUADD_COMM_CAP_EXTRA_UNWIND_MIXED)); seq_printf(f, "information about unwind entry: %s\n", YES_NO(extra & QUADD_COMM_CAP_EXTRA_UNW_ENTRY_TYPE)); + seq_printf(f, "use arch timer: %s\n", + YES_NO(extra & QUADD_COMM_CAP_EXTRA_USE_ARCH_TIMER)); seq_puts(f, "\n"); diff --git a/drivers/misc/tegra-profiler/version.h b/drivers/misc/tegra-profiler/version.h index 392ea70b7a9..d3913ff5e36 100644 --- a/drivers/misc/tegra-profiler/version.h +++ b/drivers/misc/tegra-profiler/version.h @@ -18,7 +18,7 @@ #ifndef __QUADD_VERSION_H #define __QUADD_VERSION_H -#define QUADD_MODULE_VERSION "1.72" +#define QUADD_MODULE_VERSION "1.73" #define QUADD_MODULE_BRANCH "Dev" #endif /* __QUADD_VERSION_H */ diff --git a/include/linux/tegra_profiler.h b/include/linux/tegra_profiler.h index bfab1ee72e8..b0dccedb25b 100644 --- a/include/linux/tegra_profiler.h +++ b/include/linux/tegra_profiler.h @@ -19,7 +19,7 @@ #include -#define QUADD_SAMPLES_VERSION 26 +#define QUADD_SAMPLES_VERSION 27 #define QUADD_IO_VERSION 12 #define QUADD_IO_VERSION_DYNAMIC_RB 5 @@ -39,6 +39,7 @@ #define QUADD_SAMPLE_VERSION_SPECIAL_MMAP 24 #define QUADD_SAMPLE_VERSION_UNWIND_MIXED 25 #define QUADD_SAMPLE_VERSION_UNW_ENTRY_TYPE 26 +#define QUADD_SAMPLE_VERSION_USE_ARCH_TIMER 27 #define QUADD_MAX_COUNTERS 32 #define QUADD_MAX_PROCESS 64 @@ -368,6 +369,7 @@ enum { #define QUADD_COMM_CAP_EXTRA_SPECIAL_ARCH_MMAP (1 << 5) #define QUADD_COMM_CAP_EXTRA_UNWIND_MIXED (1 << 6) #define QUADD_COMM_CAP_EXTRA_UNW_ENTRY_TYPE (1 << 7) +#define QUADD_COMM_CAP_EXTRA_USE_ARCH_TIMER (1 << 8) struct quadd_comm_cap { u32 pmu:1,