
From: Anton Blanchard <anton@samba.org>

Implement eeh_add_device_early and eeh_add_device_late, required for
the ppc64 PCI hotplug code.

Signed-off-by: Linas Vepstas <linas@us.ibm.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/ppc64/kernel/eeh.c |   51 ++++++++++++++++++++++++----------------
 25-akpm/include/asm-ppc64/eeh.h |   16 ++++++------
 2 files changed, 39 insertions(+), 28 deletions(-)

diff -puN arch/ppc64/kernel/eeh.c~ppc64-add-eeh_add_device_early-late arch/ppc64/kernel/eeh.c
--- 25/arch/ppc64/kernel/eeh.c~ppc64-add-eeh_add_device_early-late	2004-05-31 17:04:16.163814808 -0700
+++ 25-akpm/arch/ppc64/kernel/eeh.c	2004-05-31 17:04:16.168814048 -0700
@@ -612,33 +612,25 @@ void __init eeh_init(void)
 }
 
 /**
- * eeh_add_device - perform EEH initialization for the indicated pci device
- * @dev: pci device for which to set up EEH
+ * eeh_add_device_early - enable EEH for the indicated device_node
+ * @dn: device node for which to set up EEH
  *
- * This routine can be used to perform EEH initialization for PCI
+ * This routine must be used to perform EEH initialization for PCI
  * devices that were added after system boot (e.g. hotplug, dlpar).
+ * This routine must be called before any i/o is performed to the
+ * adapter (inluding any config-space i/o).
  * Whether this actually enables EEH or not for this device depends
- * on the type of the device, on earlier boot command-line
- * arguments & etc.
+ * on the CEC architecture, type of the device, on earlier boot
+ * command-line arguments & etc.
  */
-void eeh_add_device(struct pci_dev *dev)
+void eeh_add_device_early(struct device_node *dn)
 {
-	struct device_node *dn;
 	struct pci_controller *phb;
 	struct eeh_early_enable_info info;
 
-	if (!dev || !eeh_subsystem_enabled)
-		return;
-
-#ifdef DEBUG
-	printk(KERN_DEBUG "EEH: adding device %s %s\n", pci_name(dev),
-	       pci_pretty_name(dev));
-#endif
-	dn = pci_device_to_OF_node(dev);
-	if (NULL == dn)
+	if (!dn || !eeh_subsystem_enabled)
 		return;
-
-	phb = PCI_GET_PHB_PTR(dev);
+	phb = dn->phb;
 	if (NULL == phb || 0 == phb->buid) {
 		printk(KERN_WARNING "EEH: Expected buid but found none\n");
 		return;
@@ -646,11 +638,30 @@ void eeh_add_device(struct pci_dev *dev)
 
 	info.buid_hi = BUID_HI(phb->buid);
 	info.buid_lo = BUID_LO(phb->buid);
-
 	early_enable_eeh(dn, &info);
+}
+EXPORT_SYMBOL(eeh_add_device_early);
+
+/**
+ * eeh_add_device_late - perform EEH initialization for the indicated pci device
+ * @dev: pci device for which to set up EEH
+ *
+ * This routine must be used to complete EEH initialization for PCI
+ * devices that were added after system boot (e.g. hotplug, dlpar).
+ */
+void eeh_add_device_late(struct pci_dev *dev)
+{
+	if (!dev || !eeh_subsystem_enabled)
+		return;
+
+#ifdef DEBUG
+	printk(KERN_DEBUG "EEH: adding device %s %s\n", pci_name(dev),
+	       pci_pretty_name(dev));
+#endif
+
 	pci_addr_cache_insert_device (dev);
 }
-EXPORT_SYMBOL(eeh_add_device);
+EXPORT_SYMBOL(eeh_add_device_late);
 
 /**
  * eeh_remove_device - undo EEH setup for the indicated pci device
diff -puN include/asm-ppc64/eeh.h~ppc64-add-eeh_add_device_early-late include/asm-ppc64/eeh.h
--- 25/include/asm-ppc64/eeh.h~ppc64-add-eeh_add_device_early-late	2004-05-31 17:04:16.164814656 -0700
+++ 25-akpm/include/asm-ppc64/eeh.h	2004-05-31 17:04:16.169813896 -0700
@@ -47,16 +47,16 @@ void *eeh_ioremap(unsigned long addr, vo
 void __init pci_addr_cache_build(void);
 
 /**
- * eeh_add_device - perform EEH initialization for the indicated pci device
- * @dev: pci device for which to set up EEH
+ * eeh_add_device_early
+ * eeh_add_device_late
  *
- * This routine can be used to perform EEH initialization for PCI
- * devices that were added after system boot (e.g. hotplug, dlpar).
- * Whether this actually enables EEH or not for this device depends
- * on the type of the device, on earlier boot command-line
- * arguments & etc.
+ * Perform eeh initialization for devices added after boot.
+ * Call eeh_add_device_early before doing any i/o to the
+ * device (including config space i/o).  Call eeh_add_device_late
+ * to finish the eeh setup for this device.
  */
-void eeh_add_device(struct pci_dev *);
+void eeh_add_device_early(struct device_node *);
+void eeh_add_device_late(struct pci_dev *);
 
 /**
  * eeh_remove_device - undo EEH setup for the indicated pci device
_
