linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] timekeeping: Add persistent_clock_exist flag
@ 2012-12-13  2:05 Feng Tang
  2012-12-13  2:05 ` [PATCH 2/3] rtc: Skip the suspend/resume handling if persistent clock exist Feng Tang
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Feng Tang @ 2012-12-13  2:05 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Alessandro Zummo, linux-kernel
  Cc: alek.du, Feng Tang

In current kernel, there are several places which need to check
whether there is a persistent clock for the platform. Current check
is done by calling the read_persistent_clock() and validating the
return value.

Add such a flag to make code more readable and call read_persistent_clock()
only once for all the checks.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: Feng Tang <feng.tang@intel.com>
---
 include/linux/time.h      |    1 +
 kernel/time/timekeeping.c |   15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 4d358e9..19388ad 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -115,6 +115,7 @@ static inline bool timespec_valid_strict(const struct timespec *ts)
 	return true;
 }
 
+extern int persistent_clock_exist;
 extern void read_persistent_clock(struct timespec *ts);
 extern void read_boot_clock(struct timespec *ts);
 extern int update_persistent_clock(struct timespec now);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4c7de02..b82f218 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -28,6 +28,9 @@ static struct timekeeper timekeeper;
 /* flag for if timekeeping is suspended */
 int __read_mostly timekeeping_suspended;
 
+/* Flag for if there is a persistent clock on this platform */
+int __read_mostly persistent_clock_exist;
+
 static inline void tk_normalize_xtime(struct timekeeper *tk)
 {
 	while (tk->xtime_nsec >= ((u64)NSEC_PER_SEC << tk->shift)) {
@@ -590,12 +593,14 @@ void __init timekeeping_init(void)
 	struct timespec now, boot, tmp;
 
 	read_persistent_clock(&now);
+
 	if (!timespec_valid_strict(&now)) {
 		pr_warn("WARNING: Persistent clock returned invalid value!\n"
 			"         Check your CMOS/BIOS settings.\n");
 		now.tv_sec = 0;
 		now.tv_nsec = 0;
-	}
+	} else if (now.tv_sec || now.tv_nsec)
+		persistent_clock_exist = 1;
 
 	read_boot_clock(&boot);
 	if (!timespec_valid_strict(&boot)) {
@@ -670,9 +675,11 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
 	unsigned long flags;
 	struct timespec ts;
 
-	/* Make sure we don't set the clock twice */
-	read_persistent_clock(&ts);
-	if (!(ts.tv_sec == 0 && ts.tv_nsec == 0))
+	/*
+	 * Make sure we don't set the clock twice, as timekeeping_resume()
+	 * already did it
+	 */
+	if (persistent_clock_exist)
 		return;
 
 	write_seqlock_irqsave(&tk->lock, flags);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-12-20  7:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13  2:05 [PATCH 1/3] timekeeping: Add persistent_clock_exist flag Feng Tang
2012-12-13  2:05 ` [PATCH 2/3] rtc: Skip the suspend/resume handling if persistent clock exist Feng Tang
2012-12-13  2:05 ` [PATCH 3/3] rtc: Skip setting xtime if persisent " Feng Tang
2012-12-14  1:20 ` [PATCH 1/3] timekeeping: Add persistent_clock_exist flag John Stultz
2012-12-14  1:37   ` Feng Tang
2012-12-14  2:00     ` John Stultz
2012-12-14  2:15       ` Feng Tang
2012-12-14  2:38       ` Jason Gunthorpe
2012-12-14  3:13         ` Feng Tang
2012-12-14  4:10           ` Jason Gunthorpe
2012-12-14 21:22             ` John Stultz
2012-12-14 21:56               ` Jason Gunthorpe
2012-12-14 23:23                 ` John Stultz
2012-12-17 16:14                 ` Feng Tang
2012-12-17 18:22                   ` Jason Gunthorpe
2012-12-18  2:44                     ` Feng Tang
2012-12-14 21:36         ` John Stultz
2012-12-20  7:02         ` Feng Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).