Skip to contentSkip to conversation

powerpc/powernv: PCI support for p7IOC under OPAL v2

PATCH New Benjamin Herrenschmidt 1 participant 1 message Nov 16, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 powerpc/powernv: PCI support for p7IOC under OPAL v2

This adds support for p7IOC (and possibly other IODA v1 IO Hubs) using OPAL v2 interfaces.

We completely take over resource assignment and assign them using an algorithm that hands out device BARs in a way that makes them fit in individual segments of the M32 window of the bridge, which enables us to assign individual PEs to devices and functions.

The current implementation gives out a PE per functions on PCIe, and a PE for the entire bridge for PCIe to PCI-X bridges.

This can be adjusted / fine tuned later.

We also setup DMA resources (32-bit only for now) and MSIs (both 32-bit and 64-bit MSI are supported).

The DMA allocation tries to divide the available 256M segments of the 32-bit DMA address space "fairly" among PEs. This is done using a "weight" heuristic which assigns less value to things like OHCI USB controllers than, for example SCSI RAID controllers. This algorithm will probably want some fine tuning for specific devices or device types.

---
v2. Small fixes from Gavin Shan in the resource assignment code

 arch/powerpc/include/asm/pci-bridge.h     |    6 +-
 arch/powerpc/kernel/pci_dn.c              |    3 +
 arch/powerpc/platforms/powernv/Makefile   |    2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c | 1320 +++++++++++++++++++++++++++++
 arch/powerpc/platforms/powernv/pci.c      |   20 +-
 arch/powerpc/platforms/powernv/pci.h      |   84 ++
 6 files changed, 1429 insertions(+), 6 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/include/asm/pci-bridge.h +5 -1
index 56b879a..882b6aa 100644
@@ -153,8 +153,8 @@ struct pci_dn {
 
 	int	pci_ext_config_space;	/* for pci devices */
 
-#ifdef CONFIG_EEH
 	struct	pci_dev *pcidev;	/* back-pointer to the pci device */
+#ifdef CONFIG_EEH
 	int	class_code;		/* pci device class */
 	int	eeh_mode;		/* See eeh.h for possible EEH_MODEs */
 	int	eeh_config_addr;
@@ -164,6 +164,10 @@ struct pci_dn {
 	int	eeh_false_positives;	/* # times this device reported #ff's */
 	u32	config_space[16];	/* saved PCI config space */
 #endif
+#define IODA_INVALID_PE		(-1)
+#ifdef CONFIG_PPC_POWERNV
+	int	pe_number;
+#endif
 };
 
 /* Get the pointer to a device_node's pci_dn */
arch/powerpc/kernel/pci_dn.c +3 -0
index 4e69deb..dd9e4a0 100644
@@ -50,6 +50,9 @@ void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
 	dn->data = pdn;
 	pdn->node = dn;
 	pdn->phb = phb;
+#ifdef CONFIG_PPC_POWERNV
+	pdn->pe_number = IODA_INVALID_PE;
+#endif
 	regs = of_get_property(dn, "reg", NULL);
 	if (regs) {
 		/* First register entry is addr (00BBSS00)  */
arch/powerpc/platforms/powernv/Makefile +1 -1
index 3185300..bcc3cb48 100644
@@ -2,4 +2,4 @@ obj-y			+= setup.o opal-takeover.o opal-wrappers.o opal.o
 obj-y			+= opal-rtc.o opal-nvram.o
 
 obj-$(CONFIG_SMP)	+= smp.o
-obj-$(CONFIG_PCI)	+= pci.o pci-p5ioc2.o
+obj-$(CONFIG_PCI)	+= pci.o pci-p5ioc2.o pci-ioda.o
arch/powerpc/platforms/powernv/pci-ioda.c new file +1320 -0

1,320 lines not on this page · raw message

arch/powerpc/platforms/powernv/pci.c +16 -4
index baef772..c0ed379 100644
@@ -467,12 +467,24 @@ void __init pnv_pci_init(void)
 		init_pci_config_tokens();
 		find_and_init_phbs();
 #endif /* CONFIG_PPC_POWERNV_RTAS */
-	} else {
-		/* OPAL is here, do our normal stuff */
+	}
+	/* OPAL is here, do our normal stuff */
+	else {
+		int found_ioda = 0;
+
+		/* Look for IODA IO-Hubs. We don't support mixing IODA
+		 * and p5ioc2 due to the need to change some global
+		 * probing flags
+		 */
+		for_each_compatible_node(np, NULL, "ibm,ioda-hub") {
+			pnv_pci_init_ioda_hub(np);
+			found_ioda = 1;
+		}
 
 		/* Look for p5ioc2 IO-Hubs */
-		for_each_compatible_node(np, NULL, "ibm,p5ioc2")
-			pnv_pci_init_p5ioc2_hub(np);
+		if (!found_ioda)
+			for_each_compatible_node(np, NULL, "ibm,p5ioc2")
+				pnv_pci_init_p5ioc2_hub(np);
 	}
 
 	/* Setup the linkage between OF nodes and PHBs */
arch/powerpc/platforms/powernv/pci.h +84 -0

102 lines not on this page · raw message