[PATCH] ppc64/ppc: Cleanup PCI skipping

Benjamin Herrenschmidt benh at kernel.crashing.org
Wed Jan 19 13:54:51 EST 2005


Hi !

The g5 code has special hooks to "hide" some PCI devices when they are off.

Currently, this code involves some calls to match a pci_dev from the open firmware
node and such things that are causing some problems with the latest version of
my sungem driver who wants to do some of this in atomic contexts.

This patch moves that to a list of struct device_node instead, which also ends up
simplifying the code.

Later, I'll go back to manipulating PCI devices in a clean way when Brian King's
PCI blocking patch gets in, but only after I change sungem again to never call
these in atomic context. This is a 3 step transition basically

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Index: linux-work/arch/ppc64/kernel/pmac_feature.c
===================================================================
--- linux-work.orig/arch/ppc64/kernel/pmac_feature.c	2004-11-22 11:49:24.000000000 +1100
+++ linux-work/arch/ppc64/kernel/pmac_feature.c	2005-01-19 13:48:25.000000000 +1100
@@ -111,7 +111,7 @@
 static u32 uninorth_rev __pmacdata;
 static void *u3_ht;
 
-extern struct pci_dev *k2_skiplist[2];
+extern struct device_node *k2_skiplist[2];
 
 /*
  * For each motherboard family, we have a table of functions pointers
@@ -160,30 +160,17 @@
 {
 	struct macio_chip* macio = &macio_chips[0];
 	unsigned long flags;
-	struct pci_dev *pdev = NULL;
 
 	if (node == NULL)
 		return -ENODEV;
 
-	/* XXX FIXME: We should fix pci_device_from_OF_node here, and
-	 * get to a real pci_dev or we'll get into trouble with PCI
-	 * domains the day we get overlapping numbers (like if we ever
-	 * decide to show the HT root.
-	 * Note that we only get the slot when value is 0. This is called
-	 * early during boot with value 1 to enable all devices, at which
-	 * point, we don't yet have probed pci_find_slot, so it would fail
-	 * to look for the slot at this point.
-	 */
-	if (!value)
-		pdev = pci_find_slot(node->busno, node->devfn);
-
 	LOCK(flags);
 	if (value) {
 		MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
 		mb();
 		k2_skiplist[0] = NULL;
 	} else {
-		k2_skiplist[0] = pdev;
+		k2_skiplist[0] = node;
 		mb();
 		MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
 	}
@@ -198,30 +185,17 @@
 {
 	struct macio_chip* macio = &macio_chips[0];
 	unsigned long flags;
-	struct pci_dev *pdev = NULL;
 
-	/* XXX FIXME: We should fix pci_device_from_OF_node here, and
-	 * get to a real pci_dev or we'll get into trouble with PCI
-	 * domains the day we get overlapping numbers (like if we ever
-	 * decide to show the HT root
-	 * Note that we only get the slot when value is 0. This is called
-	 * early during boot with value 1 to enable all devices, at which
-	 * point, we don't yet have probed pci_find_slot, so it would fail
-	 * to look for the slot at this point.
-	 */
 	if (node == NULL)
 		return -ENODEV;
 
-	if (!value)
-		pdev = pci_find_slot(node->busno, node->devfn);
-
 	LOCK(flags);
 	if (value) {
 		MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
 		mb();
 		k2_skiplist[1] = NULL;
 	} else {
-		k2_skiplist[1] = pdev;
+		k2_skiplist[1] = node;
 		mb();
 		MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
 	}
Index: linux-work/arch/ppc64/kernel/pmac_pci.c
===================================================================
--- linux-work.orig/arch/ppc64/kernel/pmac_pci.c	2005-01-14 08:17:11.000000000 +1100
+++ linux-work/arch/ppc64/kernel/pmac_pci.c	2005-01-19 13:44:50.000000000 +1100
@@ -43,7 +43,7 @@
  * assuming we won't have both UniNorth and Bandit */
 static int has_uninorth;
 static struct pci_controller *u3_agp;
-struct pci_dev *k2_skiplist[2];
+struct device_node *k2_skiplist[2];
 
 static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
 {
@@ -233,15 +233,6 @@
 	struct device_node *busdn, *dn;
 	int i;
 
-	/*
-	 * When a device in K2 is powered down, we die on config
-	 * cycle accesses. Fix that here.
-	 */
-	for (i=0; i<2; i++)
-		if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
-		    k2_skiplist[i]->devfn == devfn)
-			return 1;
-
 	/* We only allow config cycles to devices that are in OF device-tree
 	 * as we are apparently having some weird things going on with some
 	 * revs of K2 on recent G5s
@@ -256,6 +247,14 @@
 	if (dn == NULL)
 		return -1;
 
+	/*
+	 * When a device in K2 is powered down, we die on config
+	 * cycle accesses. Fix that here.
+	 */
+	for (i=0; i<2; i++)
+		if (k2_skiplist[i] == dn)
+			return 1;
+
 	return 0;
 }
 
Index: linux-work/arch/ppc/platforms/pmac_feature.c
===================================================================
--- linux-work.orig/arch/ppc/platforms/pmac_feature.c	2005-01-18 17:50:10.000000000 +1100
+++ linux-work/arch/ppc/platforms/pmac_feature.c	2005-01-19 13:46:06.000000000 +1100
@@ -56,7 +56,7 @@
 #endif
 
 extern int powersave_nap;
-extern struct pci_dev *k2_skiplist[2];
+extern struct device_node *k2_skiplist[2];
 
 
 /*
@@ -1328,16 +1328,6 @@
 {
 	struct macio_chip* macio = &macio_chips[0];
 	unsigned long flags;
-	struct pci_dev *pdev;
-	u8 pbus, pid;
-
-	/* XXX FIXME: We should fix pci_device_from_OF_node here, and
-	 * get to a real pci_dev or we'll get into trouble with PCI
-	 * domains the day we get overlapping numbers (like if we ever
-	 * decide to show the HT root
-	 */
-	if (pci_device_from_OF_node(node, &pbus, &pid) == 0)
-		pdev = pci_find_slot(pbus, pid);
 
 	LOCK(flags);
 	if (value) {
@@ -1345,7 +1335,7 @@
 		mb();
 		k2_skiplist[0] = NULL;
 	} else {
-		k2_skiplist[0] = pdev;
+		k2_skiplist[0] = node;
 		mb();
 		MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
 	}
@@ -1361,16 +1351,6 @@
 {
 	struct macio_chip* macio = &macio_chips[0];
 	unsigned long flags;
-	struct pci_dev *pdev;
-	u8 pbus, pid;
-
-	/* XXX FIXME: We should fix pci_device_from_OF_node here, and
-	 * get to a real pci_dev or we'll get into trouble with PCI
-	 * domains the day we get overlapping numbers (like if we ever
-	 * decide to show the HT root
-	 */
-	if (pci_device_from_OF_node(node, &pbus, &pid) == 0)
-		pdev = pci_find_slot(pbus, pid);
 
 	LOCK(flags);
 	if (value) {
@@ -1378,7 +1358,7 @@
 		mb();
 		k2_skiplist[1] = NULL;
 	} else {
-		k2_skiplist[1] = pdev;
+		k2_skiplist[1] = node;
 		mb();
 		MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
 	}
Index: linux-work/arch/ppc/platforms/pmac_pci.c
===================================================================
--- linux-work.orig/arch/ppc/platforms/pmac_pci.c	2005-01-18 17:50:11.000000000 +1100
+++ linux-work/arch/ppc/platforms/pmac_pci.c	2005-01-19 13:46:58.000000000 +1100
@@ -52,7 +52,7 @@
 extern u8 pci_cache_line_size;
 extern int pcibios_assign_bus_offset;
 
-struct pci_dev *k2_skiplist[2];
+struct device_node *k2_skiplist[2];
 
 /*
  * Magic constants for enabling cache coherency in the bandit/PSX bridge.
@@ -325,8 +325,7 @@
 	 * cycle accesses. Fix that here.
 	 */
 	for (i=0; i<2; i++)
-		if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
-		    k2_skiplist[i]->devfn == devfn) {
+		if (k2_skiplist[i] == np) { 
 			switch (len) {
 			case 1:
 				*val = 0xff; break;
@@ -375,8 +374,7 @@
 	 * cycle accesses. Fix that here.
 	 */
 	for (i=0; i<2; i++)
-		if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
-		    k2_skiplist[i]->devfn == devfn)
+		if (k2_skiplist[i] == np)
 			return PCIBIOS_SUCCESSFUL;
 
 	addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);





More information about the Linuxppc64-dev mailing list