All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: tglx@linutronix.de, john.stultz@linaro.org,
	daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com,
	aaro.koskinen@iki.fi, linux@armlinux.org.uk,
	mark.rutland@arm.com, marc.zyngier@arm.com
Cc: baolin.wang@linaro.org, broonie@kernel.org,
	paulmck@linux.vnet.ibm.com, mlichvar@redhat.com,
	rdunlap@infradead.org, kstewart@linuxfoundation.org,
	gregkh@linuxfoundation.org, pombredanne@nexb.com,
	thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de,
	linus.walleij@linaro.org, viresh.kumar@linaro.org,
	mingo@kernel.org, hpa@zytor.com, peterz@infradead.org,
	douly.fnst@cn.fujitsu.com, len.brown@intel.com,
	rajvi.jingar@intel.com, alexandre.belloni@bootlin.com,
	x86@kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org
Subject: [RFC PATCH 09/10] x86: tsc: Register the persistent clock
Date: Mon, 14 May 2018 16:55:35 +0800	[thread overview]
Message-ID: <3b626f6d7dd5ca047e6835b10c3a4e662db2539f.1526285602.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <cover.1526285602.git.baolin.wang@linaro.org>
In-Reply-To: <cover.1526285602.git.baolin.wang@linaro.org>

Register the tsc as one persistent clock to compensate the suspend time
if the tsc clocksource is always available.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 arch/x86/Kconfig      |    1 +
 arch/x86/kernel/tsc.c |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c07f492..667e3a7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -195,6 +195,7 @@ config X86
 	select USER_STACKTRACE_SUPPORT
 	select VIRT_TO_BUS
 	select X86_FEATURE_NAMES		if PROC_FS
+	select PERSISTENT_CLOCK
 
 config INSTRUCTION_DECODER
 	def_bool y
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 74392d9..dd8d7c3 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -11,6 +11,7 @@
 #include <linux/delay.h>
 #include <linux/clocksource.h>
 #include <linux/percpu.h>
+#include <linux/persistent_clock.h>
 #include <linux/timex.h>
 #include <linux/static_key.h>
 
@@ -1032,6 +1033,11 @@ static u64 read_tsc(struct clocksource *cs)
 	return (u64)rdtsc_ordered();
 }
 
+static u64 notrace tsc_read_persistent_clock(void)
+{
+	return (u64)rdtsc_ordered();
+}
+
 static void tsc_cs_mark_unstable(struct clocksource *cs)
 {
 	if (tsc_unstable)
@@ -1300,6 +1306,11 @@ static void tsc_refine_calibration_work(struct work_struct *work)
 	if (boot_cpu_has(X86_FEATURE_ART))
 		art_related_clocksource = &clocksource_tsc;
 	clocksource_register_khz(&clocksource_tsc, tsc_khz);
+
+	if (clocksource_tsc.flags & CLOCK_SOURCE_SUSPEND_NONSTOP)
+		persistent_clock_init_and_register(tsc_read_persistent_clock,
+						   CLOCKSOURCE_MASK(64),
+						   tsc_khz, 0);
 unreg:
 	clocksource_unregister(&clocksource_tsc_early);
 }
@@ -1327,6 +1338,11 @@ static int __init init_tsc_clocksource(void)
 		if (boot_cpu_has(X86_FEATURE_ART))
 			art_related_clocksource = &clocksource_tsc;
 		clocksource_register_khz(&clocksource_tsc, tsc_khz);
+
+		if (clocksource_tsc.flags & CLOCK_SOURCE_SUSPEND_NONSTOP)
+			persistent_clock_init_and_register(tsc_read_persistent_clock,
+							   CLOCKSOURCE_MASK(64),
+							   tsc_khz, 0);
 unreg:
 		clocksource_unregister(&clocksource_tsc_early);
 		return 0;
-- 
1.7.9.5

WARNING: multiple messages have this Message-ID (diff)
From: baolin.wang@linaro.org (Baolin Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 09/10] x86: tsc: Register the persistent clock
Date: Mon, 14 May 2018 16:55:35 +0800	[thread overview]
Message-ID: <3b626f6d7dd5ca047e6835b10c3a4e662db2539f.1526285602.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <cover.1526285602.git.baolin.wang@linaro.org>

Register the tsc as one persistent clock to compensate the suspend time
if the tsc clocksource is always available.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 arch/x86/Kconfig      |    1 +
 arch/x86/kernel/tsc.c |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c07f492..667e3a7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -195,6 +195,7 @@ config X86
 	select USER_STACKTRACE_SUPPORT
 	select VIRT_TO_BUS
 	select X86_FEATURE_NAMES		if PROC_FS
+	select PERSISTENT_CLOCK
 
 config INSTRUCTION_DECODER
 	def_bool y
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 74392d9..dd8d7c3 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -11,6 +11,7 @@
 #include <linux/delay.h>
 #include <linux/clocksource.h>
 #include <linux/percpu.h>
+#include <linux/persistent_clock.h>
 #include <linux/timex.h>
 #include <linux/static_key.h>
 
@@ -1032,6 +1033,11 @@ static u64 read_tsc(struct clocksource *cs)
 	return (u64)rdtsc_ordered();
 }
 
+static u64 notrace tsc_read_persistent_clock(void)
+{
+	return (u64)rdtsc_ordered();
+}
+
 static void tsc_cs_mark_unstable(struct clocksource *cs)
 {
 	if (tsc_unstable)
@@ -1300,6 +1306,11 @@ static void tsc_refine_calibration_work(struct work_struct *work)
 	if (boot_cpu_has(X86_FEATURE_ART))
 		art_related_clocksource = &clocksource_tsc;
 	clocksource_register_khz(&clocksource_tsc, tsc_khz);
+
+	if (clocksource_tsc.flags & CLOCK_SOURCE_SUSPEND_NONSTOP)
+		persistent_clock_init_and_register(tsc_read_persistent_clock,
+						   CLOCKSOURCE_MASK(64),
+						   tsc_khz, 0);
 unreg:
 	clocksource_unregister(&clocksource_tsc_early);
 }
@@ -1327,6 +1338,11 @@ static int __init init_tsc_clocksource(void)
 		if (boot_cpu_has(X86_FEATURE_ART))
 			art_related_clocksource = &clocksource_tsc;
 		clocksource_register_khz(&clocksource_tsc, tsc_khz);
+
+		if (clocksource_tsc.flags & CLOCK_SOURCE_SUSPEND_NONSTOP)
+			persistent_clock_init_and_register(tsc_read_persistent_clock,
+							   CLOCKSOURCE_MASK(64),
+							   tsc_khz, 0);
 unreg:
 		clocksource_unregister(&clocksource_tsc_early);
 		return 0;
-- 
1.7.9.5

  parent reply	other threads:[~2018-05-14  8:55 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14  8:55 [RFC PATCH 00/10] Add persistent clock support Baolin Wang
2018-05-14  8:55 ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 01/10] time: " Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 02/10] clocksource: sprd: Add one persistent timer for Spreadtrum platform Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 03/10] arm: omap: Convert 32K counter to use persistent clock Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 04/10] clocksource: tegra20_timer: Remove register_persistent_clock() API Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 05/10] arm: time: Remove the persistent clock support for ARM Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 06/10] clocksource: arm_arch_timer: Register the persistent clock Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 07/10] clocksource: timer-ti-32k: " Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 08/10] clocksource: time-pistachio: " Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-14  8:55 ` Baolin Wang [this message]
2018-05-14  8:55   ` [RFC PATCH 09/10] x86: tsc: " Baolin Wang
2018-05-14  8:55 ` [RFC PATCH 10/10] time: timekeeping: Remove time compensating from nonstop clocksources Baolin Wang
2018-05-14  8:55   ` Baolin Wang
2018-05-15 10:27 ` [RFC PATCH 00/10] Add persistent clock support Daniel Lezcano
2018-05-15 10:27   ` Daniel Lezcano
2018-05-16  2:20   ` Baolin Wang
2018-05-16  2:20     ` Baolin Wang
2018-05-16  2:20     ` Baolin Wang
2018-05-16  7:11     ` Baolin Wang
2018-05-16  7:11       ` Baolin Wang
2018-05-16  7:11       ` Baolin Wang
2018-05-15 13:56 ` Daniel Lezcano
2018-05-15 13:56   ` Daniel Lezcano
2018-05-16  2:58   ` Baolin Wang
2018-05-16  2:58     ` Baolin Wang
2018-05-16  2:58     ` Baolin Wang

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=3b626f6d7dd5ca047e6835b10c3a4e662db2539f.1526285602.git.baolin.wang@linaro.org \
    --to=baolin.wang@linaro.org \
    --cc=aaro.koskinen@iki.fi \
    --cc=alexandre.belloni@bootlin.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=douly.fnst@cn.fujitsu.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=jonathanh@nvidia.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=pombredanne@nexb.com \
    --cc=rajvi.jingar@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=tony@atomide.com \
    --cc=viresh.kumar@linaro.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.