All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] Convert remaining arches to use read/update_persistent_clock
@ 2010-03-04  3:57 John Stultz
  2010-03-04  3:57 ` [PATCH 01/14] alpha: Convert alpha " John Stultz
  0 siblings, 1 reply; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz

A number of arches have moved over to using the generic read_persisitent_clock
or update_persisitent_clock implementations instead of manipulating xtime
themselves.

This patchset tries to convert the remaining arches over and will allow for
further generic timekeeping cleanups.

There is some issues where the RTC/persistent clock is behind a bus that requires
irqs to access. This patch is not trying to handle those cases, and instead is just
using whatever method was used at time_init to initialize xtime.

I sent this set out back in December to only a bit of discussion (many thanks to 
the testers who provided feedback!). But I wanted to send it out again to try to 
get this moving again.

Any feedback or comments would be appreciated.

thanks
-john


John Stultz (14):
  alpha: Convert alpha to use read/update_persistent_clock
  mn10300: Convert mn10300 to use read/update_persistent_clock
  frv: Convert frv to use read/update_persistent_clock
  parisc: Convert parisc to use read/update_persistent_clock
  h8300: Convert h8300 to use read/update_persistent_clock
  avr32: Convert avr32 to use read/update_persistent_clock
  ia64: Convert ia64 to use read/update_persistent_clock
  sh: Convert sh to use read/update_persistent_clock
  blackfin: Convert blackfin to use read/update_persistent_clock
  m32r: Convert m32r to use read/update_peristent_clock
  m68k: Convert m68k to use read/update_persistent_clock
  sparc: Convert sparc to use read/update_persistent_clock
  cris: Convert cris to use read/update_persistent_clock
  arm: Convert arm to use read_persistent_clock

 arch/alpha/Kconfig               |    3 +
 arch/alpha/kernel/time.c         |  101 ++++++++++++++++++--------------------
 arch/arm/Kconfig                 |    3 +
 arch/arm/kernel/time.c           |    7 +++
 arch/avr32/kernel/time.c         |   12 ++--
 arch/blackfin/kernel/time-ts.c   |   13 +++--
 arch/blackfin/kernel/time.c      |   39 ++------------
 arch/cris/Kconfig                |    3 +
 arch/cris/arch-v10/kernel/time.c |   37 +-------------
 arch/cris/arch-v32/kernel/time.c |   40 +--------------
 arch/cris/kernel/time.c          |   20 ++++---
 arch/frv/kernel/time.c           |   34 +++----------
 arch/h8300/kernel/time.c         |   10 +++-
 arch/ia64/kernel/time.c          |   12 ++---
 arch/m32r/kernel/time.c          |   47 +++---------------
 arch/m68k/kernel/time.c          |   11 +++--
 arch/mn10300/Kconfig             |    3 +
 arch/mn10300/kernel/rtc.c        |   27 ++--------
 arch/mn10300/kernel/time.c       |    4 --
 arch/parisc/kernel/time.c        |   29 +++++------
 arch/sh/kernel/time.c            |    6 +--
 arch/sparc/Kconfig               |    2 +-
 arch/sparc/kernel/time_32.c      |   15 ++----
 23 files changed, 158 insertions(+), 320 deletions(-)


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

* [PATCH 01/14] alpha: Convert alpha to use read/update_persistent_clock
  2010-03-04  3:57 [PATCH 00/14] Convert remaining arches to use read/update_persistent_clock John Stultz
@ 2010-03-04  3:57 ` John Stultz
  2010-03-04  3:57   ` [PATCH 02/14] mn10300: Convert mn10300 " John Stultz
  2010-03-13  0:19   ` [tip:timers/cleanup] alpha: Convert alpha " tip-bot for John Stultz
  0 siblings, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Richard Henderson, Thomas Gleixner, Andrew Morton

This patch converts the alpha architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/alpha/Kconfig       |    3 +
 arch/alpha/kernel/time.c |  101 +++++++++++++++++++++------------------------
 2 files changed, 50 insertions(+), 54 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index bd7261e..75fff7e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -54,6 +54,9 @@ config ARCH_USES_GETTIMEOFFSET
 	bool
 	default y
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config ZONE_DMA
 	bool
 	default y
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index 5d08266..5465e93 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -75,8 +75,6 @@ static struct {
 	__u32 last_time;
 	/* ticks/cycle * 2^48 */
 	unsigned long scaled_ticks_per_cycle;
-	/* last time the CMOS clock got updated */
-	time_t last_rtc_update;
 	/* partial unused tick */
 	unsigned long partial_tick;
 } state;
@@ -91,6 +89,52 @@ static inline __u32 rpcc(void)
     return result;
 }
 
+int update_persistent_clock(struct timespec now)
+{
+	return set_rtc_mmss(now.tv_sec);
+}
+
+void read_persistent_clock(struct timespec *ts)
+{
+	unsigned int year, mon, day, hour, min, sec, epoch;
+
+	sec = CMOS_READ(RTC_SECONDS);
+	min = CMOS_READ(RTC_MINUTES);
+	hour = CMOS_READ(RTC_HOURS);
+	day = CMOS_READ(RTC_DAY_OF_MONTH);
+	mon = CMOS_READ(RTC_MONTH);
+	year = CMOS_READ(RTC_YEAR);
+
+	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+		sec = bcd2bin(sec);
+		min = bcd2bin(min);
+		hour = bcd2bin(hour);
+		day = bcd2bin(day);
+		mon = bcd2bin(mon);
+		year = bcd2bin(year);
+	}
+
+	/* PC-like is standard; used for year >= 70 */
+	epoch = 1900;
+	if (year < 20)
+		epoch = 2000;
+	else if (year >= 20 && year < 48)
+		/* NT epoch */
+		epoch = 1980;
+	else if (year >= 48 && year < 70)
+		/* Digital UNIX epoch */
+		epoch = 1952;
+
+	printk(KERN_INFO "Using epoch = %d\n", epoch);
+
+	if ((year += epoch) < 1970)
+		year += 100;
+
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+}
+
+
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -123,19 +167,6 @@ irqreturn_t timer_interrupt(int irq, void *dev)
 	if (nticks)
 		do_timer(nticks);
 
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	if (ntp_synced()
-	    && xtime.tv_sec > state.last_rtc_update + 660
-	    && xtime.tv_nsec >= 500000 - ((unsigned) TICK_SIZE) / 2
-	    && xtime.tv_nsec <= 500000 + ((unsigned) TICK_SIZE) / 2) {
-		int tmp = set_rtc_mmss(xtime.tv_sec);
-		state.last_rtc_update = xtime.tv_sec - (tmp ? 600 : 0);
-	}
-
 	write_sequnlock(&xtime_lock);
 
 #ifndef CONFIG_SMP
@@ -304,7 +335,7 @@ rpcc_after_update_in_progress(void)
 void __init
 time_init(void)
 {
-	unsigned int year, mon, day, hour, min, sec, cc1, cc2, epoch;
+	unsigned int cc1, cc2;
 	unsigned long cycle_freq, tolerance;
 	long diff;
 
@@ -348,43 +379,6 @@ time_init(void)
 	   bogomips yet, but this is close on a 500Mhz box.  */
 	__delay(1000000);
 
-	sec = CMOS_READ(RTC_SECONDS);
-	min = CMOS_READ(RTC_MINUTES);
-	hour = CMOS_READ(RTC_HOURS);
-	day = CMOS_READ(RTC_DAY_OF_MONTH);
-	mon = CMOS_READ(RTC_MONTH);
-	year = CMOS_READ(RTC_YEAR);
-
-	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-		sec = bcd2bin(sec);
-		min = bcd2bin(min);
-		hour = bcd2bin(hour);
-		day = bcd2bin(day);
-		mon = bcd2bin(mon);
-		year = bcd2bin(year);
-	}
-
-	/* PC-like is standard; used for year >= 70 */
-	epoch = 1900;
-	if (year < 20)
-		epoch = 2000;
-	else if (year >= 20 && year < 48)
-		/* NT epoch */
-		epoch = 1980;
-	else if (year >= 48 && year < 70)
-		/* Digital UNIX epoch */
-		epoch = 1952;
-
-	printk(KERN_INFO "Using epoch = %d\n", epoch);
-
-	if ((year += epoch) < 1970)
-		year += 100;
-
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
-
-        wall_to_monotonic.tv_sec -= xtime.tv_sec;
-        wall_to_monotonic.tv_nsec = 0;
 
 	if (HZ > (1<<16)) {
 		extern void __you_loose (void);
@@ -394,7 +388,6 @@ time_init(void)
 	state.last_time = cc1;
 	state.scaled_ticks_per_cycle
 		= ((unsigned long) HZ << FIX_SHIFT) / cycle_freq;
-	state.last_rtc_update = 0;
 	state.partial_tick = 0L;
 
 	/* Startup the timer source. */
-- 
1.6.0.4


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

* [PATCH 02/14] mn10300: Convert mn10300 to use read/update_persistent_clock
  2010-03-04  3:57 ` [PATCH 01/14] alpha: Convert alpha " John Stultz
@ 2010-03-04  3:57   ` John Stultz
  2010-03-04  3:57     ` [PATCH 03/14] frv: Convert frv " John Stultz
  2010-03-13  0:19     ` [tip:timers/cleanup] mn10300: Convert mn10300 " tip-bot for John Stultz
  2010-03-13  0:19   ` [tip:timers/cleanup] alpha: Convert alpha " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml
  Cc: John Stultz, David Howells, Koichi Yasutake, Thomas Gleixner,
	Andrew Morton

This patch converts the mn10300 architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/mn10300/Kconfig       |    3 +++
 arch/mn10300/kernel/rtc.c  |   27 +++++----------------------
 arch/mn10300/kernel/time.c |    4 ----
 3 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 89faaca..1c4565a 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -37,6 +37,9 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
 config GENERIC_CALIBRATE_DELAY
 	def_bool y
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config GENERIC_FIND_NEXT_BIT
 	def_bool y
 
diff --git a/arch/mn10300/kernel/rtc.c b/arch/mn10300/kernel/rtc.c
index 7978470..815a933 100644
--- a/arch/mn10300/kernel/rtc.c
+++ b/arch/mn10300/kernel/rtc.c
@@ -26,17 +26,15 @@ static long last_rtc_update;
 /* time for RTC to update itself in ioclks */
 static unsigned long mn10300_rtc_update_period;
 
-/*
- * read the current RTC time
- */
-unsigned long __init get_initial_rtc_time(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	struct rtc_time tm;
 
 	get_rtc_time(&tm);
 
-	return mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
+	ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
 		      tm.tm_hour, tm.tm_min, tm.tm_sec);
+	ts->tv_nsec = 0;
 }
 
 /*
@@ -110,24 +108,9 @@ static int set_rtc_mmss(unsigned long nowtime)
 	return retval;
 }
 
-void check_rtc_time(void)
+int update_persistent_clock(struct timespec now)
 {
-	/* the RTC clock just finished ticking over again this second
-	 * - if we have an externally synchronized Linux clock, then update
-	 *   RTC clock accordingly every ~11 minutes. set_rtc_mmss() has to be
-	 *   called as close as possible to 500 ms before the new second starts.
-	 */
-	if ((time_status & STA_UNSYNC) == 0 &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    xtime.tv_nsec / 1000 >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-	    xtime.tv_nsec / 1000 <= 500000 + ((unsigned) TICK_SIZE) / 2
-	    ) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* do it again in 60s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
+	return set_rtc_mms(now.tv_sec);
 }
 
 /*
diff --git a/arch/mn10300/kernel/time.c b/arch/mn10300/kernel/time.c
index 395caf0..8f7f6d2 100644
--- a/arch/mn10300/kernel/time.c
+++ b/arch/mn10300/kernel/time.c
@@ -111,7 +111,6 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
 		/* advance the kernel's time tracking system */
 		profile_tick(CPU_PROFILING);
 		do_timer(1);
-		check_rtc_time();
 	}
 
 	write_sequnlock(&xtime_lock);
@@ -139,9 +138,6 @@ void __init time_init(void)
 	       " (calibrated against RTC)\n",
 	       MN10300_TSCCLK / 1000000, (MN10300_TSCCLK / 10000) % 100);
 
-	xtime.tv_sec = get_initial_rtc_time();
-	xtime.tv_nsec = 0;
-
 	mn10300_last_tsc = TMTSCBC;
 
 	/* use timer 0 & 1 cascaded to tick at as close to HZ as possible */
-- 
1.6.0.4


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

* [PATCH 03/14] frv: Convert frv to use read/update_persistent_clock
  2010-03-04  3:57   ` [PATCH 02/14] mn10300: Convert mn10300 " John Stultz
@ 2010-03-04  3:57     ` John Stultz
  2010-03-04  3:57       ` [PATCH 04/14] parisc: Convert parisc " John Stultz
  2010-03-13  0:19       ` [tip:timers/cleanup] frv: Convert frv " tip-bot for John Stultz
  2010-03-13  0:19     ` [tip:timers/cleanup] mn10300: Convert mn10300 " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, David Howells, Thomas Gleixner, Andrew Morton

This patch converts the frv architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: David Howells <dhowells@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/frv/kernel/time.c |   34 +++++++---------------------------
 1 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/arch/frv/kernel/time.c b/arch/frv/kernel/time.c
index fb0ce75..0ddbbae 100644
--- a/arch/frv/kernel/time.c
+++ b/arch/frv/kernel/time.c
@@ -48,20 +48,12 @@ static struct irqaction timer_irq  = {
 	.name = "timer",
 };
 
-static inline int set_rtc_mmss(unsigned long nowtime)
-{
-	return -1;
-}
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
 static irqreturn_t timer_interrupt(int irq, void *dummy)
 {
-	/* last time the cmos clock got updated */
-	static long last_rtc_update = 0;
-
 	profile_tick(CPU_PROFILING);
 	/*
 	 * Here we are in the timer irq handler. We just have irqs locally
@@ -74,22 +66,6 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
 
 	do_timer(1);
 
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2
-	    ) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
-	}
-
 #ifdef CONFIG_HEARTBEAT
 	static unsigned short n;
 	n++;
@@ -119,7 +95,8 @@ void time_divisor_init(void)
 	__set_TCSR_DATA(0, base >> 8);
 }
 
-void time_init(void)
+
+void read_persistent_clock(struct timespec *ts)
 {
 	unsigned int year, mon, day, hour, min, sec;
 
@@ -135,9 +112,12 @@ void time_init(void)
 
 	if ((year += 1900) < 1970)
 		year += 100;
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+	ts->tv_nsec = 0;
+}
 
+void time_init(void)
+{
 	/* install scheduling interrupt handler */
 	setup_irq(IRQ_CPU_TIMER0, &timer_irq);
 
-- 
1.6.0.4


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

* [PATCH 04/14] parisc: Convert parisc to use read/update_persistent_clock
  2010-03-04  3:57     ` [PATCH 03/14] frv: Convert frv " John Stultz
@ 2010-03-04  3:57       ` John Stultz
  2010-03-04  3:57         ` [PATCH 05/14] h8300: Convert h8300 " John Stultz
  2010-03-06 22:40         ` [PATCH 04/14] parisc: Convert parisc " Helge Deller
  2010-03-13  0:19       ` [tip:timers/cleanup] frv: Convert frv " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml
  Cc: John Stultz, Kyle McMartin, Helge Deller, Thomas Gleixner, Andrew Morton

This patch converts the parisc architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/parisc/kernel/time.c |   29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index a79c6f9..05511cc 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -250,9 +250,21 @@ static int __init rtc_init(void)
 }
 module_init(rtc_init);
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	static struct pdc_tod tod_data;
+	if (pdc_tod_read(&tod_data) == 0) {
+		ts->tv_sec = tod_data.tod_sec;
+		ts->tv_nsec = tod_data.tod_usec * 1000;
+	} else {
+		printk(KERN_ERR "Error reading tod clock\n");
+	        ts->tv_sec = 0;
+		ts->tv_nsec = 0;
+	}
+}
+
+void __init time_init(void)
+{
 	unsigned long current_cr16_khz;
 
 	clocktick = (100 * PAGE0->mem_10msec) / HZ;
@@ -264,19 +276,4 @@ void __init time_init(void)
 	clocksource_cr16.mult = clocksource_khz2mult(current_cr16_khz,
 						clocksource_cr16.shift);
 	clocksource_register(&clocksource_cr16);
-
-	if (pdc_tod_read(&tod_data) == 0) {
-		unsigned long flags;
-
-		write_seqlock_irqsave(&xtime_lock, flags);
-		xtime.tv_sec = tod_data.tod_sec;
-		xtime.tv_nsec = tod_data.tod_usec * 1000;
-		set_normalized_timespec(&wall_to_monotonic,
-		                        -xtime.tv_sec, -xtime.tv_nsec);
-		write_sequnlock_irqrestore(&xtime_lock, flags);
-	} else {
-		printk(KERN_ERR "Error reading tod clock\n");
-	        xtime.tv_sec = 0;
-		xtime.tv_nsec = 0;
-	}
 }
-- 
1.6.0.4


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

* [PATCH 05/14] h8300: Convert h8300 to use read/update_persistent_clock
  2010-03-04  3:57       ` [PATCH 04/14] parisc: Convert parisc " John Stultz
@ 2010-03-04  3:57         ` John Stultz
  2010-03-04  3:57           ` [PATCH 06/14] avr32: Convert avr32 " John Stultz
  2010-03-13  0:20           ` [tip:timers/cleanup] h8300: Convert h8300 " tip-bot for John Stultz
  2010-03-06 22:40         ` [PATCH 04/14] parisc: Convert parisc " Helge Deller
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Yoshinori Sato, Thomas Gleixner, Andrew Morton

This patch converts the h8300  architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/h8300/kernel/time.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c
index 7f2d6cf..165005a 100644
--- a/arch/h8300/kernel/time.c
+++ b/arch/h8300/kernel/time.c
@@ -41,7 +41,7 @@ void h8300_timer_tick(void)
 	update_process_times(user_mode(get_irq_regs()));
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	unsigned int year, mon, day, hour, min, sec;
 
@@ -56,8 +56,12 @@ void __init time_init(void)
 #endif
 	if ((year += 1900) < 1970)
 		year += 100;
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+	ts->tv_nsec = 0;
+}
+
+void __init time_init(void)
+{
 
 	h8300_timer_setup();
 }
-- 
1.6.0.4


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

* [PATCH 06/14] avr32: Convert avr32 to use read/update_persistent_clock
  2010-03-04  3:57         ` [PATCH 05/14] h8300: Convert h8300 " John Stultz
@ 2010-03-04  3:57           ` John Stultz
  2010-03-04  3:57             ` [PATCH 07/14] ia64: Convert ia64 " John Stultz
  2010-03-13  0:20             ` [tip:timers/cleanup] avr32: Convert avr32 " tip-bot for John Stultz
  2010-03-13  0:20           ` [tip:timers/cleanup] h8300: Convert h8300 " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Haavard Skinnemoen, Thomas Gleixner, Andrew Morton

This patch converts the avr32 architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/avr32/kernel/time.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index f27aa3b..a047d69 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -110,17 +110,17 @@ static struct clock_event_device comparator = {
 	.set_mode	= comparator_mode,
 };
 
+void read_persistent_clock(struct timespec *ts)
+{
+	ts->tv.sec = mktime(2007, 1, 1, 0, 0, 0);
+	ts->tv_nsec = 0;
+}
+
 void __init time_init(void)
 {
 	unsigned long counter_hz;
 	int ret;
 
-	xtime.tv_sec = mktime(2007, 1, 1, 0, 0, 0);
-	xtime.tv_nsec = 0;
-
-	set_normalized_timespec(&wall_to_monotonic,
-				-xtime.tv_sec, -xtime.tv_nsec);
-
 	/* figure rate for counter */
 	counter_hz = clk_get_rate(boot_cpu_data.clk);
 	counter.mult = clocksource_hz2mult(counter_hz, counter.shift);
-- 
1.6.0.4


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

* [PATCH 07/14] ia64: Convert ia64 to use read/update_persistent_clock
  2010-03-04  3:57           ` [PATCH 06/14] avr32: Convert avr32 " John Stultz
@ 2010-03-04  3:57             ` John Stultz
  2010-03-04  3:57               ` [PATCH 08/14] sh: Convert sh " John Stultz
  2010-03-13  0:20               ` [tip:timers/cleanup] ia64: Convert ia64 " tip-bot for John Stultz
  2010-03-13  0:20             ` [tip:timers/cleanup] avr32: Convert avr32 " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Tony Luck, Fenghua Yu, Thomas Gleixner, Andrew Morton

This patch converts the ia64  architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/ia64/kernel/time.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 47a1927..653b3c4 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -430,18 +430,16 @@ static int __init rtc_init(void)
 }
 module_init(rtc_init);
 
+void read_persistent_clock(struct timespec *ts)
+{
+	efi_gettimeofday(ts);
+}
+
 void __init
 time_init (void)
 {
 	register_percpu_irq(IA64_TIMER_VECTOR, &timer_irqaction);
-	efi_gettimeofday(&xtime);
 	ia64_init_itm();
-
-	/*
-	 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
-	 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
-	 */
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 }
 
 /*
-- 
1.6.0.4


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

* [PATCH 08/14] sh: Convert sh to use read/update_persistent_clock
  2010-03-04  3:57             ` [PATCH 07/14] ia64: Convert ia64 " John Stultz
@ 2010-03-04  3:57               ` John Stultz
  2010-03-04  3:57                 ` [PATCH 09/14] blackfin: Convert blackfin " John Stultz
  2010-03-04 17:00                 ` [PATCH 08/14] sh: Convert sh " Paul Mundt
  2010-03-13  0:20               ` [tip:timers/cleanup] ia64: Convert ia64 " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Paul Mundt, Thomas Gleixner, Andrew Morton

This patch converts the sh architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/sh/kernel/time.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index 953fa16..8a0072d 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -39,12 +39,12 @@ static int null_rtc_set_time(const time_t secs)
 void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
 int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;
 
-#ifdef CONFIG_GENERIC_CMOS_UPDATE
 void read_persistent_clock(struct timespec *ts)
 {
 	rtc_sh_get_time(ts);
 }
 
+#ifdef CONFIG_GENERIC_CMOS_UPDATE
 int update_persistent_clock(struct timespec now)
 {
 	return rtc_sh_set_time(now.tv_sec);
@@ -113,9 +113,5 @@ void __init time_init(void)
 	hwblk_init();
 	clk_init();
 
-	rtc_sh_get_time(&xtime);
-	set_normalized_timespec(&wall_to_monotonic,
-				-xtime.tv_sec, -xtime.tv_nsec);
-
 	late_time_init = sh_late_time_init;
 }
-- 
1.6.0.4


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

* [PATCH 09/14] blackfin: Convert blackfin to use read/update_persistent_clock
  2010-03-04  3:57               ` [PATCH 08/14] sh: Convert sh " John Stultz
@ 2010-03-04  3:57                 ` John Stultz
  2010-03-04  3:57                   ` [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock John Stultz
                                     ` (2 more replies)
  2010-03-04 17:00                 ` [PATCH 08/14] sh: Convert sh " Paul Mundt
  1 sibling, 3 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Mike Frysinger, Thomas Gleixner, Andrew Morton

This patch converts the blackfin architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/blackfin/kernel/time-ts.c |   13 +++++++------
 arch/blackfin/kernel/time.c    |   39 ++++++---------------------------------
 2 files changed, 13 insertions(+), 39 deletions(-)

diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 17c38c5..08dd3e8 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -348,9 +348,15 @@ static int __init bfin_clockevent_init(void)
 	return 0;
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60;	/* 1 Jan 2007 */
+	ts->tv_sec = secs_since_1970;
+	ts->tv_nsec = 0;
+}
+
+void __init time_init(void)
+{
 
 #ifdef CONFIG_RTC_DRV_BFIN
 	/* [#2663] hack to filter junk RTC values that would cause
@@ -363,11 +369,6 @@ void __init time_init(void)
 	}
 #endif
 
-	/* Initialize xtime. From now on, xtime is updated with timer interrupts */
-	xtime.tv_sec = secs_since_1970;
-	xtime.tv_nsec = 0;
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
-
 	bfin_cs_cycles_init();
 	bfin_cs_gptimer0_init();
 	bfin_clockevent_init();
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c
index 13c1ee3..c911361 100644
--- a/arch/blackfin/kernel/time.c
+++ b/arch/blackfin/kernel/time.c
@@ -112,11 +112,6 @@ u32 arch_gettimeoffset(void)
 }
 #endif
 
-static inline int set_rtc_mmss(unsigned long nowtime)
-{
-	return 0;
-}
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -126,29 +121,8 @@ __attribute__((l1_text))
 #endif
 irqreturn_t timer_interrupt(int irq, void *dummy)
 {
-	/* last time the cmos clock got updated */
-	static long last_rtc_update;
-
 	write_seqlock(&xtime_lock);
 	do_timer(1);
-
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / NSEC_PER_USEC) >=
-	    500000 - ((unsigned)TICK_SIZE) / 2
-	    && (xtime.tv_nsec / NSEC_PER_USEC) <=
-	    500000 + ((unsigned)TICK_SIZE) / 2) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* Do it again in 60s. */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
 	write_sequnlock(&xtime_lock);
 
 #ifdef CONFIG_IPIPE
@@ -161,10 +135,15 @@ irqreturn_t timer_interrupt(int irq, void *dummy)
 	return IRQ_HANDLED;
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60;	/* 1 Jan 2007 */
+	ts->tv_sec = secs_since_1970;
+	ts->tv_nsec = 0;
+}
 
+void __init time_init(void)
+{
 #ifdef CONFIG_RTC_DRV_BFIN
 	/* [#2663] hack to filter junk RTC values that would cause
 	 * userspace to have to deal with time values greater than
@@ -176,11 +155,5 @@ void __init time_init(void)
 	}
 #endif
 
-	/* Initialize xtime. From now on, xtime is updated with timer interrupts */
-	xtime.tv_sec = secs_since_1970;
-	xtime.tv_nsec = 0;
-
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
-
 	time_sched_init(timer_interrupt);
 }
-- 
1.6.0.4


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

* [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock
  2010-03-04  3:57                 ` [PATCH 09/14] blackfin: Convert blackfin " John Stultz
@ 2010-03-04  3:57                   ` John Stultz
  2010-03-04  3:57                     ` [PATCH 11/14] m68k: Convert m68k to use read/update_persistent_clock John Stultz
  2010-03-13  0:21                     ` [tip:timers/cleanup] m32r: Convert m32r to use read/update_peristent_clock tip-bot for John Stultz
  2010-03-09 23:53                   ` [PATCH 09/14] blackfin: Convert blackfin to use read/update_persistent_clock Mike Frysinger
  2010-03-13  0:20                   ` [tip:timers/cleanup] " tip-bot for John Stultz
  2 siblings, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Hirokazu Takata, Thomas Gleixner, Andrew Morton

This patch converts the m32r  architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/m32r/kernel/time.c |   47 +++++++----------------------------------------
 1 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c
index 9cedcef..bda8682 100644
--- a/arch/m32r/kernel/time.c
+++ b/arch/m32r/kernel/time.c
@@ -106,24 +106,6 @@ u32 arch_gettimeoffset(void)
 }
 
 /*
- * In order to set the CMOS clock precisely, set_rtc_mmss has to be
- * called 500 ms after the second nowtime has started, because when
- * nowtime is written into the registers of the CMOS clock, it will
- * jump to the next second precisely 500 ms later. Check the Motorola
- * MC146818A or Dallas DS12887 data sheet for details.
- *
- * BUG: This routine does not handle hour overflow properly; it just
- *      sets the minutes. Usually you won't notice until after reboot!
- */
-static inline int set_rtc_mmss(unsigned long nowtime)
-{
-	return 0;
-}
-
-/* last time the cmos clock got updated */
-static long last_rtc_update = 0;
-
-/*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
@@ -138,23 +120,6 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
 #ifndef CONFIG_SMP
 	update_process_times(user_mode(get_irq_regs()));
 #endif
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	write_seqlock(&xtime_lock);
-	if (ntp_synced()
-		&& xtime.tv_sec > last_rtc_update + 660
-		&& (xtime.tv_nsec / 1000) >= 500000 - ((unsigned)TICK_SIZE) / 2
-		&& (xtime.tv_nsec / 1000) <= 500000 + ((unsigned)TICK_SIZE) / 2)
-	{
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else	/* do it again in 60 s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
-	write_sequnlock(&xtime_lock);
 	/* As we return to user mode fire off the other CPU schedulers..
 	   this is basically because we don't yet share IRQ's around.
 	   This message is rigged to be safe on the 386 - basically it's
@@ -174,7 +139,7 @@ static struct irqaction irq0 = {
 	.name = "MFT2",
 };
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	unsigned int epoch, year, mon, day, hour, min, sec;
 
@@ -194,11 +159,13 @@ void __init time_init(void)
 		epoch = 1952;
 	year += epoch;
 
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
-	set_normalized_timespec(&wall_to_monotonic,
-		-xtime.tv_sec, -xtime.tv_nsec);
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+	ts->tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+}
 
+
+void __init time_init(void)
+{
 #if defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_XNUX2) \
 	|| defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_M32700) \
 	|| defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104)
-- 
1.6.0.4


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

* [PATCH 11/14] m68k: Convert m68k to use read/update_persistent_clock
  2010-03-04  3:57                   ` [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock John Stultz
@ 2010-03-04  3:57                     ` John Stultz
  2010-03-04  3:57                       ` [PATCH 12/14] sparc: Convert sparc " John Stultz
  2010-03-13  0:21                       ` [tip:timers/cleanup] m68k: Convert m68k " tip-bot for John Stultz
  2010-03-13  0:21                     ` [tip:timers/cleanup] m32r: Convert m32r to use read/update_peristent_clock tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Geert Uytterhoeven, Thomas Gleixner, Andrew Morton

This patch converts the m68k architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/m68k/kernel/time.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 17dc2a3..4926b38 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -73,21 +73,24 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
 	return IRQ_HANDLED;
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	struct rtc_time time;
+	ts->tv_sec = 0;
+	ts->tv_nsec = 0;
 
 	if (mach_hwclk) {
 		mach_hwclk(0, &time);
 
 		if ((time.tm_year += 1900) < 1970)
 			time.tm_year += 100;
-		xtime.tv_sec = mktime(time.tm_year, time.tm_mon, time.tm_mday,
+		ts->tv_sec = mktime(time.tm_year, time.tm_mon, time.tm_mday,
 				      time.tm_hour, time.tm_min, time.tm_sec);
-		xtime.tv_nsec = 0;
 	}
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
+}
 
+void __init time_init(void)
+{
 	mach_sched_init(timer_interrupt);
 }
 
-- 
1.6.0.4


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

* [PATCH 12/14] sparc: Convert sparc to use read/update_persistent_clock
  2010-03-04  3:57                     ` [PATCH 11/14] m68k: Convert m68k to use read/update_persistent_clock John Stultz
@ 2010-03-04  3:57                       ` John Stultz
  2010-03-04  3:57                         ` [PATCH 13/14] cris: Convert cris " John Stultz
  2010-03-04  6:41                         ` [PATCH 12/14] sparc: Convert sparc " David Miller
  2010-03-13  0:21                       ` [tip:timers/cleanup] m68k: Convert m68k " tip-bot for John Stultz
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, David S. Miller", Thomas Gleixner, Andrew Morton

This patch converts the sparc architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/sparc/Kconfig          |    2 +-
 arch/sparc/kernel/time_32.c |   15 +++++----------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 4097f6a..0e8ec2a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -72,7 +72,7 @@ config ARCH_USES_GETTIMEOFFSET
 
 config GENERIC_CMOS_UPDATE
 	bool
-	default y if SPARC64
+	default y
 
 config GENERIC_CLOCKEVENTS
 	bool
diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c
index 0d4c09b..a3f1690 100644
--- a/arch/sparc/kernel/time_32.c
+++ b/arch/sparc/kernel/time_32.c
@@ -78,6 +78,11 @@ __volatile__ unsigned int *master_l10_counter;
 
 u32 (*do_arch_gettimeoffset)(void);
 
+int update_persistent_clock(struct timespec now)
+{
+	return set_rtc_mmss(now.tv_sec);
+}
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -101,16 +106,6 @@ static irqreturn_t timer_interrupt(int dummy, void *dev_id)
 
 	do_timer(1);
 
-	/* Determine when to update the Mostek clock. */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
-	  if (set_rtc_mmss(xtime.tv_sec) == 0)
-	    last_rtc_update = xtime.tv_sec;
-	  else
-	    last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
-	}
 	write_sequnlock(&xtime_lock);
 
 #ifndef CONFIG_SMP
-- 
1.6.0.4


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

* [PATCH 13/14] cris: Convert cris to use read/update_persistent_clock
  2010-03-04  3:57                       ` [PATCH 12/14] sparc: Convert sparc " John Stultz
@ 2010-03-04  3:57                         ` John Stultz
  2010-03-04  3:57                           ` [PATCH 14/14] arm: Convert arm to use read_persistent_clock John Stultz
  2010-03-13  0:21                           ` [tip:timers/cleanup] cris: Convert cris to use read/update_persistent_clock tip-bot for John Stultz
  2010-03-04  6:41                         ` [PATCH 12/14] sparc: Convert sparc " David Miller
  1 sibling, 2 replies; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml
  Cc: John Stultz, Mikael Starvik, Jesper Nilsson, Thomas Gleixner,
	Andrew Morton

This patch converts the cris architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/cris/Kconfig                |    3 ++
 arch/cris/arch-v10/kernel/time.c |   37 +---------------------------------
 arch/cris/arch-v32/kernel/time.c |   40 +------------------------------------
 arch/cris/kernel/time.c          |   20 ++++++++++--------
 4 files changed, 18 insertions(+), 82 deletions(-)

diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 7adac38..4d42d9d 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -20,6 +20,9 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
 	bool
 
+config GENERIC_CMOS_UPDATE
+	def_bool y
+
 config GENERIC_IOMAP
        bool
        default y
diff --git a/arch/cris/arch-v10/kernel/time.c b/arch/cris/arch-v10/kernel/time.c
index 31ca141..30adae5 100644
--- a/arch/cris/arch-v10/kernel/time.c
+++ b/arch/cris/arch-v10/kernel/time.c
@@ -26,7 +26,6 @@
 /* it will make jiffies at 96 hz instead of 100 hz though */
 #undef USE_CASCADE_TIMERS
 
-extern void update_xtime_from_cmos(void);
 extern int set_rtc_mmss(unsigned long nowtime);
 extern int have_rtc;
 
@@ -188,8 +187,6 @@ stop_watchdog(void)
 #endif	
 }
 
-/* last time the cmos clock got updated */
-static long last_rtc_update = 0;
 
 /*
  * timer_interrupt() needs to keep up the real-time clock,
@@ -232,24 +229,6 @@ timer_interrupt(int irq, void *dev_id)
 	do_timer(1);
 	
         cris_do_profile(regs); /* Save profiling information */
-
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 *
-	 * The division here is not time critical since it will run once in 
-	 * 11 minutes
-	 */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
-	}
         return IRQ_HANDLED;
 }
 
@@ -274,22 +253,10 @@ time_init(void)
 	 */
 	loops_per_usec = 50;
 
-	if(RTC_INIT() < 0) {
-		/* no RTC, start at 1980 */
-		xtime.tv_sec = 0;
-		xtime.tv_nsec = 0;
+	if(RTC_INIT() < 0)
 		have_rtc = 0;
-	} else {		
-		/* get the current time */
+	else
 		have_rtc = 1;
-		update_xtime_from_cmos();
-	}
-
-	/*
-	 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
-	 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
-	 */
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 
 	/* Setup the etrax timers
 	 * Base frequency is 25000 hz, divider 250 -> 100 HZ
diff --git a/arch/cris/arch-v32/kernel/time.c b/arch/cris/arch-v32/kernel/time.c
index b1920d8..1ee0e10 100644
--- a/arch/cris/arch-v32/kernel/time.c
+++ b/arch/cris/arch-v32/kernel/time.c
@@ -44,7 +44,6 @@ unsigned long timer_regs[NR_CPUS] =
 #endif
 };
 
-extern void update_xtime_from_cmos(void);
 extern int set_rtc_mmss(unsigned long nowtime);
 extern int have_rtc;
 
@@ -198,9 +197,6 @@ handle_watchdog_bite(struct pt_regs* regs)
 #endif
 }
 
-/* Last time the cmos clock got updated. */
-static long last_rtc_update = 0;
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick.
@@ -238,25 +234,6 @@ timer_interrupt(int irq, void *dev_id)
 
 	/* Call the real timer interrupt handler */
 	do_timer(1);
-
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 *
-	 * The division here is not time critical since it will run once in
-	 * 11 minutes
-	 */
-	if ((time_status & STA_UNSYNC) == 0 &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* Do it again in 60 s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
         return IRQ_HANDLED;
 }
 
@@ -309,23 +286,10 @@ time_init(void)
 	 */
 	loops_per_usec = 50;
 
-	if(RTC_INIT() < 0) {
-		/* No RTC, start at 1980 */
-		xtime.tv_sec = 0;
-		xtime.tv_nsec = 0;
+	if(RTC_INIT() < 0)
 		have_rtc = 0;
-	} else {
-		/* Get the current time */
+	else
 		have_rtc = 1;
-		update_xtime_from_cmos();
-	}
-
-	/*
-	 * Initialize wall_to_monotonic such that adding it to
-	 * xtime will yield zero, the tv_nsec field must be normalized
-	 * (i.e., 0 <= nsec < NSEC_PER_SEC).
-	 */
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 
 	/* Start CPU local timer. */
 	cris_timer_init();
diff --git a/arch/cris/kernel/time.c b/arch/cris/kernel/time.c
index 074fe7d..e169aea 100644
--- a/arch/cris/kernel/time.c
+++ b/arch/cris/kernel/time.c
@@ -162,6 +162,8 @@ unsigned long
 get_cmos_time(void)
 {
 	unsigned int year, mon, day, hour, min, sec;
+	if(!have_rtc)
+		return 0;
 
 	sec = CMOS_READ(RTC_SECONDS);
 	min = CMOS_READ(RTC_MINUTES);
@@ -183,19 +185,19 @@ get_cmos_time(void)
 	return mktime(year, mon, day, hour, min, sec);
 }
 
-/* update xtime from the CMOS settings. used when /dev/rtc gets a SET_TIME.
- * TODO: this doesn't reset the fancy NTP phase stuff as do_settimeofday does.
- */
 
-void
-update_xtime_from_cmos(void)
+int update_persistent_clock(struct timespec now)
 {
-	if(have_rtc) {
-		xtime.tv_sec = get_cmos_time();
-		xtime.tv_nsec = 0;
-	}
+	return set_rtc_mmss(now.tv_sec);
 }
 
+void read_persistent_clock(struct timespec *ts)
+{
+	ts->tv_sec = get_cmos_time();
+	ts->tv_nsec = 0;
+}
+
+
 extern void cris_profile_sample(struct pt_regs* regs);
 
 void
-- 
1.6.0.4


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

* [PATCH 14/14] arm: Convert arm to use read_persistent_clock
  2010-03-04  3:57                         ` [PATCH 13/14] cris: Convert cris " John Stultz
@ 2010-03-04  3:57                           ` John Stultz
  2010-03-04  9:36                             ` Russell King - ARM Linux
  2010-03-13  0:21                           ` [tip:timers/cleanup] cris: Convert cris to use read/update_persistent_clock tip-bot for John Stultz
  1 sibling, 1 reply; 34+ messages in thread
From: John Stultz @ 2010-03-04  3:57 UTC (permalink / raw)
  To: 	lkml; +Cc: John Stultz, Thomas Gleixner, Andrew Morton, Russell King

This patch converts the arm architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.

Also removes a direct xtime access, replacing it with current_kernel_time()

I have not built or tested this patch, so help from arch maintainers would be appreciated.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/arm/Kconfig       |    3 +++
 arch/arm/kernel/time.c |    7 +++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3b18128..b70929d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -43,6 +43,9 @@ config GENERIC_GPIO
 config GENERIC_TIME
 	bool
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config GENERIC_CLOCKEVENTS
 	bool
 
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 2875380..eebe8f5 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -79,6 +79,13 @@ static unsigned long dummy_gettimeoffset(void)
 }
 #endif
 
+int update_persistent_clock(struct timespec now)
+{
+	if (set_rtc == NULL)
+		return -1;
+	return set_rtc(now);
+}
+
 #ifdef CONFIG_LEDS_TIMER
 static inline void do_leds(void)
 {
-- 
1.6.0.4


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

* Re: [PATCH 12/14] sparc: Convert sparc to use read/update_persistent_clock
  2010-03-04  3:57                       ` [PATCH 12/14] sparc: Convert sparc " John Stultz
  2010-03-04  3:57                         ` [PATCH 13/14] cris: Convert cris " John Stultz
@ 2010-03-04  6:41                         ` David Miller
  1 sibling, 0 replies; 34+ messages in thread
From: David Miller @ 2010-03-04  6:41 UTC (permalink / raw)
  To: johnstul; +Cc: linux-kernel, tglx, akpm

From: John Stultz <johnstul@us.ibm.com>
Date: Wed,  3 Mar 2010 19:57:27 -0800

> This patch converts the sparc architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.
> 
> I have not built or tested this patch, so help from arch maintainers would be appreciated.
> 
> Cc: David S. Miller" <davem@davemloft.net>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 
> Signed-off-by: John Stultz <johnstul@us.ibm.com>

Here's a version that compiles, you have to get rid of the now unused
variably last_rtc_update since we build with -Werror, and you can also
add my:

Acked-by: David S. Miller <davem@davemloft.net>

Also, you'll reach more sparc developers by CC:'ing sparclinux@vger.kernel.org
on your patches :-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 4097f6a..0e8ec2a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -72,7 +72,7 @@ config ARCH_USES_GETTIMEOFFSET
 
 config GENERIC_CMOS_UPDATE
 	bool
-	default y if SPARC64
+	default y
 
 config GENERIC_CLOCKEVENTS
 	bool
diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c
index 0d4c09b..4453003 100644
--- a/arch/sparc/kernel/time_32.c
+++ b/arch/sparc/kernel/time_32.c
@@ -78,6 +78,11 @@ __volatile__ unsigned int *master_l10_counter;
 
 u32 (*do_arch_gettimeoffset)(void);
 
+int update_persistent_clock(struct timespec now)
+{
+	return set_rtc_mmss(now.tv_sec);
+}
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -87,9 +92,6 @@ u32 (*do_arch_gettimeoffset)(void);
 
 static irqreturn_t timer_interrupt(int dummy, void *dev_id)
 {
-	/* last time the cmos clock got updated */
-	static long last_rtc_update;
-
 #ifndef CONFIG_SMP
 	profile_tick(CPU_PROFILING);
 #endif
@@ -101,16 +103,6 @@ static irqreturn_t timer_interrupt(int dummy, void *dev_id)
 
 	do_timer(1);
 
-	/* Determine when to update the Mostek clock. */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
-	  if (set_rtc_mmss(xtime.tv_sec) == 0)
-	    last_rtc_update = xtime.tv_sec;
-	  else
-	    last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
-	}
 	write_sequnlock(&xtime_lock);
 
 #ifndef CONFIG_SMP

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

* Re: [PATCH 14/14] arm: Convert arm to use read_persistent_clock
  2010-03-04  3:57                           ` [PATCH 14/14] arm: Convert arm to use read_persistent_clock John Stultz
@ 2010-03-04  9:36                             ` Russell King - ARM Linux
  2010-03-04 19:55                               ` john stultz
  0 siblings, 1 reply; 34+ messages in thread
From: Russell King - ARM Linux @ 2010-03-04  9:36 UTC (permalink / raw)
  To: John Stultz; +Cc: lkml, Thomas Gleixner, Andrew Morton

On Wed, Mar 03, 2010 at 07:57:29PM -0800, John Stultz wrote:
> This patch converts the arm architecture to use the generic
> read_persistent_clock and update_persistent_clock interfaces,
> reducing the amount of arch specific code we have to maintain,
> and allowing for further cleanups in the future.

Have you checked Linus' latest tree?  set_rtc() no longer exists there.

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

* Re: [PATCH 08/14] sh: Convert sh to use read/update_persistent_clock
  2010-03-04  3:57               ` [PATCH 08/14] sh: Convert sh " John Stultz
  2010-03-04  3:57                 ` [PATCH 09/14] blackfin: Convert blackfin " John Stultz
@ 2010-03-04 17:00                 ` Paul Mundt
  1 sibling, 0 replies; 34+ messages in thread
From: Paul Mundt @ 2010-03-04 17:00 UTC (permalink / raw)
  To: John Stultz; +Cc: lkml, Thomas Gleixner, Andrew Morton

On Wed, Mar 03, 2010 at 07:57:23PM -0800, John Stultz wrote:
> This patch converts the sh architecture to use the generic
> read_persistent_clock and update_persistent_clock interfaces, reducing
> the amount of arch specific code we have to maintain, and allowing for
> further cleanups in the future.
> 
> I have not built or tested this patch, so help from arch maintainers
> would be appreciated.
> 
> Cc: Paul Mundt <lethal@linux-sh.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: John Stultz <johnstul@us.ibm.com>

Looks fine to me, I'll apply it, thanks.

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

* Re: [PATCH 14/14] arm: Convert arm to use read_persistent_clock
  2010-03-04  9:36                             ` Russell King - ARM Linux
@ 2010-03-04 19:55                               ` john stultz
  0 siblings, 0 replies; 34+ messages in thread
From: john stultz @ 2010-03-04 19:55 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: lkml, Thomas Gleixner, Andrew Morton

On Thu, 2010-03-04 at 09:36 +0000, Russell King - ARM Linux wrote:
> On Wed, Mar 03, 2010 at 07:57:29PM -0800, John Stultz wrote:
> > This patch converts the arm architecture to use the generic
> > read_persistent_clock and update_persistent_clock interfaces,
> > reducing the amount of arch specific code we have to maintain,
> > and allowing for further cleanups in the future.
> 
> Have you checked Linus' latest tree?  set_rtc() no longer exists there.

Ah. Thanks for pointing that out. I'll go ahead and drop the patch.

Thanks again!
-john



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

* Re: [PATCH 04/14] parisc: Convert parisc to use read/update_persistent_clock
  2010-03-04  3:57       ` [PATCH 04/14] parisc: Convert parisc " John Stultz
  2010-03-04  3:57         ` [PATCH 05/14] h8300: Convert h8300 " John Stultz
@ 2010-03-06 22:40         ` Helge Deller
  2010-03-06 22:49           ` Kyle McMartin
  1 sibling, 1 reply; 34+ messages in thread
From: Helge Deller @ 2010-03-06 22:40 UTC (permalink / raw)
  To: John Stultz; +Cc: lkml, Kyle McMartin, Thomas Gleixner, Andrew Morton

On 03/04/2010 04:57 AM, John Stultz wrote:
> This patch converts the parisc architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.
>
> I have not built or tested this patch, so help from arch maintainers would be appreciated.

Works nicely.

Thanks, John.

Acked-by: Helge Deller <deller@gmx.de>

>
> Cc: Kyle McMartin<kyle@mcmartin.ca>
> Cc: Helge Deller<deller@gmx.de>
> Cc: Thomas Gleixner<tglx@linutronix.de>
> Cc: Andrew Morton<akpm@linux-foundation.org>
>
> Signed-off-by: John Stultz<johnstul@us.ibm.com>
> ---
>   arch/parisc/kernel/time.c |   29 +++++++++++++----------------
>   1 files changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
> index a79c6f9..05511cc 100644
> --- a/arch/parisc/kernel/time.c
> +++ b/arch/parisc/kernel/time.c
> @@ -250,9 +250,21 @@ static int __init rtc_init(void)
>   }
>   module_init(rtc_init);
>
> -void __init time_init(void)
> +void read_persistent_clock(struct timespec *ts)
>   {
>   	static struct pdc_tod tod_data;
> +	if (pdc_tod_read(&tod_data) == 0) {
> +		ts->tv_sec = tod_data.tod_sec;
> +		ts->tv_nsec = tod_data.tod_usec * 1000;
> +	} else {
> +		printk(KERN_ERR "Error reading tod clock\n");
> +	        ts->tv_sec = 0;
> +		ts->tv_nsec = 0;
> +	}
> +}
> +
> +void __init time_init(void)
> +{
>   	unsigned long current_cr16_khz;
>
>   	clocktick = (100 * PAGE0->mem_10msec) / HZ;
> @@ -264,19 +276,4 @@ void __init time_init(void)
>   	clocksource_cr16.mult = clocksource_khz2mult(current_cr16_khz,
>   						clocksource_cr16.shift);
>   	clocksource_register(&clocksource_cr16);
> -
> -	if (pdc_tod_read(&tod_data) == 0) {
> -		unsigned long flags;
> -
> -		write_seqlock_irqsave(&xtime_lock, flags);
> -		xtime.tv_sec = tod_data.tod_sec;
> -		xtime.tv_nsec = tod_data.tod_usec * 1000;
> -		set_normalized_timespec(&wall_to_monotonic,
> -		                        -xtime.tv_sec, -xtime.tv_nsec);
> -		write_sequnlock_irqrestore(&xtime_lock, flags);
> -	} else {
> -		printk(KERN_ERR "Error reading tod clock\n");
> -	        xtime.tv_sec = 0;
> -		xtime.tv_nsec = 0;
> -	}
>   }


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

* Re: [PATCH 04/14] parisc: Convert parisc to use read/update_persistent_clock
  2010-03-06 22:40         ` [PATCH 04/14] parisc: Convert parisc " Helge Deller
@ 2010-03-06 22:49           ` Kyle McMartin
  0 siblings, 0 replies; 34+ messages in thread
From: Kyle McMartin @ 2010-03-06 22:49 UTC (permalink / raw)
  To: Helge Deller
  Cc: John Stultz, lkml, Kyle McMartin, Thomas Gleixner, Andrew Morton

On Sat, Mar 06, 2010 at 11:40:30PM +0100, Helge Deller wrote:
> Works nicely.
>
> Thanks, John.
>
> Acked-by: Helge Deller <deller@gmx.de>
>

Thanks Helge, added your annotation.

regards, Kyle

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

* Re: [PATCH 09/14] blackfin: Convert blackfin to use  read/update_persistent_clock
  2010-03-04  3:57                 ` [PATCH 09/14] blackfin: Convert blackfin " John Stultz
  2010-03-04  3:57                   ` [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock John Stultz
@ 2010-03-09 23:53                   ` Mike Frysinger
  2010-03-09 23:59                     ` john stultz
  2010-03-13  0:20                   ` [tip:timers/cleanup] " tip-bot for John Stultz
  2 siblings, 1 reply; 34+ messages in thread
From: Mike Frysinger @ 2010-03-09 23:53 UTC (permalink / raw)
  To: John Stultz; +Cc: lkml, Thomas Gleixner, Andrew Morton

On Wed, Mar 3, 2010 at 22:57, John Stultz wrote:
> This patch converts the blackfin architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.
>
> I have not built or tested this patch, so help from arch maintainers would be appreciated.

Blackfin builds & boots with generic clockevents and w/out
Acked-by: Mike Frysinger <vapier@gentoo.org>

did you want me to merge it for 2.6.35 or should it go through with
your patchset ?
-mike

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

* Re: [PATCH 09/14] blackfin: Convert blackfin to use read/update_persistent_clock
  2010-03-09 23:53                   ` [PATCH 09/14] blackfin: Convert blackfin to use read/update_persistent_clock Mike Frysinger
@ 2010-03-09 23:59                     ` john stultz
  2010-03-10  0:01                       ` Mike Frysinger
  0 siblings, 1 reply; 34+ messages in thread
From: john stultz @ 2010-03-09 23:59 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: lkml, Thomas Gleixner, Andrew Morton

On Tue, 2010-03-09 at 18:53 -0500, Mike Frysinger wrote:
> On Wed, Mar 3, 2010 at 22:57, John Stultz wrote:
> > This patch converts the blackfin architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.
> >
> > I have not built or tested this patch, so help from arch maintainers would be appreciated.
> 
> Blackfin builds & boots with generic clockevents and w/out
> Acked-by: Mike Frysinger <vapier@gentoo.org>

Cool!

> did you want me to merge it for 2.6.35 or should it go through with
> your patchset ?

I'd say go ahead and merge it. 

thanks
-john





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

* Re: [PATCH 09/14] blackfin: Convert blackfin to use  read/update_persistent_clock
  2010-03-09 23:59                     ` john stultz
@ 2010-03-10  0:01                       ` Mike Frysinger
  0 siblings, 0 replies; 34+ messages in thread
From: Mike Frysinger @ 2010-03-10  0:01 UTC (permalink / raw)
  To: john stultz; +Cc: lkml, Thomas Gleixner, Andrew Morton

On Tue, Mar 9, 2010 at 18:59, john stultz wrote:
> On Tue, 2010-03-09 at 18:53 -0500, Mike Frysinger wrote:
>> On Wed, Mar 3, 2010 at 22:57, John Stultz wrote:
>> > This patch converts the blackfin architecture to use the generic read_persistent_clock and update_persistent_clock interfaces, reducing the amount of arch specific code we have to maintain, and allowing for further cleanups in the future.
>> >
>> > I have not built or tested this patch, so help from arch maintainers would be appreciated.
>>
>> Blackfin builds & boots with generic clockevents and w/out
>> Acked-by: Mike Frysinger <vapier@gentoo.org>
>
> Cool!
>
>> did you want me to merge it for 2.6.35 or should it go through with
>> your patchset ?
>
> I'd say go ahead and merge it.

will do
-mike

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

* [tip:timers/cleanup] alpha: Convert alpha to use read/update_persistent_clock
  2010-03-04  3:57 ` [PATCH 01/14] alpha: Convert alpha " John Stultz
  2010-03-04  3:57   ` [PATCH 02/14] mn10300: Convert mn10300 " John Stultz
@ 2010-03-13  0:19   ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:19 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, akpm, johnstul, tglx, rth

Commit-ID:  1e871be1aa97babb467a929d6adcb1960659928b
Gitweb:     http://git.kernel.org/tip/1e871be1aa97babb467a929d6adcb1960659928b
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:16 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:08 +0100

alpha: Convert alpha to use read/update_persistent_clock

This patch converts the alpha architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

igned-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-2-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/alpha/Kconfig       |    3 +
 arch/alpha/kernel/time.c |  101 +++++++++++++++++++++------------------------
 2 files changed, 50 insertions(+), 54 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index bd7261e..75fff7e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -54,6 +54,9 @@ config ARCH_USES_GETTIMEOFFSET
 	bool
 	default y
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config ZONE_DMA
 	bool
 	default y
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index 5d08266..5465e93 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -75,8 +75,6 @@ static struct {
 	__u32 last_time;
 	/* ticks/cycle * 2^48 */
 	unsigned long scaled_ticks_per_cycle;
-	/* last time the CMOS clock got updated */
-	time_t last_rtc_update;
 	/* partial unused tick */
 	unsigned long partial_tick;
 } state;
@@ -91,6 +89,52 @@ static inline __u32 rpcc(void)
     return result;
 }
 
+int update_persistent_clock(struct timespec now)
+{
+	return set_rtc_mmss(now.tv_sec);
+}
+
+void read_persistent_clock(struct timespec *ts)
+{
+	unsigned int year, mon, day, hour, min, sec, epoch;
+
+	sec = CMOS_READ(RTC_SECONDS);
+	min = CMOS_READ(RTC_MINUTES);
+	hour = CMOS_READ(RTC_HOURS);
+	day = CMOS_READ(RTC_DAY_OF_MONTH);
+	mon = CMOS_READ(RTC_MONTH);
+	year = CMOS_READ(RTC_YEAR);
+
+	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+		sec = bcd2bin(sec);
+		min = bcd2bin(min);
+		hour = bcd2bin(hour);
+		day = bcd2bin(day);
+		mon = bcd2bin(mon);
+		year = bcd2bin(year);
+	}
+
+	/* PC-like is standard; used for year >= 70 */
+	epoch = 1900;
+	if (year < 20)
+		epoch = 2000;
+	else if (year >= 20 && year < 48)
+		/* NT epoch */
+		epoch = 1980;
+	else if (year >= 48 && year < 70)
+		/* Digital UNIX epoch */
+		epoch = 1952;
+
+	printk(KERN_INFO "Using epoch = %d\n", epoch);
+
+	if ((year += epoch) < 1970)
+		year += 100;
+
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+}
+
+
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -123,19 +167,6 @@ irqreturn_t timer_interrupt(int irq, void *dev)
 	if (nticks)
 		do_timer(nticks);
 
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	if (ntp_synced()
-	    && xtime.tv_sec > state.last_rtc_update + 660
-	    && xtime.tv_nsec >= 500000 - ((unsigned) TICK_SIZE) / 2
-	    && xtime.tv_nsec <= 500000 + ((unsigned) TICK_SIZE) / 2) {
-		int tmp = set_rtc_mmss(xtime.tv_sec);
-		state.last_rtc_update = xtime.tv_sec - (tmp ? 600 : 0);
-	}
-
 	write_sequnlock(&xtime_lock);
 
 #ifndef CONFIG_SMP
@@ -304,7 +335,7 @@ rpcc_after_update_in_progress(void)
 void __init
 time_init(void)
 {
-	unsigned int year, mon, day, hour, min, sec, cc1, cc2, epoch;
+	unsigned int cc1, cc2;
 	unsigned long cycle_freq, tolerance;
 	long diff;
 
@@ -348,43 +379,6 @@ time_init(void)
 	   bogomips yet, but this is close on a 500Mhz box.  */
 	__delay(1000000);
 
-	sec = CMOS_READ(RTC_SECONDS);
-	min = CMOS_READ(RTC_MINUTES);
-	hour = CMOS_READ(RTC_HOURS);
-	day = CMOS_READ(RTC_DAY_OF_MONTH);
-	mon = CMOS_READ(RTC_MONTH);
-	year = CMOS_READ(RTC_YEAR);
-
-	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-		sec = bcd2bin(sec);
-		min = bcd2bin(min);
-		hour = bcd2bin(hour);
-		day = bcd2bin(day);
-		mon = bcd2bin(mon);
-		year = bcd2bin(year);
-	}
-
-	/* PC-like is standard; used for year >= 70 */
-	epoch = 1900;
-	if (year < 20)
-		epoch = 2000;
-	else if (year >= 20 && year < 48)
-		/* NT epoch */
-		epoch = 1980;
-	else if (year >= 48 && year < 70)
-		/* Digital UNIX epoch */
-		epoch = 1952;
-
-	printk(KERN_INFO "Using epoch = %d\n", epoch);
-
-	if ((year += epoch) < 1970)
-		year += 100;
-
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
-
-        wall_to_monotonic.tv_sec -= xtime.tv_sec;
-        wall_to_monotonic.tv_nsec = 0;
 
 	if (HZ > (1<<16)) {
 		extern void __you_loose (void);
@@ -394,7 +388,6 @@ time_init(void)
 	state.last_time = cc1;
 	state.scaled_ticks_per_cycle
 		= ((unsigned long) HZ << FIX_SHIFT) / cycle_freq;
-	state.last_rtc_update = 0;
 	state.partial_tick = 0L;
 
 	/* Startup the timer source. */

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

* [tip:timers/cleanup] mn10300: Convert mn10300 to use read/update_persistent_clock
  2010-03-04  3:57   ` [PATCH 02/14] mn10300: Convert mn10300 " John Stultz
  2010-03-04  3:57     ` [PATCH 03/14] frv: Convert frv " John Stultz
@ 2010-03-13  0:19     ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, johnstul, yasutake.koichi, dhowells,
	akpm, tglx

Commit-ID:  f7a56575fa4e62e94a644f72ef8c5d423c073982
Gitweb:     http://git.kernel.org/tip/f7a56575fa4e62e94a644f72ef8c5d423c073982
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:17 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:09 +0100

mn10300: Convert mn10300 to use read/update_persistent_clock

This patch converts the mn10300 architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-3-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mn10300/Kconfig       |    3 +++
 arch/mn10300/kernel/rtc.c  |   27 +++++----------------------
 arch/mn10300/kernel/time.c |    4 ----
 3 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 89faaca..1c4565a 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -37,6 +37,9 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
 config GENERIC_CALIBRATE_DELAY
 	def_bool y
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config GENERIC_FIND_NEXT_BIT
 	def_bool y
 
diff --git a/arch/mn10300/kernel/rtc.c b/arch/mn10300/kernel/rtc.c
index 7978470..815a933 100644
--- a/arch/mn10300/kernel/rtc.c
+++ b/arch/mn10300/kernel/rtc.c
@@ -26,17 +26,15 @@ static long last_rtc_update;
 /* time for RTC to update itself in ioclks */
 static unsigned long mn10300_rtc_update_period;
 
-/*
- * read the current RTC time
- */
-unsigned long __init get_initial_rtc_time(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	struct rtc_time tm;
 
 	get_rtc_time(&tm);
 
-	return mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
+	ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
 		      tm.tm_hour, tm.tm_min, tm.tm_sec);
+	ts->tv_nsec = 0;
 }
 
 /*
@@ -110,24 +108,9 @@ static int set_rtc_mmss(unsigned long nowtime)
 	return retval;
 }
 
-void check_rtc_time(void)
+int update_persistent_clock(struct timespec now)
 {
-	/* the RTC clock just finished ticking over again this second
-	 * - if we have an externally synchronized Linux clock, then update
-	 *   RTC clock accordingly every ~11 minutes. set_rtc_mmss() has to be
-	 *   called as close as possible to 500 ms before the new second starts.
-	 */
-	if ((time_status & STA_UNSYNC) == 0 &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    xtime.tv_nsec / 1000 >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-	    xtime.tv_nsec / 1000 <= 500000 + ((unsigned) TICK_SIZE) / 2
-	    ) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* do it again in 60s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
+	return set_rtc_mms(now.tv_sec);
 }
 
 /*
diff --git a/arch/mn10300/kernel/time.c b/arch/mn10300/kernel/time.c
index 395caf0..8f7f6d2 100644
--- a/arch/mn10300/kernel/time.c
+++ b/arch/mn10300/kernel/time.c
@@ -111,7 +111,6 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
 		/* advance the kernel's time tracking system */
 		profile_tick(CPU_PROFILING);
 		do_timer(1);
-		check_rtc_time();
 	}
 
 	write_sequnlock(&xtime_lock);
@@ -139,9 +138,6 @@ void __init time_init(void)
 	       " (calibrated against RTC)\n",
 	       MN10300_TSCCLK / 1000000, (MN10300_TSCCLK / 10000) % 100);
 
-	xtime.tv_sec = get_initial_rtc_time();
-	xtime.tv_nsec = 0;
-
 	mn10300_last_tsc = TMTSCBC;
 
 	/* use timer 0 & 1 cascaded to tick at as close to HZ as possible */

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

* [tip:timers/cleanup] frv: Convert frv to use read/update_persistent_clock
  2010-03-04  3:57     ` [PATCH 03/14] frv: Convert frv " John Stultz
  2010-03-04  3:57       ` [PATCH 04/14] parisc: Convert parisc " John Stultz
@ 2010-03-13  0:19       ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, dhowells, akpm, johnstul, tglx

Commit-ID:  739b27116a0e6903d6c85d6769e69f43d8fa4128
Gitweb:     http://git.kernel.org/tip/739b27116a0e6903d6c85d6769e69f43d8fa4128
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:18 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:09 +0100

frv: Convert frv to use read/update_persistent_clock

This patch converts the frv architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-4-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/frv/kernel/time.c |   34 +++++++---------------------------
 1 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/arch/frv/kernel/time.c b/arch/frv/kernel/time.c
index fb0ce75..0ddbbae 100644
--- a/arch/frv/kernel/time.c
+++ b/arch/frv/kernel/time.c
@@ -48,20 +48,12 @@ static struct irqaction timer_irq  = {
 	.name = "timer",
 };
 
-static inline int set_rtc_mmss(unsigned long nowtime)
-{
-	return -1;
-}
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
 static irqreturn_t timer_interrupt(int irq, void *dummy)
 {
-	/* last time the cmos clock got updated */
-	static long last_rtc_update = 0;
-
 	profile_tick(CPU_PROFILING);
 	/*
 	 * Here we are in the timer irq handler. We just have irqs locally
@@ -74,22 +66,6 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
 
 	do_timer(1);
 
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2
-	    ) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
-	}
-
 #ifdef CONFIG_HEARTBEAT
 	static unsigned short n;
 	n++;
@@ -119,7 +95,8 @@ void time_divisor_init(void)
 	__set_TCSR_DATA(0, base >> 8);
 }
 
-void time_init(void)
+
+void read_persistent_clock(struct timespec *ts)
 {
 	unsigned int year, mon, day, hour, min, sec;
 
@@ -135,9 +112,12 @@ void time_init(void)
 
 	if ((year += 1900) < 1970)
 		year += 100;
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+	ts->tv_nsec = 0;
+}
 
+void time_init(void)
+{
 	/* install scheduling interrupt handler */
 	setup_irq(IRQ_CPU_TIMER0, &timer_irq);
 

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

* [tip:timers/cleanup] h8300: Convert h8300 to use read/update_persistent_clock
  2010-03-04  3:57         ` [PATCH 05/14] h8300: Convert h8300 " John Stultz
  2010-03-04  3:57           ` [PATCH 06/14] avr32: Convert avr32 " John Stultz
@ 2010-03-13  0:20           ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:20 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, akpm, johnstul, tglx, ysato

Commit-ID:  12833c1e373ad2b12667ca159d335fae29968473
Gitweb:     http://git.kernel.org/tip/12833c1e373ad2b12667ca159d335fae29968473
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:20 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:10 +0100

h8300: Convert h8300 to use read/update_persistent_clock

This patch converts the h8300 architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-6-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/h8300/kernel/time.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c
index 7f2d6cf..165005a 100644
--- a/arch/h8300/kernel/time.c
+++ b/arch/h8300/kernel/time.c
@@ -41,7 +41,7 @@ void h8300_timer_tick(void)
 	update_process_times(user_mode(get_irq_regs()));
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	unsigned int year, mon, day, hour, min, sec;
 
@@ -56,8 +56,12 @@ void __init time_init(void)
 #endif
 	if ((year += 1900) < 1970)
 		year += 100;
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = 0;
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+	ts->tv_nsec = 0;
+}
+
+void __init time_init(void)
+{
 
 	h8300_timer_setup();
 }

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

* [tip:timers/cleanup] avr32: Convert avr32 to use read/update_persistent_clock
  2010-03-04  3:57           ` [PATCH 06/14] avr32: Convert avr32 " John Stultz
  2010-03-04  3:57             ` [PATCH 07/14] ia64: Convert ia64 " John Stultz
@ 2010-03-13  0:20             ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, akpm, johnstul, tglx, hskinnemoen

Commit-ID:  e2032a4a7237e97cd2ee36e2d806c5742ace189f
Gitweb:     http://git.kernel.org/tip/e2032a4a7237e97cd2ee36e2d806c5742ace189f
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:21 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:10 +0100

avr32: Convert avr32 to use read/update_persistent_clock

This patch converts the avr32 architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-7-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/avr32/kernel/time.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index f27aa3b..a047d69 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -110,17 +110,17 @@ static struct clock_event_device comparator = {
 	.set_mode	= comparator_mode,
 };
 
+void read_persistent_clock(struct timespec *ts)
+{
+	ts->tv.sec = mktime(2007, 1, 1, 0, 0, 0);
+	ts->tv_nsec = 0;
+}
+
 void __init time_init(void)
 {
 	unsigned long counter_hz;
 	int ret;
 
-	xtime.tv_sec = mktime(2007, 1, 1, 0, 0, 0);
-	xtime.tv_nsec = 0;
-
-	set_normalized_timespec(&wall_to_monotonic,
-				-xtime.tv_sec, -xtime.tv_nsec);
-
 	/* figure rate for counter */
 	counter_hz = clk_get_rate(boot_cpu_data.clk);
 	counter.mult = clocksource_hz2mult(counter_hz, counter.shift);

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

* [tip:timers/cleanup] ia64: Convert ia64 to use read/update_persistent_clock
  2010-03-04  3:57             ` [PATCH 07/14] ia64: Convert ia64 " John Stultz
  2010-03-04  3:57               ` [PATCH 08/14] sh: Convert sh " John Stultz
@ 2010-03-13  0:20               ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, johnstul, tony.luck, akpm, fenghua.yu, tglx

Commit-ID:  6ffdc5774a9ef80e58db398a8307d5b2db2644ce
Gitweb:     http://git.kernel.org/tip/6ffdc5774a9ef80e58db398a8307d5b2db2644ce
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:22 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:11 +0100

ia64: Convert ia64 to use read/update_persistent_clock

This patch converts the ia64 architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-8-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/kernel/time.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 47a1927..653b3c4 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -430,18 +430,16 @@ static int __init rtc_init(void)
 }
 module_init(rtc_init);
 
+void read_persistent_clock(struct timespec *ts)
+{
+	efi_gettimeofday(ts);
+}
+
 void __init
 time_init (void)
 {
 	register_percpu_irq(IA64_TIMER_VECTOR, &timer_irqaction);
-	efi_gettimeofday(&xtime);
 	ia64_init_itm();
-
-	/*
-	 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
-	 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
-	 */
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 }
 
 /*

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

* [tip:timers/cleanup] blackfin: Convert blackfin to use read/update_persistent_clock
  2010-03-04  3:57                 ` [PATCH 09/14] blackfin: Convert blackfin " John Stultz
  2010-03-04  3:57                   ` [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock John Stultz
  2010-03-09 23:53                   ` [PATCH 09/14] blackfin: Convert blackfin to use read/update_persistent_clock Mike Frysinger
@ 2010-03-13  0:20                   ` tip-bot for John Stultz
  2 siblings, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:20 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, akpm, johnstul, vapier, tglx

Commit-ID:  cb0e996378900fa05d5c779d6bfa52d55ebc3407
Gitweb:     http://git.kernel.org/tip/cb0e996378900fa05d5c779d6bfa52d55ebc3407
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:24 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:12 +0100

blackfin: Convert blackfin to use read/update_persistent_clock

This patch converts the blackfin architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-10-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/blackfin/kernel/time-ts.c |   13 +++++++------
 arch/blackfin/kernel/time.c    |   39 ++++++---------------------------------
 2 files changed, 13 insertions(+), 39 deletions(-)

diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 17c38c5..08dd3e8 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -348,9 +348,15 @@ static int __init bfin_clockevent_init(void)
 	return 0;
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60;	/* 1 Jan 2007 */
+	ts->tv_sec = secs_since_1970;
+	ts->tv_nsec = 0;
+}
+
+void __init time_init(void)
+{
 
 #ifdef CONFIG_RTC_DRV_BFIN
 	/* [#2663] hack to filter junk RTC values that would cause
@@ -363,11 +369,6 @@ void __init time_init(void)
 	}
 #endif
 
-	/* Initialize xtime. From now on, xtime is updated with timer interrupts */
-	xtime.tv_sec = secs_since_1970;
-	xtime.tv_nsec = 0;
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
-
 	bfin_cs_cycles_init();
 	bfin_cs_gptimer0_init();
 	bfin_clockevent_init();
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c
index 13c1ee3..c911361 100644
--- a/arch/blackfin/kernel/time.c
+++ b/arch/blackfin/kernel/time.c
@@ -112,11 +112,6 @@ u32 arch_gettimeoffset(void)
 }
 #endif
 
-static inline int set_rtc_mmss(unsigned long nowtime)
-{
-	return 0;
-}
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -126,29 +121,8 @@ __attribute__((l1_text))
 #endif
 irqreturn_t timer_interrupt(int irq, void *dummy)
 {
-	/* last time the cmos clock got updated */
-	static long last_rtc_update;
-
 	write_seqlock(&xtime_lock);
 	do_timer(1);
-
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / NSEC_PER_USEC) >=
-	    500000 - ((unsigned)TICK_SIZE) / 2
-	    && (xtime.tv_nsec / NSEC_PER_USEC) <=
-	    500000 + ((unsigned)TICK_SIZE) / 2) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* Do it again in 60s. */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
 	write_sequnlock(&xtime_lock);
 
 #ifdef CONFIG_IPIPE
@@ -161,10 +135,15 @@ irqreturn_t timer_interrupt(int irq, void *dummy)
 	return IRQ_HANDLED;
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60;	/* 1 Jan 2007 */
+	ts->tv_sec = secs_since_1970;
+	ts->tv_nsec = 0;
+}
 
+void __init time_init(void)
+{
 #ifdef CONFIG_RTC_DRV_BFIN
 	/* [#2663] hack to filter junk RTC values that would cause
 	 * userspace to have to deal with time values greater than
@@ -176,11 +155,5 @@ void __init time_init(void)
 	}
 #endif
 
-	/* Initialize xtime. From now on, xtime is updated with timer interrupts */
-	xtime.tv_sec = secs_since_1970;
-	xtime.tv_nsec = 0;
-
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
-
 	time_sched_init(timer_interrupt);
 }

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

* [tip:timers/cleanup] m32r: Convert m32r to use read/update_peristent_clock
  2010-03-04  3:57                   ` [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock John Stultz
  2010-03-04  3:57                     ` [PATCH 11/14] m68k: Convert m68k to use read/update_persistent_clock John Stultz
@ 2010-03-13  0:21                     ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:21 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, akpm, johnstul, takata, tglx

Commit-ID:  944694716d6ea3c274a73c830bf33e194bad4bcd
Gitweb:     http://git.kernel.org/tip/944694716d6ea3c274a73c830bf33e194bad4bcd
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:25 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:12 +0100

m32r: Convert m32r to use read/update_peristent_clock

This patch converts the m32r architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-11-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/m32r/kernel/time.c |   47 +++++++----------------------------------------
 1 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c
index 9cedcef..bda8682 100644
--- a/arch/m32r/kernel/time.c
+++ b/arch/m32r/kernel/time.c
@@ -106,24 +106,6 @@ u32 arch_gettimeoffset(void)
 }
 
 /*
- * In order to set the CMOS clock precisely, set_rtc_mmss has to be
- * called 500 ms after the second nowtime has started, because when
- * nowtime is written into the registers of the CMOS clock, it will
- * jump to the next second precisely 500 ms later. Check the Motorola
- * MC146818A or Dallas DS12887 data sheet for details.
- *
- * BUG: This routine does not handle hour overflow properly; it just
- *      sets the minutes. Usually you won't notice until after reboot!
- */
-static inline int set_rtc_mmss(unsigned long nowtime)
-{
-	return 0;
-}
-
-/* last time the cmos clock got updated */
-static long last_rtc_update = 0;
-
-/*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
@@ -138,23 +120,6 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
 #ifndef CONFIG_SMP
 	update_process_times(user_mode(get_irq_regs()));
 #endif
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 */
-	write_seqlock(&xtime_lock);
-	if (ntp_synced()
-		&& xtime.tv_sec > last_rtc_update + 660
-		&& (xtime.tv_nsec / 1000) >= 500000 - ((unsigned)TICK_SIZE) / 2
-		&& (xtime.tv_nsec / 1000) <= 500000 + ((unsigned)TICK_SIZE) / 2)
-	{
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else	/* do it again in 60 s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
-	write_sequnlock(&xtime_lock);
 	/* As we return to user mode fire off the other CPU schedulers..
 	   this is basically because we don't yet share IRQ's around.
 	   This message is rigged to be safe on the 386 - basically it's
@@ -174,7 +139,7 @@ static struct irqaction irq0 = {
 	.name = "MFT2",
 };
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	unsigned int epoch, year, mon, day, hour, min, sec;
 
@@ -194,11 +159,13 @@ void __init time_init(void)
 		epoch = 1952;
 	year += epoch;
 
-	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
-	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
-	set_normalized_timespec(&wall_to_monotonic,
-		-xtime.tv_sec, -xtime.tv_nsec);
+	ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+	ts->tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
+}
 
+
+void __init time_init(void)
+{
 #if defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_XNUX2) \
 	|| defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_M32700) \
 	|| defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104)

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

* [tip:timers/cleanup] m68k: Convert m68k to use read/update_persistent_clock
  2010-03-04  3:57                     ` [PATCH 11/14] m68k: Convert m68k to use read/update_persistent_clock John Stultz
  2010-03-04  3:57                       ` [PATCH 12/14] sparc: Convert sparc " John Stultz
@ 2010-03-13  0:21                       ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:21 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, geert, akpm, johnstul, tglx

Commit-ID:  ffbcad49e79cd82428010b44a87401446ea7f370
Gitweb:     http://git.kernel.org/tip/ffbcad49e79cd82428010b44a87401446ea7f370
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:26 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:13 +0100

m68k: Convert m68k to use read/update_persistent_clock

This patch converts the m68k architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-12-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/m68k/kernel/time.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 17dc2a3..4926b38 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -73,21 +73,24 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
 	return IRQ_HANDLED;
 }
 
-void __init time_init(void)
+void read_persistent_clock(struct timespec *ts)
 {
 	struct rtc_time time;
+	ts->tv_sec = 0;
+	ts->tv_nsec = 0;
 
 	if (mach_hwclk) {
 		mach_hwclk(0, &time);
 
 		if ((time.tm_year += 1900) < 1970)
 			time.tm_year += 100;
-		xtime.tv_sec = mktime(time.tm_year, time.tm_mon, time.tm_mday,
+		ts->tv_sec = mktime(time.tm_year, time.tm_mon, time.tm_mday,
 				      time.tm_hour, time.tm_min, time.tm_sec);
-		xtime.tv_nsec = 0;
 	}
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
+}
 
+void __init time_init(void)
+{
 	mach_sched_init(timer_interrupt);
 }
 

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

* [tip:timers/cleanup] cris: Convert cris to use read/update_persistent_clock
  2010-03-04  3:57                         ` [PATCH 13/14] cris: Convert cris " John Stultz
  2010-03-04  3:57                           ` [PATCH 14/14] arm: Convert arm to use read_persistent_clock John Stultz
@ 2010-03-13  0:21                           ` tip-bot for John Stultz
  1 sibling, 0 replies; 34+ messages in thread
From: tip-bot for John Stultz @ 2010-03-13  0:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, jesper.nilsson, johnstul, akpm, starvik, tglx

Commit-ID:  8eff8a5c1d3a1de7a2d173e0effc6cc9bcbb5177
Gitweb:     http://git.kernel.org/tip/8eff8a5c1d3a1de7a2d173e0effc6cc9bcbb5177
Author:     John Stultz <johnstul@us.ibm.com>
AuthorDate: Wed, 3 Mar 2010 19:57:28 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Mar 2010 01:14:13 +0100

cris: Convert cris to use read/update_persistent_clock

This patch converts the cris architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-14-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/cris/Kconfig                |    3 ++
 arch/cris/arch-v10/kernel/time.c |   37 +---------------------------------
 arch/cris/arch-v32/kernel/time.c |   40 +------------------------------------
 arch/cris/kernel/time.c          |   20 ++++++++++--------
 4 files changed, 18 insertions(+), 82 deletions(-)

diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 059eac6..e25bf44 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -23,6 +23,9 @@ config RWSEM_XCHGADD_ALGORITHM
 config GENERIC_TIME
 	def_bool y
 
+config GENERIC_CMOS_UPDATE
+	def_bool y
+
 config ARCH_USES_GETTIMEOFFSET
 	def_bool y
 
diff --git a/arch/cris/arch-v10/kernel/time.c b/arch/cris/arch-v10/kernel/time.c
index 31ca141..30adae5 100644
--- a/arch/cris/arch-v10/kernel/time.c
+++ b/arch/cris/arch-v10/kernel/time.c
@@ -26,7 +26,6 @@
 /* it will make jiffies at 96 hz instead of 100 hz though */
 #undef USE_CASCADE_TIMERS
 
-extern void update_xtime_from_cmos(void);
 extern int set_rtc_mmss(unsigned long nowtime);
 extern int have_rtc;
 
@@ -188,8 +187,6 @@ stop_watchdog(void)
 #endif	
 }
 
-/* last time the cmos clock got updated */
-static long last_rtc_update = 0;
 
 /*
  * timer_interrupt() needs to keep up the real-time clock,
@@ -232,24 +229,6 @@ timer_interrupt(int irq, void *dev_id)
 	do_timer(1);
 	
         cris_do_profile(regs); /* Save profiling information */
-
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 *
-	 * The division here is not time critical since it will run once in 
-	 * 11 minutes
-	 */
-	if (ntp_synced() &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
-	}
         return IRQ_HANDLED;
 }
 
@@ -274,22 +253,10 @@ time_init(void)
 	 */
 	loops_per_usec = 50;
 
-	if(RTC_INIT() < 0) {
-		/* no RTC, start at 1980 */
-		xtime.tv_sec = 0;
-		xtime.tv_nsec = 0;
+	if(RTC_INIT() < 0)
 		have_rtc = 0;
-	} else {		
-		/* get the current time */
+	else
 		have_rtc = 1;
-		update_xtime_from_cmos();
-	}
-
-	/*
-	 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
-	 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
-	 */
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 
 	/* Setup the etrax timers
 	 * Base frequency is 25000 hz, divider 250 -> 100 HZ
diff --git a/arch/cris/arch-v32/kernel/time.c b/arch/cris/arch-v32/kernel/time.c
index b1920d8..1ee0e10 100644
--- a/arch/cris/arch-v32/kernel/time.c
+++ b/arch/cris/arch-v32/kernel/time.c
@@ -44,7 +44,6 @@ unsigned long timer_regs[NR_CPUS] =
 #endif
 };
 
-extern void update_xtime_from_cmos(void);
 extern int set_rtc_mmss(unsigned long nowtime);
 extern int have_rtc;
 
@@ -198,9 +197,6 @@ handle_watchdog_bite(struct pt_regs* regs)
 #endif
 }
 
-/* Last time the cmos clock got updated. */
-static long last_rtc_update = 0;
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick.
@@ -238,25 +234,6 @@ timer_interrupt(int irq, void *dev_id)
 
 	/* Call the real timer interrupt handler */
 	do_timer(1);
-
-	/*
-	 * If we have an externally synchronized Linux clock, then update
-	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-	 * called as close as possible to 500 ms before the new second starts.
-	 *
-	 * The division here is not time critical since it will run once in
-	 * 11 minutes
-	 */
-	if ((time_status & STA_UNSYNC) == 0 &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
-	    (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* Do it again in 60 s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
         return IRQ_HANDLED;
 }
 
@@ -309,23 +286,10 @@ time_init(void)
 	 */
 	loops_per_usec = 50;
 
-	if(RTC_INIT() < 0) {
-		/* No RTC, start at 1980 */
-		xtime.tv_sec = 0;
-		xtime.tv_nsec = 0;
+	if(RTC_INIT() < 0)
 		have_rtc = 0;
-	} else {
-		/* Get the current time */
+	else
 		have_rtc = 1;
-		update_xtime_from_cmos();
-	}
-
-	/*
-	 * Initialize wall_to_monotonic such that adding it to
-	 * xtime will yield zero, the tv_nsec field must be normalized
-	 * (i.e., 0 <= nsec < NSEC_PER_SEC).
-	 */
-	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 
 	/* Start CPU local timer. */
 	cris_timer_init();
diff --git a/arch/cris/kernel/time.c b/arch/cris/kernel/time.c
index a05dd31..c72730d 100644
--- a/arch/cris/kernel/time.c
+++ b/arch/cris/kernel/time.c
@@ -98,6 +98,8 @@ unsigned long
 get_cmos_time(void)
 {
 	unsigned int year, mon, day, hour, min, sec;
+	if(!have_rtc)
+		return 0;
 
 	sec = CMOS_READ(RTC_SECONDS);
 	min = CMOS_READ(RTC_MINUTES);
@@ -119,19 +121,19 @@ get_cmos_time(void)
 	return mktime(year, mon, day, hour, min, sec);
 }
 
-/* update xtime from the CMOS settings. used when /dev/rtc gets a SET_TIME.
- * TODO: this doesn't reset the fancy NTP phase stuff as do_settimeofday does.
- */
 
-void
-update_xtime_from_cmos(void)
+int update_persistent_clock(struct timespec now)
 {
-	if(have_rtc) {
-		xtime.tv_sec = get_cmos_time();
-		xtime.tv_nsec = 0;
-	}
+	return set_rtc_mmss(now.tv_sec);
 }
 
+void read_persistent_clock(struct timespec *ts)
+{
+	ts->tv_sec = get_cmos_time();
+	ts->tv_nsec = 0;
+}
+
+
 extern void cris_profile_sample(struct pt_regs* regs);
 
 void

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

end of thread, other threads:[~2010-03-13  1:32 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04  3:57 [PATCH 00/14] Convert remaining arches to use read/update_persistent_clock John Stultz
2010-03-04  3:57 ` [PATCH 01/14] alpha: Convert alpha " John Stultz
2010-03-04  3:57   ` [PATCH 02/14] mn10300: Convert mn10300 " John Stultz
2010-03-04  3:57     ` [PATCH 03/14] frv: Convert frv " John Stultz
2010-03-04  3:57       ` [PATCH 04/14] parisc: Convert parisc " John Stultz
2010-03-04  3:57         ` [PATCH 05/14] h8300: Convert h8300 " John Stultz
2010-03-04  3:57           ` [PATCH 06/14] avr32: Convert avr32 " John Stultz
2010-03-04  3:57             ` [PATCH 07/14] ia64: Convert ia64 " John Stultz
2010-03-04  3:57               ` [PATCH 08/14] sh: Convert sh " John Stultz
2010-03-04  3:57                 ` [PATCH 09/14] blackfin: Convert blackfin " John Stultz
2010-03-04  3:57                   ` [PATCH 10/14] m32r: Convert m32r to use read/update_peristent_clock John Stultz
2010-03-04  3:57                     ` [PATCH 11/14] m68k: Convert m68k to use read/update_persistent_clock John Stultz
2010-03-04  3:57                       ` [PATCH 12/14] sparc: Convert sparc " John Stultz
2010-03-04  3:57                         ` [PATCH 13/14] cris: Convert cris " John Stultz
2010-03-04  3:57                           ` [PATCH 14/14] arm: Convert arm to use read_persistent_clock John Stultz
2010-03-04  9:36                             ` Russell King - ARM Linux
2010-03-04 19:55                               ` john stultz
2010-03-13  0:21                           ` [tip:timers/cleanup] cris: Convert cris to use read/update_persistent_clock tip-bot for John Stultz
2010-03-04  6:41                         ` [PATCH 12/14] sparc: Convert sparc " David Miller
2010-03-13  0:21                       ` [tip:timers/cleanup] m68k: Convert m68k " tip-bot for John Stultz
2010-03-13  0:21                     ` [tip:timers/cleanup] m32r: Convert m32r to use read/update_peristent_clock tip-bot for John Stultz
2010-03-09 23:53                   ` [PATCH 09/14] blackfin: Convert blackfin to use read/update_persistent_clock Mike Frysinger
2010-03-09 23:59                     ` john stultz
2010-03-10  0:01                       ` Mike Frysinger
2010-03-13  0:20                   ` [tip:timers/cleanup] " tip-bot for John Stultz
2010-03-04 17:00                 ` [PATCH 08/14] sh: Convert sh " Paul Mundt
2010-03-13  0:20               ` [tip:timers/cleanup] ia64: Convert ia64 " tip-bot for John Stultz
2010-03-13  0:20             ` [tip:timers/cleanup] avr32: Convert avr32 " tip-bot for John Stultz
2010-03-13  0:20           ` [tip:timers/cleanup] h8300: Convert h8300 " tip-bot for John Stultz
2010-03-06 22:40         ` [PATCH 04/14] parisc: Convert parisc " Helge Deller
2010-03-06 22:49           ` Kyle McMartin
2010-03-13  0:19       ` [tip:timers/cleanup] frv: Convert frv " tip-bot for John Stultz
2010-03-13  0:19     ` [tip:timers/cleanup] mn10300: Convert mn10300 " tip-bot for John Stultz
2010-03-13  0:19   ` [tip:timers/cleanup] alpha: Convert alpha " tip-bot for John Stultz

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.