rtc again...
Hi,
under 2.2.17pre15ben1
rtc does not give me the right answer when built in - what am I doing wrong?
It won't build load as a module right now 'cos I forgot to check ppc_ksyms before doing the build :-( .... (I remembered for 2.4.0).
under 2.4.0-test5 it seems to be fine as a module (haven't tried built in).
Iain.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 11 lines · Iain Sandoe
Hi,
under 2.2.17pre15ben1
rtc does not give me the right answer when built in - what am I doing wrong?
It won't build load as a module right now 'cos I forgot to check
ppc_ksymsbefore doing the build :-( .... (I remembered for 2.4.0).under 2.4.0-test5 it seems to be fine as a module (haven't tried built in).
I am using it as module both for 2.2.17-bk and for 2.4.0-test5. They don't give the same time, and I think it is the one in 2.4.0 that is right. I am at GMT+2:00, and the time in 2.2.17 is 2 hours early. When I change /etc/sysconfig/clock from "UTC=false" to "UTC=true", both times shift by 2 hours, but the discrepancy remains.
The following patch for bitkeeper linuxppc_2_2 fixes this problem for me. It brings 2.2.17pre13 in line with 2.4.0-test5 (and MacOS). I cannot test the VIAPMU part, so maybe there the offset is necessary, but for the VIACUDA part, it seems wrong.
--
Martin
ppc/kernel/pmac_time.c renamed from ppc/kernel/pmac_time.c~ +2 -3
@@ -78,7 +78,6 @@unsigned long pmac_get_rtc_time (void ) {struct adb_request req; -int offset = sys_tz.tz_minuteswest *60 ;/* Get the time from the RTC */ if (adb_controller ==0 )
@@ -95,7 +94,7 @@printk (KERN_ERR "pmac_get_rtc_time: got %d byte reply\n" , req.reply_len);return (req.reply[3 ] <<24 ) + (req.reply[4 ] <<16 ) - + (req.reply[5 ] <<8 ) + req.reply[6 ] -RTC_OFFSET + offset; + + (req.reply[5 ] <<8 ) + req.reply[6 ] -RTC_OFFSET ;case ADB_VIAPMU :if (pmu_request (&req,NULL ,1 ,PMU_READ_RTC ) <0 ) {printk ("pmac_read_rtc_time: pmu_request failed\n" );
@@ -107,7 +106,7 @@printk (KERN_ERR "pmac_get_rtc_time: got %d byte reply\n" , req.reply_len);return (req.reply[1 ] <<24 ) + (req.reply[2 ] <<16 ) - + (req.reply[3 ] <<8 ) + req.reply[4 ] -RTC_OFFSET + offset; + + (req.reply[3 ] <<8 ) + req.reply[4 ] -RTC_OFFSET ;default :return 0 ; }
Quoted 11 lines
I am using it as module both for 2.2.17-bk and for 2.4.0-test5. They don't give the same time, and I think it is the one in 2.4.0 that is right. I am at GMT+2:00, and the time in 2.2.17 is 2 hours early. When I change
/etc/sysconfig/clockfrom "UTC=false" to "UTC=true", both times shift by 2 hours, but the discrepancy remains.The following patch for bitkeeper
linuxppc_2_2fixes this problem for me. It brings 2.2.17pre13 in line with 2.4.0-test5 (and MacOS). I cannot test the VIAPMU part, so maybe there the offset is necessary, but for the VIACUDA part, it seems wrong.
You patch reverts a fix I made some time ago. Basially, what probably happens is that your RTC is in UTC time, not in local time. The Mac RTC is supposed to be in local time, the offset corrects the kernel time on boot to account for this. Previously, without that fix, the kernel used to boot with a bogus UTC time until userland fixes it.
Ben.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 12 lines · Martin Costabel
Quoted 6 lines · Iain Sandoe
Hi,
under 2.2.17pre15ben1
rtc does not give me the right answer when built in - what am I doing
wrong?
Quoted 4 lines
It won't build load as a module right now 'cos I forgot to check
ppc_ksymsbefore doing the build :-( .... (I remembered for 2.4.0).
Quoted 7 lines
Quoted 1 line
under 2.4.0-test5 it seems to be fine as a module (haven't tried built in).
I am using it as module both for 2.2.17-bk and for 2.4.0-test5. They don't give the same time, and I think it is the one in 2.4.0 that is right. I am at GMT+2:00, and the time in 2.2.17 is 2 hours early. When I change
/etc/sysconfig/clockfrom "UTC=false" to "UTC=true", both times shift by 2 hours, but the discrepancy remains.
Are you sure you are using the "hwclock" utility coming with util-linux? And not the old pmac specific "clock" utility to query the clock? What happens if you remove all "clock" binaries from your system?
Franz.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 12 lines · Benjamin Herrenschmidt
Quoted 11 lines
I am using it as module both for 2.2.17-bk and for 2.4.0-test5. They don't give the same time, and I think it is the one in 2.4.0 that is right. I am at GMT+2:00, and the time in 2.2.17 is 2 hours early. When I change
/etc/sysconfig/clockfrom "UTC=false" to "UTC=true", both times shift by 2 hours, but the discrepancy remains.The following patch for bitkeeper
linuxppc_2_2fixes this problem for me. It brings 2.2.17pre13 in line with 2.4.0-test5 (and MacOS). I cannot test the VIAPMU part, so maybe there the offset is necessary, but for the VIACUDA part, it seems wrong.
Quoted 5 lines
You patch reverts a fix I made some time ago. Basially, what probably happens is that your RTC is in UTC time, not in local time. The Mac RTC is supposed to be in local time, the offset corrects the kernel time on boot to account for this. Previously, without that fix, the kernel used to boot with a bogus UTC time until userland fixes it.
Actually given the problems with RTC being UTC or local time, the offset might perhaps better be setup as a kernel parameter so that th system start up in a known good state. It seems that it is in RAM for Macs, but what about other machines (I have no problems since all my machines are UTC and I simply refuse to use an OS which requires anything else) ?
Ok, I have since long promised a patch for 2.4 to improve the clock precision, here it is (relative to kernel.org 2.4.0-test5) but it has only been tested on my MVME boards. There is still quite a long TODO list I have added to time.c but at least stability is there on UP machines at least (it should work perfectly on SMP if timebases are in sync).
I have doubts about 8xx: it won't work if the timebase is really running below 1 MHz, but you can't expect 1 microsecond resolution timestamps either in this case. The fix is quite easy however but requires an additional global variable. And no, I did not change the names of global variables for fun but to get linker error until the kernel would build.
Note that I have removed the #if 0 to prevent RTC update from Bemjamin, the code was completely bogus to start with: you should only update the RTC when STA_UNSYNC is clear, not when it is set. If you are using NTP, you don't need anything else: set CONFIG_PPC_RTC off, NTP does RTC updates through adjtimex and this should simply work right out of the box with this patch, at least it does for me and the clock is very stable.
I still see tremendously large long term drifts (of the order of 1 ppm) but this is due to the fact that el cheapo crystals on computers are actually narrowband noise sources and not precision oscillators.
Please test and give feedbcak.
Gabriel.
===== arch/ppc/kernel/apus_setup.c 1.2 vs 1.3 =====
arch/ppc/kernel/apus_setup.c +7 -9
@@ -304,7 +304,7 @@void apus_calibrate_decr (void ) {#ifdef CONFIG_APUS -int freq, divisor; +unsigned long freq;/* This algorithm for determining the bus speed was contributed by Ralph Schmidt. */
@@ -335,8 +335,8 @@ bus_speed =60 ; freq =15000000 ; }else if ((bus_speed >=63 ) && (bus_speed <69 )) { - bus_speed =66 ; - freq =16500000 ; + bus_speed =67 ; + freq =16666667 ; }else {printk ("APUS: Unable to determine bus speed (%d). " "Defaulting to 50MHz" , bus_speed);
@@ -375,12 +375,10 @@ } - freq *=60 ;/* try to make freq/1e6 an integer */ - divisor =60 ; -printk ("time_init: decrementer frequency = %d/%d\n" , freq, divisor); - decrementer_count = freq /HZ / divisor; - count_period_num = divisor; - count_period_den = freq /1000000 ; +printk ("time_init: decrementer frequency = %lu.%.6lu MHz\n" , + freq/1000000 , freq%1000000 ); + tb_ticks_per_jiffy = freq /HZ ; + tb_to_us =mulhwu_scale_factor (freq,1000000 ); __bus_speed = bus_speed; __speed_test_failed = speed_test_failed;
===== arch/ppc/kernel/chrp_time.c 1.3 vs 1.5 =====
arch/ppc/kernel/chrp_time.c +9 -12
@@ -26,7 +26,7 @@#include <asm/nvram.h> #include <asm/prom.h> #include <asm/init.h> -#include "time.h" +#include <asm/time.h> static int nvram_as1 =NVRAM_AS1 ;static int nvram_as0 =NVRAM_AS0 ;
@@ -155,8 +155,7 @@void __init chrp_calibrate_decr (void ) {struct device_node *cpu; -int *fp, divisor; -unsigned long freq; +unsigned long freq, *fp;if (via_calibrate_decr ())return ;
@@ -168,15 +167,13 @@ freq =16666000 ;/* hardcoded default */ cpu =find_type_devices ("cpu" );if (cpu !=0 ) { - fp = (int *)get_property (cpu,"timebase-frequency" ,NULL ); + fp = (unsigned long *) +get_property (cpu,"timebase-frequency" ,NULL );if (fp !=0 ) - freq = *fp; + freq = *fp; } - freq *=30 ; - divisor =30 ; -printk ("time_init: decrementer frequency = %lu/%d (%ld MHz)\n" , freq, - divisor, (freq/divisor)>>20 ); - decrementer_count = freq /HZ / divisor; - count_period_num = divisor; - count_period_den = freq /1000000 ; +printk ("time_init: decrementer frequency = %lu.%.6lu MHz\n" , + freq/1000000 , freq%1000000 ); + tb_ticks_per_jiffy = freq /HZ ; + tb_to_us =mulhwu_scale_factor (freq,1000000 ); }
===== arch/ppc/kernel/pmac_time.c 1.2 vs 1.5 =====
arch/ppc/kernel/pmac_time.c +72 -18
136 lines not on this page · raw message
===== arch/ppc/kernel/ppc_ksyms.c 1.8 vs 1.10 =====
arch/ppc/kernel/ppc_ksyms.c +1 -1
@@ -281,7 +281,7 @@EXPORT_SYMBOL (irq_desc);void ppc_irq_dispatch_handler (struct pt_regs *,int );EXPORT_SYMBOL (ppc_irq_dispatch_handler); -EXPORT_SYMBOL (decrementer_count); +EXPORT_SYMBOL (tb_ticks_per_jiffy);EXPORT_SYMBOL (get_wchan);EXPORT_SYMBOL (console_drivers);EXPORT_SYMBOL (console_lock);
===== arch/ppc/kernel/prep_setup.c 1.3 vs 1.5 =====
arch/ppc/kernel/prep_setup.c +39 -40
136 lines not on this page · raw message
===== arch/ppc/kernel/time.c 1.4 vs 1.7 =====
arch/ppc/kernel/time.c +140 -76
298 lines not on this page · raw message
===== include/asm-ppc/time.h 1.1 vs 1.4 =====
include/asm-ppc/time.h renamed from arch/ppc/kernel/time.h +74 -3
86 lines not on this page · raw message
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 7 lines
Actually given the problems with RTC being UTC or local time, the offset might perhaps better be setup as a kernel parameter so that th system start up in a known good state. It seems that it is in RAM for Macs, but what about other machines (I have no problems since all my machines are UTC and I simply refuse to use an OS which requires anything else) ?
Most "sane" RTCs are in UTC. On PReP and CHRP, this is not a problem, they use, I think, legacy RTC hardware and so you just need to set it up correctly in UTC.
On Macs, it's slightly different. MacOS expects the RTC to be in local time and stores the timezone and DSL state in PRAM. I recently added fixup code in pmac_time.c for reading that value and correctly setting the kernel timezone at boot from it. Paul improved on my code by adding the ability to save modified timezone back to PRAM. I think there's still an issue with DST. There's a field for storing it in the kernel tz structure, but I'm not sure it's fully defined or used. I beleive this could be easily fixed by looking at what hwclock does, and eventually fixing it.
Note that all this affects only powermacs, and the /dev/rtc driver we are talking about here is the pmac-only one in drivers/macintosh.
Quoted 6 lines
Note that I have removed the #if 0 to prevent RTC update from Bemjamin, the code was completely bogus to start with: you should only update the RTC when
STA_UNSYNCis clear, not when it is set. If you are using NTP, you don't need anything else: setCONFIG_PPC_RTCoff, NTP does RTC updates through adjtimex and this should simply work right out of the box with this patch, at least it does for me and the clock is very stable.
Did you remove the #if 0 or did you remove the code that is #if 0'ed ? That code seem to originate from other archs and was causing a lot of trouble when enabling the pmac_rtc_set_time() since it was writing bogus times to the RTC during boot (at that time, I didn't yet added the code to read the timezone from the PRAM).
Also, I didn't see why the kernel would keep updating the RTC hardware, the sounded bogus to me and a userland matter, not a kernel matter (but maybe I missed something). So I #if'ed it out. Removing it completely sounds fine.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 31 lines · Benjamin Herrenschmidt
Quoted 6 lines
Actually given the problems with RTC being UTC or local time, the offset might perhaps better be setup as a kernel parameter so that th system start up in a known good state. It seems that it is in RAM for Macs, but what about other machines (I have no problems since all my machines are UTC and I simply refuse to use an OS which requires anything else) ?
Most "sane" RTCs are in UTC. On PReP and CHRP, this is not a problem, they use, I think, legacy RTC hardware and so you just need to set it up correctly in UTC.
On Macs, it's slightly different. MacOS expects the RTC to be in local time and stores the timezone and DSL state in PRAM. I recently added fixup code in
pmac_time.cfor reading that value and correctly setting the kernel timezone at boot from it. Paul improved on my code by adding the ability to save modified timezone back to PRAM. I think there's still an issue with DST. There's a field for storing it in the kernel tz structure, but I'm not sure it's fully defined or used. I beleive this could be easily fixed by looking at what hwclock does, and eventually fixing it.Note that all this affects only powermacs, and the
/dev/rtcdriver we are talking about here is the pmac-only one indrivers/macintosh.Quoted 6 lines
Note that I have removed the #if 0 to prevent RTC update from Bemjamin, the code was completely bogus to start with: you should only update the RTC when
STA_UNSYNCis clear, not when it is set. If you are using NTP, you don't need anything else: setCONFIG_PPC_RTCoff, NTP does RTC updates through adjtimex and this should simply work right out of the box with this patch, at least it does for me and the clock is very stable.
Quoted 9 lines
Did you remove the #if 0 or did you remove the code that is #if 0'ed ? That code seem to originate from other archs and was causing a lot of trouble when enabling the
pmac_rtc_set_time()since it was writing bogus times to the RTC during boot (at that time, I didn't yet added the code to read the timezone from the PRAM).
Also, I didn't see why the kernel would keep updating the RTC hardware, the sounded bogus to me and a userland matter, not a kernel matter (but maybe I missed something). So I #if'ed it out. Removing it completely sounds fine.
No, I removed the #if 0, it was the condition STA_UNSYNC which was not correctly tested (inverted actually), and was missing a few additional conditions (on fractional seconds and so on):
- at boot you set STA_UNSYNC to prevent RTC updates (the inverted test made that RTC was updated asap instead),
- if you use NTP (as I do) the system uses adjtimex syscall to write into the RTC at regular intervals. NTP does not use /dev/rtc, it phases locks to another good source and lets the kernel update the RTC at regular intervals. This is how it works on all other archs, why would you want to add a full featured RTC driver when you only need a small subset (and this guarantees that your system time will be more or less correct when it reboots and ntp has trouble connecting to the time server) ?
Anyway, we might need something like the Intel port which only sets the minutes and seconds of the RTC for automatic RC updates. The problem is that the Intel code is wrong too (it can get the hours wrong if you change only the minutes). For the rest I looked at the Intel and Alpha code before doing my patch, and I'm fairly sure that is is for the most part correct given the results here (I'm rebooting regularly a machine and noting the offsets of ntpdate at each reboot to be sure that I have got the fractional second right).
As I said I want this patch tested, it might break some machines but will be a major timekeeping improvement for all other.
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 3 lines · Benjamin Herrenschmidt
Most "sane" RTCs are in UTC. On PReP and CHRP, this is not a problem, they use, I think, legacy RTC hardware and so you just need to set it up correctly in UTC.
Once upon a time, there was also NT for PowerPC, anyway using anything else than UTC in this world is simply madness (it gives ambiguous dates close to DST transition and is a mess in a connected world).
I'm now fighting problems with possible ambiguous timestamps around leap seconds (only 1 every 18 months or so but they may be a killer in my case), and trying to build a clean interface to get non ambiguous timestamps at 23:59:60 when it happens. (See what the kernel does in this case in kernel/timer.c about leap second processing, it simply sets the clock back one second and sets the TIME_OOP flag but there are additional problems if you want to get a non ambiguous timestamp in an interrupt between the timer interrupt and the following bottom-half).
RTC in CHRP and PreP are varied and far between. I'm still waiting for the new Motorola MVME boards in which they have increased the NVRAM size and the RTC is at the end, another set of quirks in perspective.
Quoted 9 lines
On Macs, it's slightly different. MacOS expects the RTC to be in local time and stores the timezone and DSL state in PRAM. I recently added fixup code in
pmac_time.cfor reading that value and correctly setting the kernel timezone at boot from it. Paul improved on my code by adding the ability to save modified timezone back to PRAM. I think there's still an issue with DST. There's a field for storing it in the kernel tz structure, but I'm not sure it's fully defined or used. I beleive this could be easily fixed by looking at what hwclock does, and eventually fixing it.
Do you have to change the clock every spring and autumn in MacOS ? Or is it automatic ?
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines
Do you have to change the clock every spring and autumn in MacOS ? Or is it automatic ?
MacOS has software to do this automatically.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 3 lines · Gabriel Paubert
=====
arch/ppc/kernel/pmac_time.c1.2 vs 1.5 =====arch/ppc/kernel/pmac_time.c +0
-0
[...]
arch/ppc/kernel/pmac_time.c line 124
Quoted 7 lines
int
pmac_set_rtc_time(unsigned long nowtime)
{arch/ppc/kernel/pmac_time.c +4
-1-return 0 ; +#ifdef CONFIG_ADB +struct adb_request req; +#endif + nowtime +=RTC_OFFSET - sys_tz.tz_minuteswest *60 ;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This needs to be changed to
+ nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60 + (sys_tz.tz_dsttime? 3600: 0);
Takashi Oe
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 14 lines · Takashi Oe
Quoted 3 lines · Gabriel Paubert
=====
arch/ppc/kernel/pmac_time.c1.2 vs 1.5 =====arch/ppc/kernel/pmac_time.c Mon Jul 31 11:28:27 2000 renamed from arch/ppc/kernel/pmac_time.c Mon Jun 19 19:59:36 2000 +0
-0[...]
arch/ppc/kernel/pmac_time.c Mon Jul 31 11:28:27 2000
Quoted 7 lines
int
pmac_set_rtc_time(unsigned long nowtime)
{arch/ppc/kernel/pmac_time.c Mon Jul 31 11:28:27 2000 renamed from arch/ppc/kernel/pmac_time.c Mon Jun 19 19:59:36 2000 +4
-1- return 0; +#ifdef CONFIG_ADB + struct adb_request req; +#endif + nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 4 lines
This needs to be changed to
+ nowtime +=
RTC_OFFSET- sys_tz.tz_minuteswest * 60 +
(sys_tz.tz_dsttime? 3600: 0);
No, don't handle DST in the kernel!! hwclock handles this in userland, see the hwclock source for details.
Franz.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 18 lines · Franz Sirl
Quoted 16 lines · Takashi Oe
Quoted 3 lines · Gabriel Paubert
=====
arch/ppc/kernel/pmac_time.c1.2 vs 1.5 =====arch/ppc/kernel/pmac_time.c Mon Jul 31 11:28:27 2000 renamed from arch/ppc/kernel/pmac_time.c Mon Jun 19 19:59:36 2000 +0
-0[...]
arch/ppc/kernel/pmac_time.c Mon Jul 31 11:28:27 2000
Quoted 7 lines
int
pmac_set_rtc_time(unsigned long nowtime)
{arch/ppc/kernel/pmac_time.c Mon Jul 31 11:28:27 2000 renamed from arch/ppc/kernel/pmac_time.c Mon Jun 19 19:59:36 2000 +4
-1- return 0; +#ifdef CONFIG_ADB + struct adb_request req; +#endif + nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This needs to be changed to
Quoted 5 lines
Quoted 2 lines
+ nowtime +=
RTC_OFFSET- sys_tz.tz_minuteswest * 60 +
(sys_tz.tz_dsttime? 3600: 0);No, don't handle DST in the kernel!! hwclock handles this in userland, see the hwclock source for details.
Oh, "nowtime" is UTC + DST fix up then??? If so, that seems to be broken to me.
Takashi Oe
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 16 lines · Takashi Oe
Quoted 3 lines · Gabriel Paubert
=====
arch/ppc/kernel/pmac_time.c1.2 vs 1.5 =====arch/ppc/kernel/pmac_time.c +0
-0[...]
arch/ppc/kernel/pmac_time.c line 124
Quoted 7 lines
int
pmac_set_rtc_time(unsigned long nowtime)
{arch/ppc/kernel/pmac_time.c +4
-1-return 0 ; +#ifdef CONFIG_ADB +struct adb_request req; +#endif + nowtime +=RTC_OFFSET - sys_tz.tz_minuteswest *60 ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This needs to be changed to
Review
Quoted 1 line
(quoted diff) +1
-0+ nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60 + (sys_tz.tz_dsttime? 3600: 0);
That's not my code, I took it from linux-2.4.0-test5, and I just added the CONFIG_ADB tests so that it links with a PreP config.
I want people to check my patch, with or without NTP and to stress the machines. All clock drifts should have vanished, which was the single most important goal of this patch. Anyway I have very strong opinions about running non UTC clocks and I won't repeat myslef here.
The other important points are:
- gettimeofday is faster (no divide, a single mulhwu which can't overflow by definition),
- 601 support (also faster than in my previous patch but could be wrong on SMP 601. There is a solution however).
What I need to know from people with an SMP machine:
- are the timebases synchronized ? Or is there a way to synchronize them ?
There are solutions for non synchronized timebases, but they are more complex so I wrote the simple solution first.
Regards,
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines
Oh, "nowtime" is UTC + DST fix up then??? If so, that seems to be broken to me
AFAIK, the timezone offset in nvram includes the DST fixup.
Ben.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 18 lines · Gabriel Paubert
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 10 lines
I am using it as module both for 2.2.17-bk and for 2.4.0-test5. They don't give the same time, and I think it is the one in 2.4.0 that is right. I am at GMT+2:00, and the time in 2.2.17 is 2 hours early. When I change
/etc/sysconfig/clockfrom "UTC=false" to "UTC=true", both times shift by 2 hours, but the discrepancy remains.The following patch for bitkeeper
linuxppc_2_2fixes this problem for me. It brings 2.2.17pre13 in line with 2.4.0-test5 (and MacOS). I cannot test the VIAPMU part, so maybe there the offset is necessary, but for the VIACUDA part, it seems wrong.Quoted 5 lines
You patch reverts a fix I made some time ago. Basially, what probably happens is that your RTC is in UTC time, not in local time. The Mac RTC is supposed to be in local time, the offset corrects the kernel time on boot to account for this. Previously, without that fix, the kernel used to boot with a bogus UTC time until userland fixes it.
Quoted 5 lines
Actually given the problems with RTC being UTC or local time, the offset might perhaps better be setup as a kernel parameter so that th system start up in a known good state. It seems that it is in RAM for Macs, but what about other machines (I have no problems since all my machines are UTC and I simply refuse to use an OS which requires anything else) ?
Why do you want to handle the offset in the kernel???
Any decent distro (e.g. Debian) allows to configure the time system for a hardware clock running in either UTC or local time, so the correction will be done on boot up.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 3 lines
Oh, "nowtime" is UTC + DST fix up then??? If so, that seems to be broken to me
AFAIK, the timezone offset in nvram includes the DST fixup.
Yes, that's right.
My assumption was "nowtime" given to kernel for pmac_set_rtc_time() is UTC. If that's the case, the following code in pmac_set_rtc_time()
nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60;
is incomplete because it does not include DST fix up and the time stored via CUDA or PMU will be an hour off from localtime which Mac OS uses during DST is in effect.
Is my assumption correct?
What I was saying is that if "nowtime" given to kernel is neither UTC or localtime, the interface seems to be broken (to me).
Takashi Oe
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Gabriel Paubert writes:
Gabriel> What I need to know from people with an SMP machine:
Gabriel> - are the timebases synchronized ? Or is there a way to synchronize them ?
On RS/6000 CHRP (RS/6000 Platform Architecture), RTAS provides
freeze-time-base and thaw-time-base calls which signal all of the processors inan SMP complex to stop and start the TB. I do not know of any functionality within the PowerPC architecture which would allow processors to coordinate their TBs without some external intervention.
Normally AIX boot freezes the TB, zeroes the TB on each processor,
and then starts the timebase synchronized. Because the functionality is part of RTAS, this can be done at any time. I do not know what PreP SMP systems do and I know that Apple discourages use of RTAS because it is not intended to work.
David
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 8 lines
On RS/6000 CHRP (RS/6000 Platform Architecture), RTAS provides
freeze-time-base and thaw-time-base calls which signal all of the processors inan SMP complex to stop and start the TB. I do not know of any functionality within the PowerPC architecture which would allow processors to coordinate their TBs without some external intervention.
Quoted 5 lines
Normally AIX boot freezes the TB, zeroes the TB on each processor,
and then starts the timebase synchronized. Because the functionality is part of RTAS, this can be done at any time. I do not know what PreP SMP systems do and I know that Apple discourages use of RTAS because it is not intended to work.
On recent Core99 machines, Apple has a HW timer in the KeyLargo ASIC that can be used to sync timebases. (It looks like a 64 bits bus-cycle timer, but I'm not completely sure yet). There's also, I beleive, the OpenPIC timer.
Ben.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 11 lines · David Edelsohn
On RS/6000 CHRP (RS/6000 Platform Architecture), RTAS provides
freeze-time-base and thaw-time-base calls which signal all of the processors inan SMP complex to stop and start the TB. I do not know of any functionality within the PowerPC architecture which would allow processors to coordinate their TBs without some external intervention.Normally AIX boot freezes the TB, zeroes the TB on each processor,
and then starts the timebase synchronized. Because the functionality is part of RTAS, this can be done at any time. I do not know what PreP SMP systems do and I know that Apple discourages use of RTAS because it is not intended to work.
Thanks for the info. AFAIK most (all?) PPC processors have a TBEN pin to enable the timebase (whether it affects the decrementer or not is irrelevant). On some chipsets (Motorola Falcon or Hawk at least) a few bits in a system control register are designated to control these pins with one bit per processor (although I fail to see why you would want to enable or disable the timebases individually).
Hard reset also clears the timebase on all the processors I know, so the time bases should be synchronized unless the firmware plays with them (assuming the HRESET pins are wired together).
However, all I needed to know is whether the firmware will start the machine with the timebases synchronized or not. As long as they are, the patch I suggested should work and give consistent, microsecond resolution gettimeofday on SMP. Actually only the low 32 bits of the timebase are used in the current code (even on 64 bit processors BTW) but I'd expect all 64 bits to be in sync anyway.
The only problem is to know what happens on SMP when a processor enters a deep low power mode which stops the timebase. Synchronizing again the timebase is not easy, probably system dependant and I don't have any system to test it. For now I'll treat it as a `don't do it, then' since ultimate power saving measures are not necessary in existing SMP systems.
Can anybody with a Macintosh SMP G4 confirm that the time bases are synchronized at boot ?
Gabriel
(still waiting for test results on the patch, including 601 machines).
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 3 lines · Benjamin Herrenschmidt
On recent Core99 machines, Apple has a HW timer in the KeyLargo ASIC that can be used to sync timebases. (It looks like a 64 bits bus-cycle timer, but I'm not completely sure yet). There's also, I beleive, the OpenPIC timer.
OpenPIC timers are not that easy to use since they are not guaranteed to ultimately run off the same oscillator as the processor time base, so you can't guarantee a stable mathematical relationship between the timebase and an OpenPIC timer count register.
Of course it will work in many machines (you would have to sacrifice one of the 4 timers to do this but that's not a big deal). You would also have to keep the most significant timebase bits and some other data in some other places (the OpenPIC timer has only 31 bits and runs at 1/8 the bus clock on integrated Motorola OpenPICs but 1/8 the PCI clock if you have an IBM MPIC2 chip). I'm looking for a solution for SMP which does not depend on the exact underlying hardware (it may require IPI but these are quite well encapsulated), like a few interlocked memory accesses to transmit the timebase and check that they are close enough.
Oh, BTW, in the OpenPIC timer specification the following is so laughable:
- integral number of clock ticks per second
Knowing that this number is required to be >= 4 million and the stability of typical computer oscillators, I can guarantee that the fractional part can be used as a fairly good random number generator (provided you don't measure it too often).
Regards,
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 3 lines
Can anybody with a Macintosh SMP G4 confirm that the time bases are synchronized at boot ?
AFAIK, on those machines, I think Apple uses their "timer" device in the new version of the mac-io ASIC to sync. timebases.
Reading Apple's CPU startup code in Darwin is _very_ interesting in fact. That's for example how I learned that the only way to correctly and completely flush the cache is to either reserve CPU-specific regions of memory, use the ROM, or have external HW assist. Without that, any snooping on the bus will garbage the flush process.
Ben.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Not all processors of an SMP complex are started at power-up and
the call to start secodary processors may perform a reset, so I don't think that one can guarantee that the TB's are synchronized. Maybe it all just works, but it does not seem like a requirement of any SMP system design.
David
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 5 lines · David Edelsohn
Not all processors of an SMP complex are started at power-up and
the call to start secodary processors may perform a reset, so I don't think that one can guarantee that the TB's are synchronized. Maybe it all just works, but it does not seem like a requirement of any SMP system design.
Yes, you may perform a reset. But at least on the chipsets I have seen the reset pin you have access to is the soft reset input which does not clear the TB (nor set the MSR IP bit for example). If the HRESET inputs are wired together (from a power supply monitoring circuit or something similar) and the timebase is never written to, than they should be synchronized. Then the only remaining problems are the power saving modes that may stop the timebase...
Disclaimer: this is how it works on 6xx/7xx processors as they are implemented in most systems. I don't know anything about IBM specific CPUs like Power3/Power4...
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 3 lines · Gabriel Paubert
Hard reset also clears the timebase on all the processors I know, so the time bases should be synchronized unless the firmware plays with them (assuming the HRESET pins are wired together).
Certainly on my 7600 with a 2-cpu powersurge board, with the code that is currently in the devel kernel to use the tb register, you don't get the same time on both cpus.
I haven't had a chance to look at your patch in detail yet, hopefully soon. At a quick glance it seemed to be touching a lot of stuff so it will take more than a quick glance. :-)
Paul.
--
Paul Mackerras, Senior Open Source Researcher, Linuxcare, Inc. +61 2 6262 8990 tel, +61 2 6262 8991 fax [email protected], http://www.linuxcare.com.au/
Linuxcare. Support for the revolution.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi Geert,
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines
Actually given the problems with RTC being UTC or local time, the offset might perhaps better be setup as a kernel parameter so that th system start up in a known good state. It seems that it is in RAM for Macs, but what about other machines (I have no problems since all my machines are UTC and I simply refuse to use an OS which requires anything else) ?
Quoted 6 lines
Why do you want to handle the offset in the kernel???
Any decent distro (e.g. Debian) allows to configure the time system for a hardware clock running in either UTC or local time, so the correction will be done on boot up.
I think there is some misunderstanding here. I don't want to handle the offset in the kernel, with one possible exception: when reading the RTC for the first time to initialize xtime. Getting timestamps right as early as possible might be important in some cases, and it's not a big deal since the code to do this is small and thrown away anyway.
Oh and I can't remember whether the clock or hwclock command ever worked on my machines. I think hwclock did once upon a time; life is so much simpler with NTP anyway (but it is run quite late in the boot process, actually just before the rc.local script on most of my machines and after mounting NFS file systems and starting daemons like syslogd/crond/inetd).
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 9 lines · Paul Mackerras
Quoted 3 lines · Gabriel Paubert
Hard reset also clears the timebase on all the processors I know, so the time bases should be synchronized unless the firmware plays with them (assuming the HRESET pins are wired together).
Certainly on my 7600 with a 2-cpu powersurge board, with the code that is currently in the devel kernel to use the tb register, you don't get the same time on both cpus.
Yes, we need a way to check that the timebase are in sync and to sync them if they are not. That's basically the same problem in any case. The problem is to do it in a way that works on all machines...
However current code is so broken that, if you had a jiffy counter per processor, you would see them drifting away.
Quoted 3 lines
I haven't had a chance to look at your patch in detail yet, hopefully soon. At a quick glance it seemed to be touching a lot of stuff so it will take more than a quick glance. :-)
It does not toch so much when you look carefully at it, only timekeeping but it's basically an all or nothing (and some global variable name changes to be sure that I catch all the occurences which add somewhat to the patch size).
However,
I have still found bugs in my code (but it seems to be slowly converging). I'm also considering switching to BitKeeper tree, and sending these patches in smaller and more digestible chunks:
- improved timing stability (fixed interrupt rate)
- 601 support and faster gettimeofday (no divide anymore)
- preliminary SMP support (gettimeofday still would have jiffy resolution on SMP)
The problem is that these parts are somewhat hard to disentangle. I'm also already running 2.4.0-test6 from kernel.org which was not yet merged in the BK tree a few hours ago and that includes a few things that I need.
Regards,
Gabriel
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 7 lines · Gabriel Paubert
Quoted 3 lines
Certainly on my 7600 with a 2-cpu powersurge board, with the code that is currently in the devel kernel to use the tb register, you don't get the same time on both cpus.
Yes, we need a way to check that the timebase are in sync and to sync them if they are not. That's basically the same problem in any case. The problem is to do it in a way that works on all machines...
Until we get SMP working on the 2-cpu G4 machines (hopefully I will be getting one soon), the old powersurge board is the only supported SMP powermac. I found with mine that when you start the second CPU, it stops the decrementers (and I expect timebases as well) on both CPUs until you send an interrupt from the primary to the secondary cpu.
So on this platform at least, we can get the decrementers and timebases synchronized.
Quoted 4 lines
It does not toch so much when you look carefully at it, only timekeeping but it's basically an all or nothing (and some global variable name changes to be sure that I catch all the occurences which add somewhat to the patch size).
I merged in your patch and tried it on my 7600/powersurge machine. It seems to work just fine.
Quoted 3 lines
I have still found bugs in my code (but it seems to be slowly converging). I'm also considering switching to BitKeeper tree, and sending these patches in smaller and more digestible chunks:
I'm going to try to update the linuxppc_2_3 bitkeeper tree to -test6, since Cort is busy moving at the moment. In the meantime I will update the rsync tree at linuxcare.com.au::linux-pmac-devel with your patch shortly.
The get/set rtc stuff on powermac still needs work. IMHO the way it should work on powermacs is this:
- at boot, read the RTC and the xpram and apply the correction from the xpram
- /dev/rtc reads and writes the RTC value directly (no timezone correction)
- if the RTC is updated from other places in the kernel, read the timezone recorded in xpram and apply that correction before writing it to the RTC.
Paul.
--
Paul Mackerras, Senior Open Source Researcher, Linuxcare, Inc. +61 2 6262 8990 tel, +61 2 6262 8991 fax [email protected], http://www.linuxcare.com.au/
Linuxcare. Support for the revolution.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 7 lines · Paul Mackerras
The get/set rtc stuff on powermac still needs work. IMHO the way it should work on powermacs is this:
- at boot, read the RTC and the xpram and apply the correction from the xpram
Quoted 6 lines
-
/dev/rtcreads and writes the RTC value directly (no timezone correction)- if the RTC is updated from other places in the kernel, read the timezone recorded in xpram and apply that correction before writing it to the RTC.
would this still allow for rtc in UTC? for those of us who do not use MacOS..
Signature · 2 lines
Ethan Benson http://www.alaska.net/~erbenson/
Quoted 8 lines · Ethan Benson
Quoted 7 lines · Paul Mackerras
The get/set rtc stuff on powermac still needs work. IMHO the way it should work on powermacs is this:
- at boot, read the RTC and the xpram and apply the correction from the xpram
Quoted 8 lines
Quoted 6 lines
-
/dev/rtcreads and writes the RTC value directly (no timezone correction)- if the RTC is updated from other places in the kernel, read the timezone recorded in xpram and apply that correction before writing it to the RTC.
would this still allow for rtc in UTC? for those of us who do not use MacOS..
Of course, at least that's how I see it. Just set all the xpram clock variables to zero. BTW, if MacOS X claims to be a true Unix, it should also support it.
Gabriel.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 10 lines · Paul Mackerras
Quoted 7 lines · Gabriel Paubert
Quoted 3 lines
Certainly on my 7600 with a 2-cpu powersurge board, with the code that is currently in the devel kernel to use the tb register, you don't get the same time on both cpus.
Yes, we need a way to check that the timebase are in sync and to sync them if they are not. That's basically the same problem in any case. The problem is to do it in a way that works on all machines...
Quoted 5 lines
Until we get SMP working on the 2-cpu G4 machines (hopefully I will be getting one soon), the old powersurge board is the only supported SMP powermac. I found with mine that when you start the second CPU, it stops the decrementers (and I expect timebases as well) on both CPUs until you send an interrupt from the primary to the secondary cpu.
I've just tested on my machines since it was not clear to me that the TBEN pin would stop the decrementer or not: it does. It is the only way I know to stop the timebase (besides stopping the clock that is).
There may still be issues with the ordering of time_init and starting the second processor. We'll see...
Quoted 2 lines
So on this platform at least, we can get the decrementers and timebases synchronized.
The only important registers are the timebases. First my patch got rid of the gross `while (get_dec() == dval);' loop, which did not work properly in any case. Depending on cache misses and external influences between this loop and the setting of the decrementer, I got effective jiffy frequency varying by 20ppm or so (that's about 200ns per 10 ms).
This had very nasty consequences even on my stratum 1 NTP server (just compiling a kernel would make the clock drift by several milliseconds before the PLL would react) on SMP this would have meant that the timer interrupts would have been drifting away randomly from each other.
The solution I implemented is simple: use the time base as a reference and generate a decrementer interrupt every n ticks of the timebase, even if the 601 makes things more complex (the code in the patch I sent is still wrong for 601, an improved one is coming soon).
Quoted 2 lines
I merged in your patch and tried it on my 7600/powersurge machine. It seems to work just fine.
So are the timebases in sync ? I was preparing a patch which should work even with unsynced timebases, but then gettimeofday can only have jiffy resolution. Beware that my next patch might break it, however, but it's the fun of writing code that you can't test yourself :-)
Quoted 8 lines
Quoted 3 lines
I have still found bugs in my code (but it seems to be slowly converging). I'm also considering switching to BitKeeper tree, and sending these patches in smaller and more digestible chunks:
I'm going to try to update the
linuxppc_2_3bitkeeper tree to -test6, since Cort is busy moving at the moment. In the meantime I will update the rsync tree at linuxcare.com.au::linux-pmac-devel with your patch shortly.
I tried once to download your tree, but bandwidth to autralia is too small from here.
Quoted 5 lines
The get/set rtc stuff on powermac still needs work. IMHO the way it should work on powermacs is this:
- at boot, read the RTC and the xpram and apply the correction from the xpram
Yes for PMAC. Apply the correction later (or never) for other machines. BTW, man setttimeofday is very interesting about dst:
The field tz_dsttime contains a symbolic constant (values are given below) that indicates in which part of the year Daylight Saving Time is in force. (Note: its value is con- stant throughout the year - it does not indicate that DST is in force, it just selects an algorithm.) The daylight saving time algorithms defined are as follows :
DST_NONE /* not on dst */
DST_USA /* USA style dst */
DST_AUST /* Australian style dst */
DST_WET /* Western European dst */
DST_MET /* Middle European dst */
DST_EET /* Eastern European dst */
DST_CAN /* Canada */
DST_GB /* Great Britain and Eire */
DST_RUM /* Rumania */
DST_TUR /* Turkey */
DST_AUSTALT /* Australian style with shift in 1986 */
Of course it turned out that the period in which Daylight Saving Time is in force cannot be given by a simple algo- rithm, one per country; indeed, this period is determined by unpredictable political decisions. So this method of representing time zones has been abandoned. Under Linux, in a call to settimeofday the tz_dsttime field should be zero.
So you might have to find another way to pass the dst field.
Quoted 2 lines
-
/dev/rtcreads and writes the RTC value directly (no timezone correction)
Right, note that there is a problem in get_rtc_time for some machines, if we want this function to be used for the /dev/rtc driver, it should not wait for the second boundary to return, or you can force one second busy wait loop in the kernel by reading /dev/rtc which opens the doors to interesting attacks ;-)
The right place to put this waiting loop is in time_init, supposing that pmac_read_rtc through cuda or pmu does not wait for a second boundary.
I'm currently working on this, but I don't plan to update the code for all machines: only PreP, CHRP and PMAC. This should provide enough examples to apply to the other machines (which won't compile anyway due to deliberate global variable name changes). The maintainers of other machines can contact me if they need any help...
Quoted 3 lines
Quoted 1 line
- if the RTC is updated from other places in the kernel, read the
timezone recorded in xpram and apply that correction before writing it to the RTC.
Ok, fine for pmac. For other platforms I shall need a way to round to the closest half hour before writing the clock when the NTP PLL is closed (which is basically the only kernel part which updates the clock). This will not yet be in the next patch set.
Regards,
Gabriel
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 2 lines · Paul Mackerras
I merged in your patch and tried it on my 7600/powersurge machine. It seems to work just fine.
Here is the first followup patch, which needs testing, to be applied on top of the preceding one. This patch corrects 601 handling, cleans up many other small things, should ensure that no decrementer interrupt is ever lost on SMP and UP (unless blocked for >1s on 601 or 2^32 TB ticks on others), and moves the initial time read loop in some get_rtc_time functions to time_init. Precision on boot still has to be checked.
Booted on an MVME2600...
I'm not going to have time to switch to BK before end of September. Time handling still needs more cleanups, I hope to do some in the next 2 weeks but I'm very busy on other fronts.
Gabriel.
arch/ppc/kernel/chrp_time.c | 26 +++++---- arch/ppc/kernel/pmac_time.c | 4 - arch/ppc/kernel/prep_setup.c | 48 +++++++++------- arch/ppc/kernel/prep_time.c | 44 +++++---------- arch/ppc/kernel/time.c | 122 ++++++++++++++++++++++++++++++------------- include/asm-ppc/hardirq.h | 7 ++ 6 files changed, 155 insertions, 96 deletions
arch/ppc/kernel/chrp_time.c +16 -10
@@ -115,28 +115,34 @@unsigned long __chrp chrp_get_rtc_time (void ) {unsigned int year, mon, day, hour, min, sec; -int i; +int uip, i;/* The Linux interpretation of the CMOS clock register contents: * When the Update-In-Progress (UIP) flag goes from 1 to 0, the * RTC registers show the second which has precisely just started. * Let's hope other operating systems interpret the RTC the same way. */ -/* read RTC exactly on falling edge of update flag */ -for (i =0 ; i <1000000 ; i++)/* may take up to 1 second... */ -if (chrp_cmos_clock_read (RTC_FREQ_SELECT ) &RTC_UIP ) -break ; -for (i =0 ; i <1000000 ; i++)/* must try at least 2.228 ms */ -if (!(chrp_cmos_clock_read (RTC_FREQ_SELECT ) &RTC_UIP )) -break ; -do {/* Isn't this overkill ? UIP above should guarantee consistency */ + +/* Since the UIP flag is set for about 2.2 ms and the clock +* is typically written with a precision of 1 jiffy, trying +* to obtain a precision better than a few milliseconds is +* an illusion. Only consistency is interesting, this also +* allows to use the routine for /dev/rtc without a potential +* 1 second kernel busy loop triggered by any reader of /dev/rtc. +*/ + +for ( i =0 ; i<1000000 ; i++) { + uip =chrp_cmos_clock_read (RTC_FREQ_SELECT ); sec =chrp_cmos_clock_read (RTC_SECONDS ); min =chrp_cmos_clock_read (RTC_MINUTES ); hour =chrp_cmos_clock_read (RTC_HOURS ); day =chrp_cmos_clock_read (RTC_DAY_OF_MONTH ); mon =chrp_cmos_clock_read (RTC_MONTH ); year =chrp_cmos_clock_read (RTC_YEAR ); - }while (sec !=chrp_cmos_clock_read (RTC_SECONDS )); + uip |=chrp_cmos_clock_read (RTC_FREQ_SELECT ); +if ((uip &RTC_UIP )==0 )break ; + } +if (!(chrp_cmos_clock_read (RTC_CONTROL ) &RTC_DM_BINARY ) ||RTC_ALWAYS_BCD ) {BCD_TO_BIN (sec);
arch/ppc/kernel/pmac_time.c +2 -2
@@ -219,8 +219,8 @@write_lock_irqsave (&xtime_lock, flags); xtime.tv_sec =pmac_get_rtc_time () + time_diff;set_dec (tb_ticks_per_jiffy); -/* No PBOOK has a 601 AFAIK, so use get_tbl not binary_tbl */ - tb_last_stamp=get_tbl (); +/* No PBOOK has a 601 AFAIK, so use get_tbl, not native */ +last_jiffy_stamp (0 )=tb_last_stamp=get_tbl (); xtime.tv_usec =0 ; last_rtc_update = xtime.tv_sec;write_unlock_irqrestore (&xtime_lock, flags);
arch/ppc/kernel/prep_setup.c +27 -21
76 lines not on this page · raw message
arch/ppc/kernel/prep_time.c +17 -27
71 lines not on this page · raw message
arch/ppc/kernel/time.c +86 -36
210 lines not on this page · raw message
include/asm-ppc/hardirq.h +7 -0
@@ -5,16 +5,23 @@#include <asm/smp.h> /* entry.S is sensitive to the offsets of these fields */ +/* The __last_jiffy_stamp field is needed to ensure that no decrementer +* interrupt is lost on SMP machines. Since on most CPUs it is in the same +* cache line as local_irq_count, it is cheap to access and is also used on UP +* for uniformity. +*/ typedef struct {unsigned int __softirq_active;unsigned int __softirq_mask;unsigned int __local_irq_count;unsigned int __local_bh_count;unsigned int __syscall_count; +unsigned int __last_jiffy_stamp; }____cacheline_aligned irq_cpustat_t ;#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ +#define last_jiffy_stamp (cpu) __IRQ_STAT((cpu), __last_jiffy_stamp)/* * Are we in an interrupt context? Either doing bottom half * or hardware interrupt processing?
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
dual G4 time issues..
In reply to Gabriel PaubertQuoted 13 lines · Gabriel Paubert
Quoted 10 lines · Paul Mackerras
Quoted 7 lines · Gabriel Paubert
Quoted 3 lines
Certainly on my 7600 with a 2-cpu powersurge board, with the code that is currently in the devel kernel to use the tb register, you don't get the same time on both cpus.
Yes, we need a way to check that the timebase are in sync and to sync them if they are not. That's basically the same problem in any case. The problem is to do it in a way that works on all machines...
Quoted 5 lines
Quoted 5 lines
Until we get SMP working on the 2-cpu G4 machines (hopefully I will be getting one soon), the old powersurge board is the only supported SMP powermac. I found with mine that when you start the second CPU, it stops the decrementers (and I expect timebases as well) on both CPUs until you send an interrupt from the primary to the secondary cpu.
Benh and I are pushing Mac G4 SMP patches into the recently created linuxppc_2_5 tree. It currently seems to work reasonably well, except there is some work needing to be done on syncing the timebases on CPU's. I seem to have about a 14 second difference between the 2 CPU's on the machine I'm testing on now.
(from ping -f)
43505 packets transmitted, 43504 packets received, 0% packet loss round-trip min/avg/max = -144657.0/0.1/144657.3 ms
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/