[Skiboot] [PATCH] nx: use gcid + 1 for CI

Dan Streetman ddstreet at ieee.org
Wed Apr 8 15:54:39 AEST 2015


In commit e077676 the nx CI's were changed to just use the chip id.
That works fine, except CI 0 is reserved, so if there is a chip id
of 0, the CI is set to 0, which is invalid.  This doesn't currently
affect the kernel driver, as it just uses the reserved CI of 0 for
all requests, as CI == 0 tells the hw to auto-select which CI to
send the request to.  However, valid CI's should be assigned; we can
use the chip id + 1 to ensure a valid CI.

This commit fixes the CI assignment by setting each CI to the chip
id + 1.

Signed-off-by: Dan Streetman <ddstreet at ieee.org>
---
 hw/nx-842.c    | 14 +++++++-------
 hw/nx-crypto.c | 24 ++++++++++++------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/hw/nx-842.c b/hw/nx-842.c
index b5a43cc..f462f7a 100644
--- a/hw/nx-842.c
+++ b/hw/nx-842.c
@@ -39,9 +39,9 @@
 static int nx_cfg_842(u32 gcid, u64 xcfg)
 {
 	u64 cfg, ci, ct;
-	int rc;
+	int rc, instance = gcid + 1;
 
-	BUILD_ASSERT(MAX_CHIPS <= NX_842_CFG_CI_MAX);
+	BUILD_ASSERT(MAX_CHIPS < NX_842_CFG_CI_MAX);
 
 	rc = xscom_read(gcid, xcfg, &cfg);
 	if (rc)
@@ -64,14 +64,14 @@ static int nx_cfg_842(u32 gcid, u64 xcfg)
 	 */
 	ci = GETFIELD(NX_842_CFG_CI, cfg) >> NX_842_CFG_CI_LSHIFT;
 	if (!ci)
-		prlog(PR_INFO, "NX%d:   842 CI set to %d\n", gcid, gcid);
-	else if (ci == gcid)
+		prlog(PR_INFO, "NX%d:   842 CI set to %d\n", gcid, instance);
+	else if (ci == instance)
 		prlog(PR_INFO, "NX%d:   842 CI already set to %u\n", gcid,
 		      (unsigned int)ci);
 	else
 		prlog(PR_INFO, "NX%d:   842 CI already set to %u, "
-		      "changing to %d\n", gcid, (unsigned int)ci, gcid);
-	ci = gcid;
+		      "changing to %d\n", gcid, (unsigned int)ci, instance);
+	ci = instance;
 	cfg = SETFIELD(NX_842_CFG_CI, cfg, ci << NX_842_CFG_CI_LSHIFT);
 
 	/* Enable all functions */
@@ -193,5 +193,5 @@ void nx_create_842_node(struct dt_node *node)
 	prlog(PR_INFO, "NX%d: 842 Coprocessor Enabled\n", gcid);
 
 	dt_add_property_cells(node, "ibm,842-coprocessor-type", NX_CT_842);
-	dt_add_property_cells(node, "ibm,842-coprocessor-instance", gcid);
+	dt_add_property_cells(node, "ibm,842-coprocessor-instance", gcid + 1);
 }
diff --git a/hw/nx-crypto.c b/hw/nx-crypto.c
index 37b64f2..723c571 100644
--- a/hw/nx-crypto.c
+++ b/hw/nx-crypto.c
@@ -48,9 +48,9 @@
 static int nx_cfg_sym(u32 gcid, u64 xcfg)
 {
 	u64 cfg, ci, ct;
-	int rc;
+	int rc, instance = gcid + 1;
 
-	BUILD_ASSERT(MAX_CHIPS <= NX_SYM_CFG_CI_MAX);
+	BUILD_ASSERT(MAX_CHIPS < NX_SYM_CFG_CI_MAX);
 
 	rc = xscom_read(gcid, xcfg, &cfg);
 	if (rc)
@@ -73,14 +73,14 @@ static int nx_cfg_sym(u32 gcid, u64 xcfg)
 	 */
 	ci = GETFIELD(NX_SYM_CFG_CI, cfg) >> NX_SYM_CFG_CI_LSHIFT;
 	if (!ci)
-		prlog(PR_INFO, "NX%d:   SYM CI set to %d\n", gcid, gcid);
-	else if (ci == gcid)
+		prlog(PR_INFO, "NX%d:   SYM CI set to %d\n", gcid, instance);
+	else if (ci == instance)
 		prlog(PR_INFO, "NX%d:   SYM CI already set to %u\n", gcid,
 		      (unsigned int)ci);
 	else
 		prlog(PR_INFO, "NX%d:   SYM CI already set to %u, "
-		      "changing to %d\n", gcid, (unsigned int)ci, gcid);
-	ci = gcid;
+		      "changing to %d\n", gcid, (unsigned int)ci, instance);
+	ci = instance;
 	cfg = SETFIELD(NX_SYM_CFG_CI, cfg, ci << NX_SYM_CFG_CI_LSHIFT);
 
 	cfg = SETFIELD(NX_SYM_CFG_FC_ENABLE, cfg, CFG_SYM_FC_ENABLE);
@@ -101,9 +101,9 @@ static int nx_cfg_sym(u32 gcid, u64 xcfg)
 static int nx_cfg_asym(u32 gcid, u64 xcfg)
 {
 	u64 cfg, ci, ct;
-	int rc;
+	int rc, instance = gcid + 1;
 
-	BUILD_ASSERT(MAX_CHIPS <= NX_ASYM_CFG_CI_MAX);
+	BUILD_ASSERT(MAX_CHIPS < NX_ASYM_CFG_CI_MAX);
 
 	rc = xscom_read(gcid, xcfg, &cfg);
 	if (rc)
@@ -127,14 +127,14 @@ static int nx_cfg_asym(u32 gcid, u64 xcfg)
 	 */
 	ci = GETFIELD(NX_ASYM_CFG_CI, cfg) >> NX_ASYM_CFG_CI_LSHIFT;
 	if (!ci)
-		prlog(PR_INFO, "NX%d:   ASYM CI set to %d\n", gcid, gcid);
-	else if (ci == gcid)
+		prlog(PR_INFO, "NX%d:   ASYM CI set to %d\n", gcid, instance);
+	else if (ci == instance)
 		prlog(PR_INFO, "NX%d:   ASYM CI already set to %u\n", gcid,
 		      (unsigned int)ci);
 	else
 		prlog(PR_INFO, "NX%d:   ASYM CI already set to %u, "
-		      "changing to %d\n", gcid, (unsigned int)ci, gcid);
-	ci = gcid;
+		      "changing to %d\n", gcid, (unsigned int)ci, instance);
+	ci = instance;
 	cfg = SETFIELD(NX_ASYM_CFG_CI, cfg, ci << NX_ASYM_CFG_CI_LSHIFT);
 
 	cfg = SETFIELD(NX_ASYM_CFG_FC_ENABLE, cfg, CFG_ASYM_FC_ENABLE);
-- 
2.1.0



More information about the Skiboot mailing list