[Skiboot] [PATCH 2/5] xscom: Map all HMER status codes to OPAL errors

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue Sep 13 14:45:25 AEST 2016


Instead of mapping them to just 3 different codes, define an OPAL
error code for all known HMER error status, as different recovery
path might be needed at the call site, and it allows for more
informative logging.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 hw/xscom.c         | 16 +++++++++++++---
 include/opal-api.h |  7 +++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/hw/xscom.c b/hw/xscom.c
index 4220312..4cc5ae4 100644
--- a/hw/xscom.c
+++ b/hw/xscom.c
@@ -134,6 +134,7 @@ static int64_t xscom_handle_error(uint64_t hmer, uint32_t gcid, uint32_t pcb_add
 {
 	struct timespec ts;
 	unsigned int stat = GETFIELD(SPR_HMER_XSCOM_STATUS, hmer);
+	int64_t rc = OPAL_HARDWARE;
 
 	/* XXX Figure out error codes from doc and error
 	 * recovery procedures
@@ -171,16 +172,25 @@ static int64_t xscom_handle_error(uint64_t hmer, uint32_t gcid, uint32_t pcb_add
 				"XSCOM: %s-busy error gcid=0x%x pcb_addr=0x%x "
 				"stat=0x%x\n", is_write ? "write" : "read",
 				gcid, pcb_addr, stat);
-		return OPAL_BUSY;
+		return OPAL_XSCOM_BUSY;
 
 	case 2: /* CPU is asleep, reset XSCOM engine and return */
 		xscom_reset(gcid);
-		return OPAL_WRONG_STATE;
+		return OPAL_XSCOM_CHIPLET_OFF;
 	case 3: /* Partial good */
+		rc = OPAL_XSCOM_PARTIAL_GOOD;
+		break;
 	case 4: /* Invalid address / address error */
+		rc = OPAL_XSCOM_ADDR_ERROR;
+		break;
 	case 5: /* Clock error */
+		rc = OPAL_XSCOM_CLOCK_ERROR;
+		break;
 	case 6: /* Parity error  */
+		rc = OPAL_XSCOM_PARITY_ERROR;
+		break;
 	case 7: /* Time out */
+		rc = OPAL_XSCOM_TIMEOUT;
 		break;
 	}
 
@@ -193,7 +203,7 @@ static int64_t xscom_handle_error(uint64_t hmer, uint32_t gcid, uint32_t pcb_add
 	xscom_reset(gcid);
 
 	/* Non recovered ... just fail */
-	return OPAL_HARDWARE;
+	return rc;
 }
 
 static void xscom_handle_ind_error(uint64_t data, uint32_t gcid,
diff --git a/include/opal-api.h b/include/opal-api.h
index c86244b..7422443 100644
--- a/include/opal-api.h
+++ b/include/opal-api.h
@@ -45,6 +45,13 @@
 #define OPAL_I2C_ARBT_LOST	-22
 #define OPAL_I2C_NACK_RCVD	-23
 #define OPAL_I2C_STOP_ERR	-24
+#define OPAL_XSCOM_BUSY		OPAL_BUSY
+#define OPAL_XSCOM_CHIPLET_OFF	OPAL_WRONG_STATE
+#define OPAL_XSCOM_PARTIAL_GOOD	-25
+#define OPAL_XSCOM_ADDR_ERROR	-26
+#define OPAL_XSCOM_CLOCK_ERROR	-27
+#define OPAL_XSCOM_PARITY_ERROR	-28
+#define OPAL_XSCOM_TIMEOUT	-29
 
 /* API Tokens (in r0) */
 #define OPAL_INVALID_CALL		       -1
-- 
2.7.4



More information about the Skiboot mailing list