From patchwork Thu Jun 22 16:22:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 779601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wtn4b1t3jz9t0F for ; Fri, 23 Jun 2017 02:25:35 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wtn4b12b9zDr0J for ; Fri, 23 Jun 2017 02:25:35 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wtn3L6Z10zDr6G for ; Fri, 23 Jun 2017 02:24:30 +1000 (AEST) Received: from pasglop.austin.ibm.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id v5MGMaCT024844; Thu, 22 Jun 2017 11:23:24 -0500 From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Thu, 22 Jun 2017 11:22:10 -0500 Message-Id: <20170622162225.26344-9-benh@kernel.crashing.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170622162225.26344-1-benh@kernel.crashing.org> References: <20170622162225.26344-1-benh@kernel.crashing.org> Subject: [Skiboot] [PATCH 09/24] psi: Use phys_map to setup the BARs X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Removes the hard coded address and the useless warning Signed-off-by: Benjamin Herrenschmidt # Conflicts: # hw/psi.c --- hw/phys-map.c | 2 +- hw/psi.c | 48 +++++++++++++++++++----------------------------- include/phys-map.h | 2 +- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/hw/phys-map.c b/hw/phys-map.c index e99983f..0fbd60d 100644 --- a/hw/phys-map.c +++ b/hw/phys-map.c @@ -109,7 +109,7 @@ static const struct phys_map_entry phys_map_table_nimbus[] = { { NPU_GENID , 1, 0x00060302016e0000ull, 0x0000000000020000ull }, { NPU_GENID , 2, 0x0006030201700000ull, 0x0000000000020000ull }, { RESV , 5, 0x0006030201720000ull, 0x00000000018e0000ull }, - { PSI_LINK , 0, 0x0006030203000000ull, 0x0000000000100000ull }, + { PSIHB_REG , 0, 0x0006030203000000ull, 0x0000000000100000ull }, { XIVE_IC , 0, 0x0006030203100000ull, 0x0000000000080000ull }, { XIVE_TM , 0, 0x0006030203180000ull, 0x0000000000040000ull }, { PSIHB_ESB , 0, 0x00060302031c0000ull, 0x0000000000010000ull }, diff --git a/hw/psi.c b/hw/psi.c index 571714a..41ca1b7 100644 --- a/hw/psi.c +++ b/hw/psi.c @@ -34,6 +34,7 @@ #include #include #include +#include static LIST_HEAD(psis); static u64 psi_link_timer; @@ -821,7 +822,7 @@ static void psi_init_p8_interrupts(struct psi *psi) static void psi_init_p9_interrupts(struct psi *psi) { - struct proc_chip *c; + struct proc_chip *chip; bool is_p9ndd1; u64 val; @@ -829,20 +830,20 @@ static void psi_init_p9_interrupts(struct psi *psi) out_be64(psi->regs + PSIHB_INTERRUPT_CONTROL, PSIHB_IRQ_RESET); out_be64(psi->regs + PSIHB_INTERRUPT_CONTROL, 0); -#define PSIHB_ESB_MMIO_DEFAULT 0x0060302031c0000ull + /* Grab chip */ + chip = get_chip(psi->chip_id); + if (!chip) + return; + + /* Configure the CI BAR */ + phys_map_get(chip->id, PSIHB_ESB, 0, &val, NULL); + val |= PSIHB_ESB_CI_VALID; + out_be64(psi->regs + PSIHB_ESB_CI_BASE, val); - /* Configure the CI BAR if necessary */ - val = in_be64(psi->regs + PSIHB_ESB_CI_BASE); - if (!(val & PSIHB_ESB_CI_VALID)) { - val = PSIHB_ESB_MMIO_DEFAULT | PSIHB_ESB_CI_VALID; - val |= (0x40000000000ull * (uint64_t)psi->chip_id); - out_be64(psi->regs + PSIHB_ESB_CI_BASE, val); - printf("PSI[0x%03x]: ESB MMIO invalid, reconfiguring...\n", - psi->chip_id); - } val = in_be64(psi->regs + PSIHB_ESB_CI_BASE); psi->esb_mmio = (void *)(val & ~PSIHB_ESB_CI_VALID); - printf("PSI[0x%03x]: ESB MMIO at @%p\n", psi->chip_id, psi->esb_mmio); + prlog(PR_DEBUG, "PSI[0x%03x]: ESB MMIO at @%p\n", + psi->chip_id, psi->esb_mmio); /* Grab and configure the notification port */ val = xive_get_notify_port(psi->chip_id, XIVE_HW_SRC_PSI); @@ -855,7 +856,6 @@ static void psi_init_p9_interrupts(struct psi *psi) out_be64(psi->regs + PSIHB_IVT_OFFSET, val); /* Register sources */ - c = next_chip(NULL); is_p9ndd1 = (c && c->ec_level >= 0x10 && c->type == PROC_CHIP_P9_NIMBUS); @@ -1050,26 +1050,16 @@ static struct psi *psi_probe_p8(struct proc_chip *chip, u64 base) static struct psi *psi_probe_p9(struct proc_chip *chip, u64 base) { struct psi *psi = NULL; - uint64_t rc, val; + uint64_t addr; + + phys_map_get(chip->id, PSIHB_REG, 0, &addr, NULL); + xscom_write(chip->id, base + PSIHB_XSCOM_P9_BASE, + addr | PSIHB_XSCOM_P9_HBBAR_EN); - rc = xscom_read(chip->id, base + PSIHB_XSCOM_P9_BASE, &val); - if (rc) { - prerror("PSI[0x%03x]: Error %llx reading PSIHB BAR\n", - chip->id, rc); - return NULL; - } - if (!val & PSIHB_XSCOM_P9_HBBAR_EN) { - prerror("PSI[0x%03x]: PSIHB BAR Disabled,fixing up (%016llx)\n", - chip->id, val); -#define PSIHB_PSI_MMIO_DEFAULT 0x006030203000000ull - val = PSIHB_PSI_MMIO_DEFAULT | PSIHB_XSCOM_P9_HBBAR_EN; - val |= (0x40000000000ull * (uint64_t)chip->id); - xscom_write(chip->id, base + PSIHB_XSCOM_P9_BASE, val); - } psi = alloc_psi(chip, base); if (!psi) return NULL; - psi->regs = (void *)(val & ~PSIHB_XSCOM_P9_HBBAR_EN); + psi->regs = (void *)addr; psi->interrupt = xive_alloc_hw_irqs(chip->id, P9_PSI_NUM_IRQS, 16); return psi; } diff --git a/include/phys-map.h b/include/phys-map.h index 434b159..3621bfd 100644 --- a/include/phys-map.h +++ b/include/phys-map.h @@ -44,7 +44,7 @@ enum phys_map_type { NPU_PHY, NPU_NTL, NPU_GENID, - PSI_LINK, + PSIHB_REG, XIVE_IC, XIVE_TM, PSIHB_ESB,