Skip to contentSkip to conversation

rtc again...

DISCUSSION Takashi Oe 2 participants 3 messages Aug 5, 2000 1 message not in the archive

lore
Share & tools
lore

Takashi Oe

author
#1 lore raw
In reply to a message not in the archive
Quoted 12 lines · Benjamin Herrenschmidt
Quoted 12 lines

Ok, the usage of "sys_tz" or "struct timezone" in general in kernel is not well defined or confused. kernel/time.c seems to assume "tz_minuteswest" includes DST fix up, while fs/fat/misc.c uses "tz_minuteswest" for time zone and "tz_dsttime" for DST fix up. The code in pmac_set_rtc_time() doesn't work if "tz_minuteswest" doesn't include the DST fix up, so, if that's the correct behaviour, the following code in pmac_time_init() needs to be tweaked for consistency in my opinion from:

	sys_tz.tz_minuteswest = -delta/60;
	/* I _suppose_ this is 0:off, 1:on */
	sys_tz.tz_dsttime = dst;
Quoted 8 lines
Quoted 4 lines

to

	sys_tz.tz_minuteswest = -delta/60 - (dst? 60: 0);
	sys_tz.tz_dsttime = dst;

Well, who is right ? time.c or fs/fat/misc.c ? Maybe we should query the powers that be... Did you look at what the userland hwclock expects in tz_dsttime ?

As Geert has pointed out, hwclock can give UTC or local time to /dev/rtc, why don't we just let userland deal with this local time issue. What I mean is for pmac_set_rtc_time(), let's change:

	nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60;

to

	nowtime += RTC_OFFSET;

and we assume that userland will give us the correct local time.

For pmac_time_init(), let's change:

	sys_tz.tz_minuteswest = -delta/60;
	/* I _suppose_ this is 0:off, 1:on */
	sys_tz.tz_dsttime = dst;

to

	sys_tz.tz_minuteswest = -delta/60 - (dst? 60: 0);
	sys_tz.tz_dsttime = 0;

which is what's been done in hwclock source and a reasonable compromise, I think, so that both kernel/time.c and fs/fat/misc.c would be happy.

How about it?

Takashi Oe

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw
Quoted 5 lines

As Geert has pointed out, hwclock can give UTC or local time to /dev/rtc, why don't we just let userland deal with this local time issue. What I mean is for pmac_set_rtc_time(), let's change:

That would give us back what we had at the beginning. This way, userland is solely responsible for this setup, which means it will be wrong on 50% of user machines (but that's user fault isn't it ?) and which means the kernel will boot with a wrong time, at least until the userland init script takes over.

I don't see why it's such a mess to simply read the default values from xpram so we are consistent with MacOS. But everything in Linux is a mess anyway...

Ben.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

author
#3 lore raw
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 4 lines

As Geert has pointed out, hwclock can give UTC or local time to /dev/rtc, why don't we just let userland deal with this local time issue. What I mean is for pmac_set_rtc_time(), let's change:

That would give us back what we had at the beginning. This way, userland is solely responsible for this setup, which means it will be wrong on 50% of user machines (but that's user fault isn't it ?) and which means the kernel will boot with a wrong time, at least until the userland init script takes over.

Hmm, nothing has been changed with pmac_get_rtc_time(). So, if it is broken now, it was broken before.... Seriously, pmac_get_rtc_time() is the one responsible for giving you the correct time at boot time, isn't it?

Does xtime need to be in UTC? If so, is it feasible to let ppc_md.time_init() give an offset in seconds from UTC to the time given by RTC?

void __init time_init(void)

  {
	unsigned long flags;

+ int offset = 0;
if (ppc_md.time_init != NULL)
{
offset = ppc_md.time_init();
}

	...
  	write_lock_irqsave(&xtime_lock, flags);
- 	xtime.tv_sec = ppc_md.get_rtc_time();
+ 	xtime.tv_sec = ppc_md.get_rtc_time() + offset;
  	write_unlock_irqrestore(&xtime_lock, flags);
	...

Oh, and change time_sleep_notify() in pmac_time.c accordingly.

Quoted 3 lines

I don't see why it's such a mess to simply read the default values from xpram so we are consistent with MacOS. But everything in Linux is a mess anyway...

Maybe because pmac's RTC is in local time for one?

Takashi Oe

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/