aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/time_64.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/arch/x86/kernel/time_64.c b/arch/x86/kernel/time_64.c
index 4ad1f7a6a839..368b1942b39a 100644
--- a/arch/x86/kernel/time_64.c
+++ b/arch/x86/kernel/time_64.c
@@ -161,21 +161,27 @@ unsigned long read_persistent_clock(void)
161 unsigned century = 0; 161 unsigned century = 0;
162 162
163 spin_lock_irqsave(&rtc_lock, flags); 163 spin_lock_irqsave(&rtc_lock, flags);
164 /*
165 * if UIP is clear, then we have >= 244 microseconds before RTC
166 * registers will be updated. Spec sheet says that this is the
167 * reliable way to read RTC - registers invalid (off bus) during update
168 */
169 while ((CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
170 cpu_relax();
164 171
165 do { 172
166 sec = CMOS_READ(RTC_SECONDS); 173 /* now read all RTC registers while stable with interrupts disabled */
167 min = CMOS_READ(RTC_MINUTES); 174 sec = CMOS_READ(RTC_SECONDS);
168 hour = CMOS_READ(RTC_HOURS); 175 min = CMOS_READ(RTC_MINUTES);
169 day = CMOS_READ(RTC_DAY_OF_MONTH); 176 hour = CMOS_READ(RTC_HOURS);
170 mon = CMOS_READ(RTC_MONTH); 177 day = CMOS_READ(RTC_DAY_OF_MONTH);
171 year = CMOS_READ(RTC_YEAR); 178 mon = CMOS_READ(RTC_MONTH);
179 year = CMOS_READ(RTC_YEAR);
172#ifdef CONFIG_ACPI 180#ifdef CONFIG_ACPI
173 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && 181 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
174 acpi_gbl_FADT.century) 182 acpi_gbl_FADT.century)
175 century = CMOS_READ(acpi_gbl_FADT.century); 183 century = CMOS_READ(acpi_gbl_FADT.century);
176#endif 184#endif
177 } while (sec != CMOS_READ(RTC_SECONDS));
178
179 spin_unlock_irqrestore(&rtc_lock, flags); 185 spin_unlock_irqrestore(&rtc_lock, flags);
180 186
181 /* 187 /*