A shorter period makes mc146818_get_time() more similar to mach_get_cmos_time() in arch/x86/kernel/rtc.c, which performs the same function, but is busy waiting for the RTC_UIP bit to clear. Waiting 1ms every time is not necessary, for example on some AMD boxes the RTC_UIP bit is documented as being high for around 270 microseconds in some cases [1], which agreed with experiments on an SB710 southbridge. So 100us seems optimal. [1] AMD SB700/710/750 Register Reference Guide, page 307, https://developer.amd.com/wordpress/media/2012/10/43009_sb7xx_rrg_pub_1.00.pdf "SB700 A12: The UIP high pulse is 270 μS Typical when SS on SRC clock is OFF and 100μ min when SRC SS is ON." [sic] Signed-off-by: Mateusz Jończyk <mat.jonczyk@xxxxx> Cc: Alessandro Zummo <a.zummo@xxxxxxxxxxxx> Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxxxx> Cc: x86@xxxxxxxxxx Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> --- drivers/rtc/rtc-mc146818-lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index 9175e11baf26..d1c42b0ef662 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -45,7 +45,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) #endif again: - if (iter_count > 10) { + if (iter_count > 100) { pr_err_ratelimited("Unable to read current time from RTC\n"); memset(time, 0xff, sizeof(*time)); return 0; @@ -57,7 +57,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) /* * Check whether there is an update in progress during which the * readout is unspecified. The maximum update time is ~2ms. Poll - * every msec for completion. + * every 100 usec for completion. * * Store the second value before checking UIP so a long lasting NMI * which happens to hit after the UIP check cannot make an update @@ -67,7 +67,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) { spin_unlock_irqrestore(&rtc_lock, flags); - mdelay(1); + udelay(100); goto again; } -- 2.25.1