[PATCH] ppc64: Use pci_device_to_OF_node

Anton Blanchard anton at samba.org
Sun Nov 14 10:48:06 EST 2004


PCI_GET_DN() doesnt check to see if ->sysdata has been initialised
correctly - we should instead use pci_device_to_OF_node. Leave
PCI_GET_DN() in the one performance critical case (iommu table lookup in
pci DMA functions). In this case ->sysdata is guaranteed to have been
initialised by the iommu setup code.

Signed-off-by: Anton Blanchard <anton at samba.org>

diff -puN arch/ppc64/kernel/pSeries_iommu.c~remove_PCI_GET_DN arch/ppc64/kernel/pSeries_iommu.c
--- foobar2/arch/ppc64/kernel/pSeries_iommu.c~remove_PCI_GET_DN	2004-11-13 10:08:48.224833361 +1100
+++ foobar2-anton/arch/ppc64/kernel/pSeries_iommu.c	2004-11-13 10:24:20.385047282 +1100
@@ -290,7 +290,11 @@ static void iommu_buses_init_lpar(struct
 
 	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
 		bus = pci_bus_b(ln);
-		busdn = PCI_GET_DN(bus);
+
+		if (bus->self)
+			busdn = pci_device_to_OF_node(bus->self);
+		else
+			busdn = bus->sysdata;   /* must be a phb */
 
 		dma_window = (unsigned int *)get_property(busdn, "ibm,dma-window", NULL);
 		if (dma_window) {
@@ -423,7 +427,7 @@ void iommu_setup_pSeries(void)
 	 * up the device tree to find it.
 	 */
 	for_each_pci_dev(dev) {
-		mydn = dn = PCI_GET_DN(dev);
+		mydn = dn = pci_device_to_OF_node(dev);
 
 		while (dn && dn->iommu_table == NULL)
 			dn = dn->parent;
diff -puN include/asm-ppc64/pci-bridge.h~remove_PCI_GET_DN include/asm-ppc64/pci-bridge.h
--- foobar2/include/asm-ppc64/pci-bridge.h~remove_PCI_GET_DN	2004-11-13 10:18:33.520682245 +1100
+++ foobar2-anton/include/asm-ppc64/pci-bridge.h	2004-11-13 10:18:52.171300722 +1100
@@ -84,11 +84,6 @@ extern void pci_process_bridge_OF_ranges
 
 extern int pcibios_remove_root_bus(struct pci_controller *phb);
 
-/* Use this macro after the PCI bus walk for max performance when it
- * is known that sysdata is correct.
- */
-#define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
-
 extern void phbs_remap_io(void);
 
 static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
diff -puN arch/ppc64/kernel/pci_iommu.c~remove_PCI_GET_DN arch/ppc64/kernel/pci_iommu.c
--- foobar2/arch/ppc64/kernel/pci_iommu.c~remove_PCI_GET_DN	2004-11-13 10:19:05.203239344 +1100
+++ foobar2-anton/arch/ppc64/kernel/pci_iommu.c	2004-11-13 10:20:53.108170239 +1100
@@ -43,6 +43,13 @@
 #include <asm/iSeries/iSeries_pci.h>
 #endif /* CONFIG_PPC_ISERIES */
 
+/* 
+ * We can use ->sysdata directly and avoid the extra work in
+ * pci_device_to_OF_node since ->sysdata will have been initialised
+ * in the iommu init code for all devices.
+ */
+#define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
+
 static inline struct iommu_table *devnode_table(struct pci_dev *dev)
 {
 	if (!dev)
_



More information about the Linuxppc64-dev mailing list