[Skiboot] [PATCH 1/2] opal/xscom: Move the delay inside xscom_reset() function.

Mahesh J Salgaonkar mahesh at linux.vnet.ibm.com
Fri Dec 8 03:13:00 AEDT 2017


From: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>

So caller of xscom_reset() does not have to bother about adding a delay
separately.

Signed-off-by: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>
---
 hw/xscom.c |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/hw/xscom.c b/hw/xscom.c
index 5b3bd88..2621465 100644
--- a/hw/xscom.c
+++ b/hw/xscom.c
@@ -96,6 +96,7 @@ static void xscom_reset(uint32_t gcid)
 {
 	u64 hmer;
 	uint32_t recv_status_reg, log_reg, err_reg;
+	struct timespec ts;
 
 	/* Clear errors in HMER */
 	mtspr(SPR_HMER, HMER_CLR_MASK);
@@ -126,6 +127,19 @@ static void xscom_reset(uint32_t gcid)
 	hmer = xscom_wait_done();
 	if (hmer & SPR_HMER_XSCOM_FAIL)
 		goto fail;
+
+	/*
+	 * Its observed that sometimes immediate retry of
+	 * XSCOM operation returns wrong data. Adding a
+	 * delay for XSCOM reset to be effective. Delay of
+	 * 10 ms is found to be working fine experimentally.
+	 * FIXME: Replace 10ms delay by exact delay needed
+	 * or other alternate method to confirm XSCOM reset
+	 * completion, after checking from HW folks.
+	 */
+	ts.tv_sec = 0;
+	ts.tv_nsec = 10 * 1000;
+	nanosleep_nopoll(&ts, NULL);
 	return;
  fail:
 	/* Fatal error resetting XSCOM */
@@ -140,7 +154,6 @@ static void xscom_reset(uint32_t gcid)
 static int64_t xscom_handle_error(uint64_t hmer, uint32_t gcid, uint32_t pcb_addr,
 			      bool is_write, int64_t retries)
 {
-	struct timespec ts;
 	unsigned int stat = GETFIELD(SPR_HMER_XSCOM_STATUS, hmer);
 	int64_t rc = OPAL_HARDWARE;
 
@@ -160,18 +173,6 @@ static int64_t xscom_handle_error(uint64_t hmer, uint32_t gcid, uint32_t pcb_add
 				XSCOM_BUSY_RESET_THRESHOLD, retries);
 			xscom_reset(gcid);
 
-			/*
-			 * Its observed that sometimes immediate retry of
-			 * XSCOM operation returns wrong data. Adding a
-			 * delay for XSCOM reset to be effective. Delay of
-			 * 10 ms is found to be working fine experimentally.
-			 * FIXME: Replace 10ms delay by exact delay needed
-			 * or other alternate method to confirm XSCOM reset
-			 * completion, after checking from HW folks.
-			 */
-			ts.tv_sec = 0;
-			ts.tv_nsec = 10 * 1000;
-			nanosleep_nopoll(&ts, NULL);
 		}
 
 		/* Log error if we have retried enough and its still busy */



More information about the Skiboot mailing list