[Skiboot] [PATCH 1/2] opal-prd: Disable pnor access interface on FSP system

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Aug 10 01:18:17 AEST 2017


On FSP system host does not have access to PNOR. Hence disable PNOR
access interfaces.

CC: Jeremy Kerr <jk at ozlabs.org>
CC: Daniel M Crowell <dcrowell at us.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 external/opal-prd/opal-prd.c | 14 ++++++++++----
 external/opal-prd/pnor.c     | 19 +++++++++++++++++++
 external/opal-prd/pnor.h     |  1 +
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 798d59c..a09a636 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -1949,10 +1949,16 @@ static int run_prd_daemon(struct opal_prd_ctx *ctx)
 
 	fixup_hinterface_table();
 
-	rc = pnor_init(&ctx->pnor);
-	if (rc) {
-		pr_log(LOG_ERR, "PNOR: Failed to open pnor: %m");
-		goto out_close;
+	if (pnor_available(&ctx->pnor)) {
+		rc = pnor_init(&ctx->pnor);
+		if (rc) {
+			pr_log(LOG_ERR, "PNOR: Failed to open pnor: %m");
+			goto out_close;
+		}
+	} else {
+		/* Disable PNOR function pointers */
+		hinterface.pnor_read = NULL;
+		hinterface.pnor_write = NULL;
 	}
 
 	ipmi_init(ctx);
diff --git a/external/opal-prd/pnor.c b/external/opal-prd/pnor.c
index 0e7e5c0..c032421 100644
--- a/external/opal-prd/pnor.c
+++ b/external/opal-prd/pnor.c
@@ -32,6 +32,25 @@
 #include "pnor.h"
 #include "opal-prd.h"
 
+#define FDT_FLASH_PATH "/proc/device-tree/chosen/ibm,system-flash"
+
+bool pnor_available(struct pnor *pnor)
+{
+	/* --pnor is specified */
+	if (pnor->path) {
+		if (access(pnor->path, R_OK | W_OK) == 0)
+			return true;
+
+		pr_log(LOG_ERR, "PNOR: Does not have permission to read pnor: %m");
+		return false;
+	}
+
+	if (access(FDT_FLASH_PATH, R_OK) == 0)
+		return true;
+
+	return false;
+}
+
 int pnor_init(struct pnor *pnor)
 {
 	int rc;
diff --git a/external/opal-prd/pnor.h b/external/opal-prd/pnor.h
index 4ff449c..28571af 100644
--- a/external/opal-prd/pnor.h
+++ b/external/opal-prd/pnor.h
@@ -23,5 +23,6 @@ extern int pnor_operation(struct pnor *pnor, const char *name,
 
 extern int pnor_init(struct pnor *pnor);
 extern void pnor_close(struct pnor *pnor);
+extern bool pnor_available(struct pnor *pnor);
 
 #endif /*PNOR_H*/
-- 
2.9.3



More information about the Skiboot mailing list