Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbbG1ArV (ORCPT ); Mon, 27 Jul 2015 20:47:21 -0400 Received: from mga01.intel.com ([192.55.52.88]:7173 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754592AbbG1AqC (ORCPT ); Mon, 27 Jul 2015 20:46:02 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,559,1432623600"; d="scan'208";a="736785859" From: Christopher Hall To: john.stultz@linaro.org, tglx@linutronix.de, richardcochran@gmail.com, mingo@redhat.com, jeffrey.t.kirsher@intel.com, john.ronciak@intel.com, hpa@zytor.com, x86@kernel.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christopher Hall Subject: [PATCH 2/5] Added functions mapping TSC value to system time Date: Mon, 27 Jul 2015 17:46:53 -0700 Message-Id: <1438044416-15588-3-git-send-email-christopher.s.hall@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438044416-15588-1-git-send-email-christopher.s.hall@intel.com> References: <1438044416-15588-1-git-send-email-christopher.s.hall@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2268 Lines: 73 * tsc_to_rawmono64 * tsc_to_realtime64 * tsc_to_mono64 These function build on the counter_to_* time translation function specifically for TSC based system clock Signed-off-by: Christopher Hall --- arch/x86/include/asm/tsc.h | 5 +++++ arch/x86/kernel/tsc.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h index 94605c0..3fdf8b1 100644 --- a/arch/x86/include/asm/tsc.h +++ b/arch/x86/include/asm/tsc.h @@ -5,6 +5,7 @@ #define _ASM_X86_TSC_H #include +#include #define NS_SCALE 10 /* 2^10, carefully chosen */ #define US_SCALE 32 /* 2^32, arbitralrily chosen */ @@ -52,6 +53,10 @@ extern int check_tsc_unstable(void); extern int check_tsc_disabled(void); extern unsigned long native_calibrate_tsc(void); +extern int tsc_to_rawmono64(struct timespec64 *rawmono, cycle_t counterval); +extern int tsc_to_realtime64(struct timespec64 *realtime, cycle_t counterval); +extern int tsc_to_mono64(struct timespec64 *mono, cycle_t counterval); + extern int tsc_clocksource_reliable; /* diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 7437b41..a192271 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -979,6 +979,24 @@ static cycle_t read_tsc(struct clocksource *cs) return (cycle_t)get_cycles(); } +int tsc_to_rawmono64(struct timespec64 *rawmono, cycle_t counterval) +{ + return counter_to_rawmono64(rawmono, counterval, &clocksource_tsc); +} +EXPORT_SYMBOL(tsc_to_rawmono64); + +int tsc_to_realtime64(struct timespec64 *realtime, cycle_t counterval) +{ + return counter_to_realtime64(realtime, counterval, &clocksource_tsc); +} +EXPORT_SYMBOL(tsc_to_realtime64); + +int tsc_to_mono64(struct timespec64 *mono, cycle_t counterval) +{ + return counter_to_mono64(mono, counterval, &clocksource_tsc); +} +EXPORT_SYMBOL(tsc_to_mono64); + /* * .mask MUST be CLOCKSOURCE_MASK(64). See comment above read_tsc() */ -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/