Signed-off-by: Mathieu Desnoyers <mathieu.desnoy...@efficios.com> Cc: John Stultz <john.stu...@linaro.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Peter Zijlstra <pet...@infradead.org> --- arch/x86/kernel/tsc.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 6ff4924..c75e9f9 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -766,10 +766,28 @@ static cycle_t read_tsc(struct clocksource *cs) ret : clocksource_tsc.cycle_last; } +static cycle_t read_tsc_latch(struct clocksource *cs, int index) +{ + cycle_t ret = (cycle_t)get_cycles(); + + return ret >= clocksource_tsc.cycle_last_latch[index] ? + ret : clocksource_tsc.cycle_last_latch[index]; +} + +static void update_tsc_latch(struct clocksource *cs, int oldindex, + int newindex) +{ + clocksource_tsc.cycle_last_latch[newindex] = + clocksource_tsc.cycle_last_latch[oldindex]; +} + static void resume_tsc(struct clocksource *cs) { - if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC_S3)) + if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC_S3)) { clocksource_tsc.cycle_last = 0; + clocksource_tsc.cycle_last_latch[0] = 0; + clocksource_tsc.cycle_last_latch[1] = 0; + } } static struct clocksource clocksource_tsc = { @@ -783,6 +801,8 @@ static struct clocksource clocksource_tsc = { #ifdef CONFIG_X86_64 .archdata = { .vclock_mode = VCLOCK_TSC }, #endif + .read_latch = read_tsc_latch, + .update_latch = update_tsc_latch, }; void mark_tsc_unstable(char *reason) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/