mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: [PATCH 6/7] x86 tsc clock: implement clock latch
Date: Sat, 14 Sep 2013 12:48:00 -0700	[thread overview]
Message-ID: <1379188081-15613-7-git-send-email-mathieu.desnoyers@efficios.com> (raw)
In-Reply-To: <1379188081-15613-1-git-send-email-mathieu.desnoyers@efficios.com>

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@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


  parent reply	other threads:[~2013-09-14 19:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-14 19:47 [RFC PATCH v2] timekeeper latch synchronization Mathieu Desnoyers
2013-09-14 19:47 ` [PATCH 1/7] Move ntp variables into struct timekeeper_ntp Mathieu Desnoyers
2013-09-14 19:47 ` [PATCH 2/7] Move PPS variables into struct timekeeper_pps Mathieu Desnoyers
2013-09-14 19:47 ` [PATCH 3/7] Move ntp structure into struct timekeeper Mathieu Desnoyers
2013-09-14 19:47 ` [PATCH 4/7] Pass struct timekeeper_ntp as parameter from timekeeper to ntp Mathieu Desnoyers
2013-09-14 19:47 ` [PATCH 5/7] clocksource: add latch to clocksource Mathieu Desnoyers
2013-09-14 19:48 ` Mathieu Desnoyers [this message]
2013-09-14 19:48 ` [PATCH 7/7] Introduce timekeeper latch synchronization Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379188081-15613-7-git-send-email-mathieu.desnoyers@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®