[Skiboot] [PATCH v2 2/2] opal-prd: Fix error code from scom_read & scom_write

Jeremy Kerr jk at ozlabs.org
Thu Sep 15 11:52:32 AEST 2016


From: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Currently, we always return a zero value from scom_read & scom_write,
so the HBRT implementation has no way of detecting errors during scom
operations.

This change uses the actual return value from the scom operation from
the kernel instead.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
 external/opal-prd/hostboot-interface.h |  8 ++++++++
 external/opal-prd/opal-prd.c           | 17 +++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/external/opal-prd/hostboot-interface.h b/external/opal-prd/hostboot-interface.h
index 36d53a6..3e73ef8 100644
--- a/external/opal-prd/hostboot-interface.h
+++ b/external/opal-prd/hostboot-interface.h
@@ -46,6 +46,14 @@ enum MemoryError_t
 #define HBRT_CAPS_SET1_OPAL		1
 #define HBRT_CAPS_SET2_PHYP		2
 
+/* Capability flags */
+
+/**
+ * xscom_read and xscom_write return proper return codes on error.
+ * Previous implementations may have incorrectly ignored failures.
+ */
+#define HBRT_CAPS_OPAL_HAS_XSCOM_RC   (1ul << 0)
+
 struct host_interfaces {
 	/** Interface version. */
 	uint64_t interface_version;
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 245c957..56943c4 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -297,13 +297,14 @@ int hservice_scom_read(uint64_t chip_id, uint64_t addr, void *buf)
 				"failed: %m", chip_id, addr);
 		return 0;
 	}
+	rc = (int)scom.rc;
 
-	pr_debug("SCOM: read: chip 0x%lx, addr 0x%lx, val 0x%lx",
-			chip_id, addr, scom.data);
+	pr_debug("SCOM: read: chip 0x%lx, addr 0x%lx, val 0x%lx, rc %d",
+		 chip_id, addr, scom.data, rc);
 
 	*(uint64_t *)buf = htobe64(scom.data);
 
-	return 0;
+	return rc;
 }
 
 int hservice_scom_write(uint64_t chip_id, uint64_t addr,
@@ -322,11 +323,12 @@ int hservice_scom_write(uint64_t chip_id, uint64_t addr,
 				"failed: %m", chip_id, addr);
 		return 0;
 	}
+	rc = (int)scom.rc;
 
-	pr_debug("SCOM: write: chip 0x%lx, addr 0x%lx, val 0x%lx",
-			chip_id, addr, scom.data);
+	pr_debug("SCOM: write: chip 0x%lx, addr 0x%lx, val 0x%lx, rc %d",
+		 chip_id, addr, scom.data, rc);
 
-	return 0;
+	return rc;
 }
 
 uint64_t hservice_get_reserved_mem(const char *name, uint32_t instance)
@@ -651,6 +653,9 @@ int hservice_memory_error(uint64_t i_start_addr, uint64_t i_endAddr,
 
 uint64_t hservice_get_interface_capabilities(uint64_t set)
 {
+	if (set == HBRT_CAPS_SET1_OPAL)
+		return HBRT_CAPS_OPAL_HAS_XSCOM_RC;
+
 	return 0;
 }
 
-- 
2.7.4



More information about the Skiboot mailing list