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

Jeremy Kerr jk at ozlabs.org
Tue Sep 13 14:27:27 AEST 2016


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

Currently, we always return a zero value from scom_red & 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 |  6 ++++++
 external/opal-prd/opal-prd.c           | 16 +++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/external/opal-prd/hostboot-interface.h b/external/opal-prd/hostboot-interface.h
index 7729a5b..0cbcdd6 100644
--- a/external/opal-prd/hostboot-interface.h
+++ b/external/opal-prd/hostboot-interface.h
@@ -41,6 +41,12 @@ enum MemoryError_t
 	MEMORY_ERROR_UE = 1,
 };
 
+/**
+ * PRD flag: xscom_read and xscom_write return proper return codes on error.
+ * Previous implementations may have incorrectly ignored failures.
+ */
+#define OPAL_PRD_FLAGS_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 775d9f1..6f2cc22 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,7 +653,7 @@ int hservice_memory_error(uint64_t i_start_addr, uint64_t i_endAddr,
 
 uint64_t hservice_get_prd_flags(void)
 {
-	return 0;
+	return OPAL_PRD_FLAGS_HAS_XSCOM_RC;
 }
 
 int hservices_init(struct opal_prd_ctx *ctx, void *code)
-- 
2.7.4



More information about the Skiboot mailing list