[Skiboot] [PATCH 1/2] hw/npu: program NPU BUID reg properly

Alistair Popple alistair at popple.id.au
Fri Sep 2 14:39:57 AEST 2016

From: Milton Miller <miltonm at us.ibm.com>

The NPU BUID register was incorrectly programmed resulting in npu
interrupt level 0 causing a PB_CENT_CRESP_ADDR_ERROR checkstop,
and irqs from npus in odd chips being aliased to and processed
as the interrupts from the corresponding npu on the even chips.

The documentation for the BUID register is confusing, describing
required values of some bits and bits of differing meaning within
contained within one field.

This patch seperates the per-irq-level irq enable mask from the
documented buid base field, leaving the buid base as the part that
is directly compared.  It documents the buid as the boundary of a
block of 16 sources (in the form of a 4 bit shift), and documents
that some bits are sourced from another register and are always
compared to that register, so they are not required to be set in
the base and mask fields.

Fixes: cc61799 Nvlink: Add NPU PHB functions
Signed-off-by: Milton Miller <miltonm at us.ibm.com>
Signed-off-by: Alistair Popple <alistair at popple.id.au>
 hw/npu.c           | 20 +++++++++++++-------
 include/npu-regs.h |  4 +++-
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/hw/npu.c b/hw/npu.c
index bca53df..11e8b97 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -1614,14 +1614,20 @@ static void npu_create_devices(struct dt_node *dn, struct npu *p)
 	struct npu_dev *dev;
 	struct dt_node *npu_dn, *link;
 	uint32_t npu_phandle, index = 0;
-	uint64_t buid;
+	uint64_t buid_reg;
 	uint64_t lsisrcid;
+	uint64_t buid;
+	/* The bits in the LSI ID Base register are always compared and
+	 * can be set to 0 in the buid base and mask fields.  The
+	 * buid (bus unit id) is the full irq minus the last 4 bits. */
+	buid = p8_chip_irq_block_base(p->chip_id, P8_IRQ_BLOCK_MISC) >> 4;
-			    in_be64(p->at_regs + NPU_LSI_SOURCE_ID));
-	buid = SETFIELD(NP_BUID_BASE, 0ull,
-			(p8_chip_irq_block_base(p->chip_id, P8_IRQ_BLOCK_MISC) | lsisrcid));
-	buid |= NP_BUID_ENABLE;
+	buid_reg = SETFIELD(NP_BUID_MASK, buid_reg, ~lsisrcid);
+	buid_reg = SETFIELD(NP_BUID_BASE, buid_reg, (buid & ~lsisrcid));
 	/* Get the npu node which has the links which we expand here
 	 * into pci like devices attached to our emulated phb. */
@@ -1661,7 +1667,7 @@ static void npu_create_devices(struct dt_node *dn, struct npu *p)
 		dev->lane_mask = dt_prop_get_u32(link, "ibm,npu-lane-mask");
 		/* Setup BUID/ISRN */
-		xscom_write(p->chip_id, dev->xscom + NX_NP_BUID, buid);
+		xscom_write(p->chip_id, dev->xscom + NX_NP_BUID, buid_reg);
 		/* Setup emulated config space */
 		for (j = 0; j < NPU_DEV_CFG_MAX; j++)
diff --git a/include/npu-regs.h b/include/npu-regs.h
index f663a98..4f1a19c 100644
--- a/include/npu-regs.h
+++ b/include/npu-regs.h
@@ -52,7 +52,9 @@
 #define NX_AS_CMD_CFG			0x12
 #define NX_NP_BUID			0x13
 #define   NP_BUID_ENABLE		PPC_BIT(0)
-#define   NP_BUID_BASE			PPC_BITMASK(1,23)
+#define   NP_BUID_BASE			PPC_BITMASK(1,15)
+#define   NP_IRQ_LEVELS			PPC_BITMASK(16,23)
+#define   NP_BUID_MASK			PPC_BITMASK(24,32)
 #define NX_TL_CMD_CR			0x20
 #define NX_TL_CMD_D_CR			0x21
 #define NX_TL_RSP_CR			0x22

More information about the Skiboot mailing list