[Skiboot] [PATCH 2/3] hw/npu: Get AT BAR from MMIO layout

Gavin Shan gwshan at linux.vnet.ibm.com
Wed Jul 6 13:20:02 AEST 2016


The DL/PL/AT BARs are assigned according to predetermined MMIO
layout by assign_mmio_bars() when probing NPU device node in
npu_probe_phb(). The AT BAR is covered by NPU LINK#1's second
BAR. assign_mmio_bars() updates the AT BAR register with the
predetermined values (base/size) and then npu_probe_phb() gets
same informatin from the register, which is unecessary.

This passes @at_bar[] to assign_mmio_bars[] where @at_bar[] are
filled, so that assign_mmio_bars() can use it directly without
getting it from AT BAR register. As a result, the code looks a
bit simplified.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 hw/npu.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/hw/npu.c b/hw/npu.c
index c1b1975..a7f5523 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -1000,7 +1000,8 @@ static const struct phb_ops npu_ops = {
 };
 
 static void assign_mmio_bars(uint32_t gcid, uint32_t xscom,
-			     struct dt_node *npu_dn, uint64_t mm_win[2])
+			     struct dt_node *npu_dn, uint64_t mm_win[2],
+			     uint64_t at_bar[2])
 {
 	uint64_t mem_start, mem_end;
 	struct npu_dev_bar bar;
@@ -1055,6 +1056,8 @@ static void assign_mmio_bars(uint32_t gcid, uint32_t xscom,
 	bar.xscom = npu_link_scom_base(npu_dn, xscom, 1) + NX_MMIO_BAR_1;
 	bar.base += bar.size;
 	bar.size = NX_MMIO_AT_SIZE;
+	at_bar[0] = bar.base;
+	at_bar[1] = NX_MMIO_AT_SIZE;
 	npu_dev_bar_update(gcid, &bar, true);
 
 	/* Now we configure all the DLTL BARs. These are the ones
@@ -1088,7 +1091,7 @@ static void npu_probe_phb(struct dt_node *dn)
 {
 	struct dt_node *np;
 	uint32_t gcid, index, phb_index, xscom;
-	uint64_t at_bar[2], mm_win[2], val;
+	uint64_t at_bar[2], mm_win[2];
 	uint32_t links;
 	char *path;
 
@@ -1106,22 +1109,7 @@ static void npu_probe_phb(struct dt_node *dn)
 	xscom = dt_get_address(dn, 0, NULL);
 	prlog(PR_INFO, "   XSCOM Base:  %08x\n", xscom);
 
-	assign_mmio_bars(gcid, xscom, dn, mm_win);
-
-	/* Retrieve AT BAR */
-	xscom_read(gcid, npu_link_scom_base(dn, xscom, 1) + NX_MMIO_BAR_1,
-		   &val);
-	if (!(val & NX_MMIO_BAR_ENABLE)) {
-		/**
-		 * @fwts-label NPUATBARDisabled
-		 * @fwts-advice NVLink not functional
-		 */
-		prlog(PR_ERR, "   AT BAR disabled!\n");
-		return;
-	}
-
-	at_bar[0] = GETFIELD(NX_MMIO_BAR_BASE, val) << 12;
-	at_bar[1] = get_bar_size(val);
+	assign_mmio_bars(gcid, xscom, dn, mm_win, at_bar);
 	prlog(PR_INFO, "   AT BAR:      %016llx (%lldKB)\n",
 	      at_bar[0], at_bar[1] / 0x400);
 
-- 
2.1.0



More information about the Skiboot mailing list