From b2b8e29dc217eb05456e8d18e7846030f9693115 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Fri, 2 Sep 2016 14:39:57 +1000 Subject: hw/npu: program NPU BUID reg properly 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 Signed-off-by: Alistair Popple Signed-off-by: Stewart Smith (cherry picked from commit 8f67ee3b7fa573885c2bda34c7934418e12287db) Signed-off-by: Stewart Smith --- 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 5247f21..2013444 100644 --- a/hw/npu.c +++ b/hw/npu.c @@ -1612,14 +1612,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. */ + lsisrcid = GETFIELD(NPU_LSI_SRC_ID_BASE, NPU_LSI_SRC_ID_BASE); + buid = p8_chip_irq_block_base(p->chip_id, P8_IRQ_BLOCK_MISC) >> 4; - lsisrcid = GETFIELD(NPU_LSI_SRC_ID_BASE, - 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_IRQ_LEVELS, NP_BUID_ENABLE, ~0); + 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. */ @@ -1659,7 +1665,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 -- cgit v1.1