The functions in rtas-rtc which call get-time-of-day can be invoked in
boot, suspend, and resume paths with interrupts off. Unfortunately
get-time-of-day can return an extended delay status, so we use
rtas_force_spin_if_busy().

In the specific case of rtas_get_rtc_time(), it is not clear why
returning an incorrect result is better than calling again even if we
are in interrupt context. Remove this logic.

Signed-off-by: Nathan Lynch <nath...@linux.ibm.com>
---
 arch/powerpc/kernel/rtas-rtc.c | 28 ++--------------------------
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/kernel/rtas-rtc.c b/arch/powerpc/kernel/rtas-rtc.c
index a28239b8b0c0..82cb95f29a11 100644
--- a/arch/powerpc/kernel/rtas-rtc.c
+++ b/arch/powerpc/kernel/rtas-rtc.c
@@ -17,19 +17,12 @@ time64_t __init rtas_get_boot_time(void)
 {
        int ret[8];
        int error;
-       unsigned int wait_time;
        u64 max_wait_tb;
 
        max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
        do {
                error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
-
-               wait_time = rtas_busy_delay_time(error);
-               if (wait_time) {
-                       /* This is boot time so we spin. */
-                       udelay(wait_time*1000);
-               }
-       } while (wait_time && (get_tb() < max_wait_tb));
+       } while (rtas_force_spin_if_busy(error) && (get_tb() < max_wait_tb));
 
        if (error != 0) {
                printk_ratelimited(KERN_WARNING
@@ -41,33 +34,16 @@ time64_t __init rtas_get_boot_time(void)
        return mktime64(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]);
 }
 
-/* NOTE: get_rtc_time will get an error if executed in interrupt context
- * and if a delay is needed to read the clock.  In this case we just
- * silently return without updating rtc_tm.
- */
 void rtas_get_rtc_time(struct rtc_time *rtc_tm)
 {
         int ret[8];
        int error;
-       unsigned int wait_time;
        u64 max_wait_tb;
 
        max_wait_tb = get_tb() + tb_ticks_per_usec * 1000 * MAX_RTC_WAIT;
        do {
                error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
-
-               wait_time = rtas_busy_delay_time(error);
-               if (wait_time) {
-                       if (in_interrupt()) {
-                               memset(rtc_tm, 0, sizeof(struct rtc_time));
-                               printk_ratelimited(KERN_WARNING
-                                                  "error: reading clock "
-                                                  "would delay interrupt\n");
-                               return; /* delay not allowed */
-                       }
-                       msleep(wait_time);
-               }
-       } while (wait_time && (get_tb() < max_wait_tb));
+       } while (rtas_sched_if_busy(error) && (get_tb() < max_wait_tb));
 
        if (error != 0) {
                printk_ratelimited(KERN_WARNING
-- 
2.30.2

Reply via email to