Skip to contentSkip to conversation

Proposed patch for MIPS PCI autoscanning code...

PATCH Steven J. Hill 2 participants 3 messages Mar 24, 2003 MIPS

lore
Share & tools
lore
#0 lore raw

In the PCI autoscanning code for MIPS the assumption is made that the generic 'pci_read_XXX' and 'pci_write_XXX' will suffice when initially autoscanning the bus. These functions are defined in the main top-level PCI code. For one of my platforms, this simply does not hold since the platform specific PCI functions defined in the 'pci_ops' structure for the 'mips_pci_channel' need to be used. I propose the following patch to fix this. Comments before I apply this?

-Steve

pci_channel.h.new renamed from pci_channel.h +2 -1
@@ -11,12 +11,13 @@
 #include <linux/pci.h>
 
 /*
- * Each pci channel is a top-level PCI bus seem by CPU.  A machine  with
+ * Each pci channel is a top-level PCI bus seen by CPU.  A machine  with
  * multiple PCI channels may have multiple PCI host controllers or a
  * single controller supporting multiple channels.
  */
 struct pci_channel {
 	struct pci_ops *pci_ops;
+	struct pci_ops *early_pci_ops;
 	struct resource *io_resource;
 	struct resource *mem_resource;
 	int first_devfn;
pci_auto.c.new renamed from pci_auto.c +8 -3
@@ -74,9 +74,14 @@
 int early_##rw##_config_##size(struct pci_channel *hose,		\
 	int top_bus, int bus, int devfn, int offset, type value)	\
 {									\
-	return pci_##rw##_config_##size(				\
-		fake_pci_dev(hose, top_bus, bus, devfn),		\
-		offset, value);						\
+	if (hose->early_pci_ops->rw##_##size != NULL)			\
+		return hose->early_pci_ops->rw##_##size(		\
+			fake_pci_dev(hose, top_bus, bus, devfn),	\
+			offset, value);					\
+	else								\
+		return pci_##rw##_config_##size(			\
+			fake_pci_dev(hose, top_bus, bus, devfn),	\
+			offset, value);					\
 }
 
 EARLY_PCI_OP(read, byte, u8 *)
#1 lore raw
Quoted 8 lines · Steven J. Hill

In the PCI autoscanning code for MIPS the assumption is made that the generic 'pci_read_XXX' and 'pci_write_XXX' will suffice when initially autoscanning the bus. These functions are defined in the main top-level PCI code. For one of my platforms, this simply does not hold since the platform specific PCI functions defined in the 'pci_ops' structure for the 'mips_pci_channel' need to be used. I propose the following patch to fix this. Comments before I apply this?

Can you illustrate more why the generic PCI functions won't work in your case?

Also, if you do check in the patch, please also update all the boards that uses pci_channel so that they will still compile.

Jun

Quoted 38 lines
pci_channel.h.new renamed from pci_channel.h +2 -1
@@ -11,12 +11,13 @@
 #include <linux/pci.h>
 
 /*
- * Each pci channel is a top-level PCI bus seem by CPU.  A machine  with
+ * Each pci channel is a top-level PCI bus seen by CPU.  A machine  with
  * multiple PCI channels may have multiple PCI host controllers or a
  * single controller supporting multiple channels.
  */
 struct pci_channel {
 	struct pci_ops *pci_ops;
+	struct pci_ops *early_pci_ops;
 	struct resource *io_resource;
 	struct resource *mem_resource;
 	int first_devfn;
pci_auto.c.new renamed from pci_auto.c +8 -3
@@ -74,9 +74,14 @@
 int early_##rw##_config_##size(struct pci_channel *hose,		\
 	int top_bus, int bus, int devfn, int offset, type value)	\
 {									\
-	return pci_##rw##_config_##size(				\
-		fake_pci_dev(hose, top_bus, bus, devfn),		\
-		offset, value);						\
+	if (hose->early_pci_ops->rw##_##size != NULL)			\
+		return hose->early_pci_ops->rw##_##size(		\
+			fake_pci_dev(hose, top_bus, bus, devfn),	\
+			offset, value);					\
+	else								\
+		return pci_##rw##_config_##size(			\
+			fake_pci_dev(hose, top_bus, bus, devfn),	\
+			offset, value);					\
 }
 
 EARLY_PCI_OP(read, byte, u8 *)
#2 lore raw
Quoted 4 lines · Jun Sun

Can you illustrate more why the generic PCI functions won't work in your case?

It turned out to be additional locking that was added in that I did not know about and hence the patch should be discarded :). Oh well, it's a Monday.

-Steve