powerpc/pci: Delay populating pdn
[cascardo/linux.git] / arch / powerpc / kernel / pci_dn.c
index ecdccce..bfe60a1 100644 (file)
@@ -181,7 +181,9 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev)
 {
 #ifdef CONFIG_PCI_IOV
        struct pci_dn *parent, *pdn;
+#ifdef CONFIG_EEH
        struct eeh_dev *edev;
+#endif /* CONFIG_EEH */
        int i;
 
        /* Only support IOV for now */
@@ -208,11 +210,12 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev)
                        return NULL;
                }
 
+#ifdef CONFIG_EEH
                /* Create the EEH device for the VF */
-               eeh_dev_init(pdn, pci_bus_to_host(pdev->bus));
-               edev = pdn_to_eeh_dev(pdn);
+               edev = eeh_dev_init(pdn);
                BUG_ON(!edev);
                edev->physfn = pdev;
+#endif /* CONFIG_EEH */
        }
 #endif /* CONFIG_PCI_IOV */
 
@@ -266,12 +269,14 @@ void remove_dev_pci_data(struct pci_dev *pdev)
                            pdn->devfn != pci_iov_virtfn_devfn(pdev, i))
                                continue;
 
+#ifdef CONFIG_EEH
                        /* Release EEH device for the VF */
                        edev = pdn_to_eeh_dev(pdn);
                        if (edev) {
                                pdn->edev = NULL;
                                kfree(edev);
                        }
+#endif /* CONFIG_EEH */
 
                        if (!list_empty(&pdn->list))
                                list_del(&pdn->list);
@@ -289,8 +294,11 @@ struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
        const __be32 *regs;
        struct device_node *parent;
        struct pci_dn *pdn;
+#ifdef CONFIG_EEH
+       struct eeh_dev *edev;
+#endif
 
-       pdn = zalloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
+       pdn = kzalloc(sizeof(*pdn), GFP_KERNEL);
        if (pdn == NULL)
                return NULL;
        dn->data = pdn;
@@ -319,6 +327,15 @@ struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
        /* Extended config space */
        pdn->pci_ext_config_space = (type && of_read_number(type, 1) == 1);
 
+       /* Create EEH device */
+#ifdef CONFIG_EEH
+       edev = eeh_dev_init(pdn);
+       if (!edev) {
+               kfree(pdn);
+               return NULL;
+       }
+#endif
+
        /* Attach to parent node */
        INIT_LIST_HEAD(&pdn->child_list);
        INIT_LIST_HEAD(&pdn->list);
@@ -504,15 +521,19 @@ void pci_devs_phb_init_dynamic(struct pci_controller *phb)
  * pci device found underneath.  This routine runs once,
  * early in the boot sequence.
  */
-void __init pci_devs_phb_init(void)
+static int __init pci_devs_phb_init(void)
 {
        struct pci_controller *phb, *tmp;
 
        /* This must be done first so the device nodes have valid pci info! */
        list_for_each_entry_safe(phb, tmp, &hose_list, list_node)
                pci_devs_phb_init_dynamic(phb);
+
+       return 0;
 }
 
+core_initcall(pci_devs_phb_init);
+
 static void pci_dev_pdn_setup(struct pci_dev *pdev)
 {
        struct pci_dn *pdn;