diff mbox series

[v2,6/8] npu2: Add checks to npu2-only codepaths

Message ID 1562620038-7017-7-git-send-email-arbab@linux.ibm.com
State Superseded
Headers show
Series Support the updated NPU in POWER9P; npu3 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (4db38a36b31045f0a116d388ddeac850b38c8680)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Reza Arbab July 8, 2019, 9:07 p.m. UTC
To prepare for npu3, add a few checks in codepaths that are only for
npu2. Compare against PVR_TYPE_P9, as npu3 will be in systems of
PVR_TYPE_P9P (or greater). Alternatively, check for dt compatibility
with "ibm,power9-npu" because npu3 will use "ibm,power9-npu3".

Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
---
 core/hmi.c       | 4 ++++
 hdata/spira.c    | 6 +++---
 hw/npu2-common.c | 4 ++++
 3 files changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/core/hmi.c b/core/hmi.c
index 5cde67138109..2202bfba9ca2 100644
--- a/core/hmi.c
+++ b/core/hmi.c
@@ -636,6 +636,10 @@  static void find_npu2_checkstop_reason(int flat_chip_id,
 	int total_errors = 0;
 	const char *loc;
 
+	/* NPU2 only */
+	if (PVR_TYPE(mfspr(SPR_PVR)) != PVR_TYPE_P9)
+		return;
+
 	/* Find the NPU on the chip associated with the HMI. */
 	for_each_phb(phb) {
 		/* NOTE: if a chip ever has >1 NPU this will need adjusting */
diff --git a/hdata/spira.c b/hdata/spira.c
index 6891a9c71bdf..804d90da34a1 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -1506,7 +1506,8 @@  static void add_npus(void)
 	int phb_index = 7; /* Start counting from 7, for no reason */
 	int npu_index = 0;
 
-	if (proc_gen < proc_gen_p9)
+	/* Only consult HDAT for npu2 */
+	if (cpu_type != PVR_TYPE_P9)
 		return;
 
 	dt_for_each_compatible(dt_root, xscom, "ibm,xscom") {
@@ -1633,8 +1634,7 @@  int parse_hdat(bool is_opal)
 	io_parse();
 
 	/* Add NPU nodes */
-	if (proc_gen >= proc_gen_p9)
-		add_npus();
+	add_npus();
 
 	/* Parse VPD */
 	vpd_parse();
diff --git a/hw/npu2-common.c b/hw/npu2-common.c
index f3f2f45a10d4..776030759693 100644
--- a/hw/npu2-common.c
+++ b/hw/npu2-common.c
@@ -654,6 +654,10 @@  void probe_npu2(void)
 	struct dt_node *np;
 	const char *zcal;
 
+	/* npu2 only */
+	if (!dt_find_compatible_node(dt_root, NULL, "ibm,power9-npu"))
+		return;
+
 	/* Abort if we're running on POWER9C DD1 (P9N DD1 is not supported) */
 	if (chip &&
 	    chip->type == PROC_CHIP_P9_CUMULUS &&