]> git.neil.brown.name Git - history.git/commitdiff
PPC32: Fix a delay which could occur when booting on machines
authorTom Rini <trini@kernel.crashing.org>
Tue, 7 Jan 2003 01:29:52 +0000 (18:29 -0700)
committerTom Rini <trini@kernel.crashing.org>
Tue, 7 Jan 2003 01:29:52 +0000 (18:29 -0700)
without an RTC.

arch/ppc/kernel/time.c

index c23238e70b69350bd2e447143eb1575495f9b5a8..14c583e4587675762b9ccf665938420eb1e1f38e 100644 (file)
@@ -286,13 +286,11 @@ void do_settimeofday(struct timeval *tv)
        write_unlock_irqrestore(&xtime_lock, flags);
 }
 
-
+/* This function is only called on the boot processor */
 void __init time_init(void)
 {
        time_t sec, old_sec;
        unsigned old_stamp, stamp, elapsed;
-       /* This function is only called on the boot processor */
-       unsigned long flags;
 
         if (ppc_md.time_init != NULL)
                 time_offset = ppc_md.time_init();
@@ -309,31 +307,31 @@ void __init time_init(void)
        /* Now that the decrementer is calibrated, it can be used in case the 
         * clock is stuck, but the fact that we have to handle the 601
         * makes things more complex. Repeatedly read the RTC until the
-        * next second boundary to try to achieve some precision...
+        * next second boundary to try to achieve some precision.  If there
+        * is no RTC, we still need to set tb_last_stamp and
+        * last_jiffy_stamp(cpu 0) to the current stamp.
         */
+       stamp = get_native_tbl();
        if (ppc_md.get_rtc_time) {
-               stamp = get_native_tbl();
                sec = ppc_md.get_rtc_time();
                elapsed = 0;
                do {
                        old_stamp = stamp; 
                        old_sec = sec;
                        stamp = get_native_tbl();
-                       if (__USE_RTC() && stamp < old_stamp) old_stamp -= 1000000000;
+                       if (__USE_RTC() && stamp < old_stamp)
+                               old_stamp -= 1000000000;
                        elapsed += stamp - old_stamp;
                        sec = ppc_md.get_rtc_time();
                } while ( sec == old_sec && elapsed < 2*HZ*tb_ticks_per_jiffy);
-               if (sec==old_sec) {
+               if (sec==old_sec)
                        printk("Warning: real time clock seems stuck!\n");
-               }
-               write_lock_irqsave(&xtime_lock, flags);
                xtime.tv_sec = sec;
-               last_jiffy_stamp(0) = tb_last_stamp = stamp;
                xtime.tv_nsec = 0;
                /* No update now, we just read the time from the RTC ! */
                last_rtc_update = xtime.tv_sec;
-               write_unlock_irqrestore(&xtime_lock, flags);
        }
+       last_jiffy_stamp(0) = tb_last_stamp = stamp;
 
        /* Not exact, but the timer interrupt takes care of this */
        set_dec(tb_ticks_per_jiffy);