diff mbox series

[RFC,03/10] powerpc/rtas-rtc: convert get-time-of-day to rtas_force_spin_if_busy()

Message ID 20210504030358.1715034-4-nathanl@linux.ibm.com (mailing list archive)
State RFC
Headers show
Series powerpc/rtas: improved busy and extended delay status handling | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (134b5c8a49b594ff6cfb4ea1a92400bb382b46d2)
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 54 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Nathan Lynch May 4, 2021, 3:03 a.m. UTC
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 <nathanl@linux.ibm.com>
---
 arch/powerpc/kernel/rtas-rtc.c | 28 ++--------------------------
 1 file changed, 2 insertions(+), 26 deletions(-)
diff mbox series

Patch

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