linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 2/14] Convert arm to read/update_persistent_clock
       [not found] ` <1261540826.3508.62.camel@localhost.localdomain>
@ 2009-12-23  4:01   ` john stultz
  2009-12-24 11:09     ` Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: john stultz @ 2009-12-23  4:01 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 Kconfig                 |    3 +++
 include/asm/mach/time.h |    2 +-
 kernel/time.c           |   39 ++++++++-------------------------------
 mach-footbridge/time.c  |    4 ++--
 4 files changed, 14 insertions(+), 34 deletions(-)

Index: gettimeoffset/arch/arm/Kconfig
===================================================================
--- gettimeoffset.orig/arch/arm/Kconfig	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/Kconfig	2009-12-22 18:51:20.000000000 -0800
@@ -38,6 +38,9 @@ config GENERIC_GPIO
 config GENERIC_TIME
 	bool
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config GENERIC_CLOCKEVENTS
 	bool
 
Index: gettimeoffset/arch/arm/include/asm/mach/time.h
===================================================================
--- gettimeoffset.orig/arch/arm/include/asm/mach/time.h	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/include/asm/mach/time.h	2009-12-22 18:51:20.000000000 -0800
@@ -50,7 +50,7 @@ extern void timer_tick(void);
  * Kernel time keeping support.
  */
 struct timespec;
-extern int (*set_rtc)(void);
+extern int (*set_rtc)(struct timespec now);
 extern void save_time_delta(struct timespec *delta, struct timespec *rtc);
 extern void restore_time_delta(struct timespec *delta, struct timespec *rtc);
 
Index: gettimeoffset/arch/arm/kernel/time.c
===================================================================
--- gettimeoffset.orig/arch/arm/kernel/time.c	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/kernel/time.c	2009-12-22 18:51:20.000000000 -0800
@@ -80,7 +80,7 @@ EXPORT_SYMBOL(profile_pc);
 /*
  * hook for setting the RTC's idea of the current time.
  */
-int (*set_rtc)(void);
+int (*set_rtc)(struct timespec now);
 
 #ifndef CONFIG_GENERIC_TIME
 static unsigned long dummy_gettimeoffset(void)
@@ -89,34 +89,11 @@ static unsigned long dummy_gettimeoffset
 }
 #endif
 
-static unsigned long next_rtc_update;
-
-/*
- * If we have an externally synchronized linux clock, then update
- * CMOS clock accordingly every ~11 minutes.  set_rtc() has to be
- * called as close as possible to 500 ms before the new second
- * starts.
- */
-static inline void do_set_rtc(void)
+int update_persistent_clock(struct timespec now)
 {
-	if (!ntp_synced() || set_rtc == NULL)
-		return;
-
-	if (next_rtc_update &&
-	    time_before((unsigned long)xtime.tv_sec, next_rtc_update))
-		return;
-
-	if (xtime.tv_nsec < 500000000 - ((unsigned) tick_nsec >> 1) &&
-	    xtime.tv_nsec >= 500000000 + ((unsigned) tick_nsec >> 1))
-		return;
-
-	if (set_rtc())
-		/*
-		 * rtc update failed.  Try again in 60s
-		 */
-		next_rtc_update = xtime.tv_sec + 60;
-	else
-		next_rtc_update = xtime.tv_sec + 660;
+	if (set_rtc == NULL)
+		return -1;
+	return set_rtc(now);
 }
 
 #ifdef CONFIG_LEDS
@@ -305,9 +282,10 @@ EXPORT_SYMBOL(do_settimeofday);
  */
 void save_time_delta(struct timespec *delta, struct timespec *rtc)
 {
+	struct timespec now = current_kernel_time();
 	set_normalized_timespec(delta,
-				xtime.tv_sec - rtc->tv_sec,
-				xtime.tv_nsec - rtc->tv_nsec);
+				now.tv_sec - rtc->tv_sec,
+				now.tv_nsec - rtc->tv_nsec);
 }
 EXPORT_SYMBOL(save_time_delta);
 
@@ -336,7 +314,6 @@ void timer_tick(void)
 {
 	profile_tick(CPU_PROFILING);
 	do_leds();
-	do_set_rtc();
 	write_seqlock(&xtime_lock);
 	do_timer(1);
 	write_sequnlock(&xtime_lock);
Index: gettimeoffset/arch/arm/mach-footbridge/time.c
===================================================================
--- gettimeoffset.orig/arch/arm/mach-footbridge/time.c	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/mach-footbridge/time.c	2009-12-22 18:51:20.000000000 -0800
@@ -61,12 +61,12 @@ static unsigned long __init get_isa_cmos
 	return mktime(year, mon, day, hour, min, sec);
 }
 
-static int set_isa_cmos_time(void)
+static int set_isa_cmos_time(struct timespec now)
 {
 	int retval = 0;
 	int real_seconds, real_minutes, cmos_minutes;
 	unsigned char save_control, save_freq_select;
-	unsigned long nowtime = xtime.tv_sec;
+	unsigned long nowtime = now.tv_sec;
 
 	save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
 	CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);

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

* [RFC][PATCH 2/14] Convert arm to read/update_persistent_clock
  2009-12-23  4:01   ` [RFC][PATCH 2/14] Convert arm to read/update_persistent_clock john stultz
@ 2009-12-24 11:09     ` Uwe Kleine-König
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2009-12-24 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Tue, Dec 22, 2009 at 08:01:42PM -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.
> 
> 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.
I havn't tested either, but built footbridge_defconfig successfully.
bloat-o-meter reports:

add/remove: 4/1 grow/shrink: 2/2 up/down: 388/-196 (192)
function                                     old     new   delta
sync_cmos_clock                                -     240    +240
update_persistent_clock                        -      52     +52
sync_cmos_work                                 -      40     +40
do_adjtimex                                 1924    1956     +32
save_time_delta                               56      76     +20
no_sync_cmos_clock                             -       4      +4
next_rtc_update                                4       -      -4
set_isa_cmos_time                            372     364      -8
timer_tick                                   324     140    -184

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2009-12-24 11:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1261540762.3508.61.camel@localhost.localdomain>
     [not found] ` <1261540826.3508.62.camel@localhost.localdomain>
2009-12-23  4:01   ` [RFC][PATCH 2/14] Convert arm to read/update_persistent_clock john stultz
2009-12-24 11:09     ` Uwe Kleine-König

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