diff mbox series

[kernel,1/2] powerpc/powernv/npu: Move compound PEs to powernv

Message ID 20190114005601.1220-2-aik@ozlabs.ru (mailing list archive)
State Rejected
Headers show
Series powerpc/powernv/npu: Move platform shared code to sysdev | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch warning total: 0 errors, 0 warnings, 2 checks, 46 lines checked

Commit Message

Alexey Kardashevskiy Jan. 14, 2019, 12:56 a.m. UTC
We are going to move NPU code shared among pseries and powernv into sysdev.

This prepares the move by moving compound PEs from the npu struct
(which is going to move to sysdev) to powernv's phb struct as
pseries does not need this. This makes npucomp a pointer instead of
embedding it to the pnv_ohb struct so we can still have the definition of
it in npu-dma.c (the only place which uses it) and save some bytes when
there is no NPU.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 arch/powerpc/platforms/powernv/pci.h     |  4 ++++
 arch/powerpc/platforms/powernv/npu-dma.c | 10 +++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
index 8e36da3..8eb1cad 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -62,6 +62,7 @@  struct pnv_ioda_pe {
 
 	/* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */
 	struct iommu_table_group table_group;
+	/* Compound PE for P8/NPU */
 	struct npu_comp		*npucomp;
 
 	/* 64-bit TCE bypass region */
@@ -173,6 +174,9 @@  struct pnv_phb {
 	u8			*diag_data;
 
 	int p2p_target_count;
+
+	/* Compound PE for P9/NPU2 */
+	struct npu_comp *npucomp;
 };
 
 extern struct pci_ops pnv_pci_ops;
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index 2ca7982..c7cd259 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -370,8 +370,6 @@  struct npu {
 
 	/* Do we need to explicitly flush the nest mmu? */
 	bool nmmu_flush;
-
-	struct npu_comp npucomp;
 };
 
 #ifdef CONFIG_IOMMU_API
@@ -535,6 +533,7 @@  struct iommu_table_group *pnv_try_setup_npu_table_group(struct pnv_ioda_pe *pe)
 	struct npu_comp *npucomp;
 	struct pci_dev *gpdev = NULL;
 	struct pci_controller *hose;
+	struct pnv_phb *phb;
 	struct pci_dev *npdev = NULL;
 
 	list_for_each_entry(gpdev, &pe->pbus->devices, bus_list) {
@@ -548,9 +547,14 @@  struct iommu_table_group *pnv_try_setup_npu_table_group(struct pnv_ioda_pe *pe)
 		return NULL;
 
 	hose = pci_bus_to_host(npdev->bus);
+	phb = hose->private_data;
 
 	if (hose->npu) {
-		table_group = &hose->npu->npucomp.table_group;
+		if (!phb->npucomp) {
+			phb->npucomp = kzalloc(sizeof(struct npu_comp),
+					GFP_KERNEL);
+		}
+		table_group = &phb->npucomp->table_group;
 
 		if (!table_group->group) {
 			table_group->ops = &pnv_npu_peers_ops;