[Skiboot] [PATCH 17/61] hdata/P10: Fix xscom address and ibm, chip-id property

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Mon Jul 19 23:19:28 AEST 2021


`xscom_id` is deprecated in P10. Instead we should use topology ID's
("Primary topology table index") to calculate xscom address. Also
use ("Processor fabric topology id") for "ibm,chip-id" property.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hdata/fsp.c   |  2 +-
 hdata/hdata.h |  1 +
 hdata/spira.c | 34 +++++++++++++++++++++++-----------
 hdata/spira.h |  3 +++
 4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/hdata/fsp.c b/hdata/fsp.c
index 458b7e636..42f1121ab 100644
--- a/hdata/fsp.c
+++ b/hdata/fsp.c
@@ -297,7 +297,7 @@ static void add_chip_id_to_sensors(struct dt_node *sensor_node, uint32_t slca_in
 		}
 
 		dt_add_property_cells(sensor_node,
-				      "ibm,chip-id", be32_to_cpu(cinfo->xscom_id));
+				      "ibm,chip-id", get_xscom_id(cinfo));
 		return;
 	}
 }
diff --git a/hdata/hdata.h b/hdata/hdata.h
index cbc61c31d..bae4eaa58 100644
--- a/hdata/hdata.h
+++ b/hdata/hdata.h
@@ -24,6 +24,7 @@ extern void vpd_data_parse(struct dt_node *node,
 
 extern struct dt_node *find_xscom_for_chip(uint32_t chip_id);
 extern uint32_t pcid_to_chip_id(uint32_t proc_chip_id);
+extern uint32_t get_xscom_id(const struct sppcrd_chip_info *cinfo);
 
 extern struct dt_node *add_core_common(struct dt_node *cpus,
 				       const struct sppcia_cpu_cache *cache,
diff --git a/hdata/spira.c b/hdata/spira.c
index b7101d72e..7d56f3f29 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -289,12 +289,23 @@ struct HDIF_common_hdr *__get_hdif(struct spira_ntuple *n, const char id[],
 	return h;
 }
 
-static struct dt_node *add_xscom_node(uint64_t base, uint32_t hw_id,
-				      uint32_t proc_chip_id)
+uint32_t get_xscom_id(const struct sppcrd_chip_info *cinfo)
+{
+	if (proc_gen <= proc_gen_p9)
+		return be32_to_cpu(cinfo->xscom_id);
+
+	/* On P10 use Processor fabric topology id for chip id */
+	return (uint32_t)(cinfo->fab_topology_id);
+}
+
+static struct dt_node *add_xscom_node(uint64_t base,
+				      const struct sppcrd_chip_info *cinfo)
 {
 	struct dt_node *node;
 	uint64_t addr, size;
 	uint64_t freq;
+	uint32_t hw_id = get_xscom_id(cinfo);
+	uint32_t proc_chip_id = be32_to_cpu(cinfo->proc_chip_id);
 
 	switch (proc_gen) {
 	case proc_gen_p8:
@@ -302,13 +313,16 @@ static struct dt_node *add_xscom_node(uint64_t base, uint32_t hw_id,
 		addr = base | ((uint64_t)hw_id << PPC_BITLSHIFT(28));
 		break;
 	case proc_gen_p9:
-	case proc_gen_p10: /* XXX P10 */
-	default:
 		/* On P9 we need to put the chip ID in the natural powerbus
 		 * position.
 		 */
 		addr = base | (((uint64_t)hw_id) << 42);
 		break;
+	case proc_gen_p10:
+	default:
+		/* Use Primary topology table index for xscom address */
+		addr = base | (((uint64_t)cinfo->topology_id_table[cinfo->primary_topology_loc]) << 44);
+		break;
 	};
 
 	size = (u64)1 << PPC_BITLSHIFT(28);
@@ -611,9 +625,7 @@ static bool add_xscom_sppcrd(uint64_t xscom_base)
 			continue;
 
 		/* Create the XSCOM node */
-		np = add_xscom_node(xscom_base,
-				    be32_to_cpu(cinfo->xscom_id),
-				    be32_to_cpu(cinfo->proc_chip_id));
+		np = add_xscom_node(xscom_base, cinfo);
 		if (!np)
 			continue;
 
@@ -636,7 +648,7 @@ static bool add_xscom_sppcrd(uint64_t xscom_base)
 					   SPPCRD_IDATA_KW_VPD);
 		if (vpd_node)
 			dt_add_property_cells(vpd_node, "ibm,chip-id",
-					      be32_to_cpu(cinfo->xscom_id));
+					      get_xscom_id(cinfo));
 
 		fru_id = HDIF_get_idata(hdif, SPPCRD_IDATA_FRU_ID, NULL);
 		if (fru_id)
@@ -875,7 +887,7 @@ static bool add_chiptod_new(void)
 				flags |= CHIPTOD_ID_FLAGS_PRIMARY;
 		}
 
-		add_chiptod_node(be32_to_cpu(cinfo->xscom_id), flags);
+		add_chiptod_node(get_xscom_id(cinfo), flags);
 		found = true;
 	}
 	return found;
@@ -947,7 +959,7 @@ static void add_nx(void)
 			continue;
 
 		if (cinfo->nx_state)
-			add_nx_node(be32_to_cpu(cinfo->xscom_id));
+			add_nx_node(get_xscom_id(cinfo));
 	}
 }
 
@@ -1397,7 +1409,7 @@ uint32_t pcid_to_chip_id(uint32_t proc_chip_id)
 			continue;
 		}
 		if (proc_chip_id == be32_to_cpu(cinfo->proc_chip_id))
-			return be32_to_cpu(cinfo->xscom_id);
+			return get_xscom_id(cinfo);
 	}
 
 	/* Not found, what to do ? Assert ? For now return a number
diff --git a/hdata/spira.h b/hdata/spira.h
index 7da1154d7..3a8a31e1a 100644
--- a/hdata/spira.h
+++ b/hdata/spira.h
@@ -1096,6 +1096,9 @@ struct sppcrd_chip_info {
 #define	CHIP_MAX_TOPOLOGY_ENTRIES	32
 	uint8_t topology_id_table[CHIP_MAX_TOPOLOGY_ENTRIES];
 	uint8_t	primary_topology_loc;	/* Index in topology_id_table */
+	__be32  abc_bus_speed;	/* SMP A */
+	__be32  wxyz_bus_speed;	/* SMP X */
+	uint8_t	fab_topology_id;/* topology id associated with the chip. */
 } __packed;
 
 /* Idata index 1 : Chip TOD */
-- 
2.31.1



More information about the Skiboot mailing list