Commit d4f7a112 authored by Tom Rini's avatar Tom Rini

PPC32: Fix a delay which could occur when booting on machines

without an RTC.
parent 87113c38
...@@ -286,13 +286,11 @@ void do_settimeofday(struct timeval *tv) ...@@ -286,13 +286,11 @@ void do_settimeofday(struct timeval *tv)
write_unlock_irqrestore(&xtime_lock, flags); write_unlock_irqrestore(&xtime_lock, flags);
} }
/* This function is only called on the boot processor */
void __init time_init(void) void __init time_init(void)
{ {
time_t sec, old_sec; time_t sec, old_sec;
unsigned old_stamp, stamp, elapsed; unsigned old_stamp, stamp, elapsed;
/* This function is only called on the boot processor */
unsigned long flags;
if (ppc_md.time_init != NULL) if (ppc_md.time_init != NULL)
time_offset = ppc_md.time_init(); time_offset = ppc_md.time_init();
...@@ -309,31 +307,31 @@ void __init time_init(void) ...@@ -309,31 +307,31 @@ void __init time_init(void)
/* Now that the decrementer is calibrated, it can be used in case the /* 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 * clock is stuck, but the fact that we have to handle the 601
* makes things more complex. Repeatedly read the RTC until the * 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) { if (ppc_md.get_rtc_time) {
stamp = get_native_tbl();
sec = ppc_md.get_rtc_time(); sec = ppc_md.get_rtc_time();
elapsed = 0; elapsed = 0;
do { do {
old_stamp = stamp; old_stamp = stamp;
old_sec = sec; old_sec = sec;
stamp = get_native_tbl(); 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; elapsed += stamp - old_stamp;
sec = ppc_md.get_rtc_time(); sec = ppc_md.get_rtc_time();
} while ( sec == old_sec && elapsed < 2*HZ*tb_ticks_per_jiffy); } 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"); printk("Warning: real time clock seems stuck!\n");
}
write_lock_irqsave(&xtime_lock, flags);
xtime.tv_sec = sec; xtime.tv_sec = sec;
last_jiffy_stamp(0) = tb_last_stamp = stamp;
xtime.tv_nsec = 0; xtime.tv_nsec = 0;
/* No update now, we just read the time from the RTC ! */ /* No update now, we just read the time from the RTC ! */
last_rtc_update = xtime.tv_sec; 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 */ /* Not exact, but the timer interrupt takes care of this */
set_dec(tb_ticks_per_jiffy); set_dec(tb_ticks_per_jiffy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment