linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] ppc misusing NTP's time_offset value
@ 2005-06-29 22:05 john stultz
  2005-06-30 17:41 ` Tom Rini
  0 siblings, 1 reply; 4+ messages in thread
From: john stultz @ 2005-06-29 22:05 UTC (permalink / raw)
  To: lkml, benh, paulus; +Cc: linuxppc-dev

Hey everyone,

	As part of my timeofday rework, I've been looking at the NTP code and I
noticed that the PPC architecture is apparently misusing the NTP's
time_offset (it is a terrible name!) value as some form of timezone
offset. This could cause problems when time_offset changed by the NTP
code.
	
	This patch changes the PPC code so it uses a more clear local variable:
timezone_offset.

Could a PPC maintainer verify this is correct?

Let me know if you have any comments or feedback.

thanks
-john

Signed-off-by: John Stultz <johnstul@us.ibm.com>

diff --git a/arch/ppc/kernel/time.c b/arch/ppc/kernel/time.c
--- a/arch/ppc/kernel/time.c
+++ b/arch/ppc/kernel/time.c
@@ -90,6 +90,9 @@ unsigned long tb_to_ns_scale;
 
 extern unsigned long wall_jiffies;
 
+/* used for timezone offset */
+static long timezone_offset;
+
 DEFINE_SPINLOCK(rtc_lock);
 
 EXPORT_SYMBOL(rtc_lock);
@@ -171,7 +174,7 @@ void timer_interrupt(struct pt_regs * re
 		     xtime.tv_sec - last_rtc_update >= 659 &&
 		     abs((xtime.tv_nsec / 1000) - (1000000-1000000/HZ)) < 500000/HZ &&
 		     jiffies - wall_jiffies == 1) {
-		  	if (ppc_md.set_rtc_time(xtime.tv_sec+1 + time_offset) == 0)
+		  	if (ppc_md.set_rtc_time(xtime.tv_sec+1 + timezone_offset) == 0)
 				last_rtc_update = xtime.tv_sec+1;
 			else
 				/* Try again one minute later */
@@ -284,7 +287,7 @@ void __init time_init(void)
 	unsigned old_stamp, stamp, elapsed;
 
         if (ppc_md.time_init != NULL)
-                time_offset = ppc_md.time_init();
+                timezone_offset = ppc_md.time_init();
 
 	if (__USE_RTC()) {
 		/* 601 processor: dec counts down by 128 every 128ns */
@@ -329,10 +332,10 @@ void __init time_init(void)
 	set_dec(tb_ticks_per_jiffy);
 
 	/* If platform provided a timezone (pmac), we correct the time */
-        if (time_offset) {
-		sys_tz.tz_minuteswest = -time_offset / 60;
+        if (timezone_offset) {
+		sys_tz.tz_minuteswest = -timezone_offset / 60;
 		sys_tz.tz_dsttime = 0;
-		xtime.tv_sec -= time_offset;
+		xtime.tv_sec -= timezone_offset;
         }
         set_normalized_timespec(&wall_to_monotonic,
                                 -xtime.tv_sec, -xtime.tv_nsec);

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [RFC][PATCH] ppc misusing NTP's time_offset value
@ 2005-06-30 10:15 Mikael Pettersson
  2005-06-30 11:53 ` Kumar Gala
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Pettersson @ 2005-06-30 10:15 UTC (permalink / raw)
  To: benh, johnstul, linux-kernel, paulus; +Cc: linuxppc-dev

On Wed, 29 Jun 2005 15:05:51 -0700, john stultz wrote:
>	As part of my timeofday rework, I've been looking at the NTP code and I
>noticed that the PPC architecture is apparently misusing the NTP's
>time_offset (it is a terrible name!) value as some form of timezone
>offset. This could cause problems when time_offset changed by the NTP
>code.
>	
>	This patch changes the PPC code so it uses a more clear local variable:
>timezone_offset.
>
>Could a PPC maintainer verify this is correct?
>
>Let me know if you have any comments or feedback.

arch/ppc/kernel/time.c used to have a 'static long time_offset;'
variable. Ulthough unrelated, this declaration clashed with the
one for kernel/time.c, causing compile-time errors with gcc4.
I submitted a fix for this in February, which renamed ppc's local
variable, and it was ACKed by Tom Rini and queued for 2.6.12.

However, the patch that actually went into 2.6.12 was different:
it just removed ppc's local variable, making arch/ppc/kernel/time.c
now share kernel/time.c's variable. At the time I assumed someone
had proved that the two modules _should_ share state, so I didn't
make a fuss about it.

Your patch brings the semantics back to what it was prior to 2.6.12.

/Mikael

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

end of thread, other threads:[~2005-06-30 18:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-29 22:05 [RFC][PATCH] ppc misusing NTP's time_offset value john stultz
2005-06-30 17:41 ` Tom Rini
  -- strict thread matches above, loose matches on Subject: below --
2005-06-30 10:15 Mikael Pettersson
2005-06-30 11:53 ` Kumar Gala

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).