linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/powernv: Change NPU PE# assignment
@ 2016-01-11  5:53 Alistair Popple
  2016-01-11  5:53 ` [PATCH 2/2] powerpc/powernv: Reserve PE#0 on NPU Alistair Popple
  2016-01-12 12:32 ` [1/2] powerpc/powernv: Change NPU PE# assignment Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Alistair Popple @ 2016-01-11  5:53 UTC (permalink / raw)
  To: mpe; +Cc: linuxppc-dev, gwshan, ruscur, benh, Alistair Popple

The P8+ hardware supports four partitionable endpoints (PEs) however
the hardware reports all errors as occurring on PE#0. This means we
need to reserve this PE for error handling (EEH) and not assign it to
a NPU device, implying that some devices will need to share PEs.

This patch changes the PE assignment for NPU devices such that NPU
devices which connect to the same GPU are assigned to the same
PE#.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 73 ++++++++++++++++++++++++++++---
 1 file changed, 66 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 458133f..0b625272 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1074,16 +1074,75 @@ static void pnv_ioda_setup_bus_PE(struct pci_bus *bus, bool all)
 	pnv_ioda_link_pe_by_weight(phb, pe);
 }
 
-static void pnv_ioda_setup_dev_PEs(struct pci_bus *bus)
+static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
+{
+	int pe_num, found_pe = false, rc;
+	long rid;
+	struct pnv_ioda_pe *pe;
+	struct pci_dev *gpu_pdev;
+	struct pci_dn *npu_pdn;
+	struct pci_controller *hose = pci_bus_to_host(npu_pdev->bus);
+	struct pnv_phb *phb = hose->private_data;
+
+	/*
+	 * Due to a hardware errata PE#0 on the NPU is reserved for
+	 * error handling. This means we only have three PEs remaining
+	 * which need to be assigned to four links, implying some
+	 * links must share PEs.
+	 *
+	 * To achieve this we assign PEs such that NPUs linking the
+	 * same GPU get assigned the same PE.
+	 */
+	gpu_pdev = pnv_pci_get_gpu_dev(npu_pdev);
+	for (pe_num = 0; pe_num < phb->ioda.total_pe; pe_num++) {
+		pe = &phb->ioda.pe_array[pe_num];
+		if (!pe->pdev)
+			continue;
+
+		if (pnv_pci_get_gpu_dev(pe->pdev) == gpu_pdev) {
+			/*
+			 * This device has the same peer GPU so should
+			 * be assigned the same PE as the existing
+			 * peer NPU.
+			 */
+			dev_info(&npu_pdev->dev,
+				"Associating to existing PE %d\n", pe_num);
+			pci_dev_get(npu_pdev);
+			npu_pdn = pci_get_pdn(npu_pdev);
+			rid = npu_pdev->bus->number << 8 | npu_pdn->devfn;
+			npu_pdn->pcidev = npu_pdev;
+			npu_pdn->pe_number = pe_num;
+			pe->dma_weight += pnv_ioda_dma_weight(npu_pdev);
+			phb->ioda.pe_rmap[rid] = pe->pe_number;
+
+			/* Map the PE to this link */
+			rc = opal_pci_set_pe(phb->opal_id, pe_num, rid,
+					OpalPciBusAll,
+					OPAL_COMPARE_RID_DEVICE_NUMBER,
+					OPAL_COMPARE_RID_FUNCTION_NUMBER,
+					OPAL_MAP_PE);
+			WARN_ON(rc != OPAL_SUCCESS);
+			found_pe = true;
+			break;
+		}
+	}
+
+	if (!found_pe)
+		/*
+		 * Could not find an existing PE so allocate a new
+		 * one.
+		 */
+		return pnv_ioda_setup_dev_PE(npu_pdev);
+	else
+		return pe;
+}
+
+static void pnv_ioda_setup_npu_PEs(struct pci_bus *bus)
 {
-	struct pci_bus *child;
 	struct pci_dev *pdev;
 
 	list_for_each_entry(pdev, &bus->devices, bus_list)
-		pnv_ioda_setup_dev_PE(pdev);
-
-	list_for_each_entry(child, &bus->children, node)
-		pnv_ioda_setup_dev_PEs(child);
+		pnv_ioda_setup_npu_PE(pdev);
 }
 
 static void pnv_ioda_setup_PEs(struct pci_bus *bus)
@@ -1128,7 +1187,7 @@ static void pnv_pci_ioda_setup_PEs(void)
 		 * remaining types of PHBs.
 		 */
 		if (phb->type == PNV_PHB_NPU)
-			pnv_ioda_setup_dev_PEs(hose->bus);
+			pnv_ioda_setup_npu_PEs(hose->bus);
 		else
 			pnv_ioda_setup_PEs(hose->bus);
 	}
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] powerpc/powernv: Reserve PE#0 on NPU
  2016-01-11  5:53 [PATCH 1/2] powerpc/powernv: Change NPU PE# assignment Alistair Popple
@ 2016-01-11  5:53 ` Alistair Popple
  2016-01-12 12:32   ` [2/2] " Michael Ellerman
  2016-01-12 12:32 ` [1/2] powerpc/powernv: Change NPU PE# assignment Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Alistair Popple @ 2016-01-11  5:53 UTC (permalink / raw)
  To: mpe; +Cc: linuxppc-dev, gwshan, ruscur, benh, Alistair Popple

P8+ hardware reports all errors on PE#0. This patch ensures PE#0 is
not assigned to NPU devices so that it can be used for EEH.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 0b625272..573ae19 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1186,9 +1186,11 @@ static void pnv_pci_ioda_setup_PEs(void)
 		 * functions. PCI bus dependent PEs are required for the
 		 * remaining types of PHBs.
 		 */
-		if (phb->type == PNV_PHB_NPU)
+		if (phb->type == PNV_PHB_NPU) {
+			/* PE#0 is needed for error reporting */
+			pnv_ioda_reserve_pe(phb, 0);
 			pnv_ioda_setup_npu_PEs(hose->bus);
-		else
+		} else
 			pnv_ioda_setup_PEs(hose->bus);
 	}
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [1/2] powerpc/powernv: Change NPU PE# assignment
  2016-01-11  5:53 [PATCH 1/2] powerpc/powernv: Change NPU PE# assignment Alistair Popple
  2016-01-11  5:53 ` [PATCH 2/2] powerpc/powernv: Reserve PE#0 on NPU Alistair Popple
@ 2016-01-12 12:32 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-01-12 12:32 UTC (permalink / raw)
  To: Alistair Popple; +Cc: linuxppc-dev, Alistair Popple, gwshan

On Mon, 2016-11-01 at 05:53:49 UTC, Alistair Popple wrote:
> The P8+ hardware supports four partitionable endpoints (PEs) however
> the hardware reports all errors as occurring on PE#0. This means we
> need to reserve this PE for error handling (EEH) and not assign it to
> a NPU device, implying that some devices will need to share PEs.
> 
> This patch changes the PE assignment for NPU devices such that NPU
> devices which connect to the same GPU are assigned to the same
> PE#.
> 
> Signed-off-by: Alistair Popple <alistair@popple.id.au>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b521549a09ddfac3bed38e2611

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [2/2] powerpc/powernv: Reserve PE#0 on NPU
  2016-01-11  5:53 ` [PATCH 2/2] powerpc/powernv: Reserve PE#0 on NPU Alistair Popple
@ 2016-01-12 12:32   ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-01-12 12:32 UTC (permalink / raw)
  To: Alistair Popple; +Cc: linuxppc-dev, Alistair Popple, gwshan

On Mon, 2016-11-01 at 05:53:50 UTC, Alistair Popple wrote:
> P8+ hardware reports all errors on PE#0. This patch ensures PE#0 is
> not assigned to NPU devices so that it can be used for EEH.
> 
> Signed-off-by: Alistair Popple <alistair@popple.id.au>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/08f48f3234a79bca86c2283a16

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-12 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-11  5:53 [PATCH 1/2] powerpc/powernv: Change NPU PE# assignment Alistair Popple
2016-01-11  5:53 ` [PATCH 2/2] powerpc/powernv: Reserve PE#0 on NPU Alistair Popple
2016-01-12 12:32   ` [2/2] " Michael Ellerman
2016-01-12 12:32 ` [1/2] powerpc/powernv: Change NPU PE# assignment Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).