X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=inline;f=drivers%2Fpci%2Fhotplug%2Frpadlpar_core.c;h=72383467a0d5a5cbb9a60e0bdc4f04b0904f5172;hb=de69fee82c5962fb7bdaf6eb8a81302f418d1a1d;hp=7f504b380f2664a4030af967f3c086bd05853bc4;hpb=3c0c6441883be7676b795939e268b90d6acab360;p=powerpc.git diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 7f504b380f..72383467a0 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ #include "rpaphp.h" #include "rpadlpar.h" -static DECLARE_MUTEX(rpadlpar_sem); +static DEFINE_MUTEX(rpadlpar_mutex); #define DLPAR_MODULE_NAME "rpadlpar_io" @@ -63,7 +63,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name, char *type; int rc; - while ((np = of_find_node_by_type(np, "pci"))) { + while ((np = of_find_node_by_name(np, "pci"))) { rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); if (rc == 0) if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) @@ -103,13 +103,13 @@ static struct slot *find_slot(struct device_node *dn) struct list_head *tmp, *n; struct slot *slot; - list_for_each_safe(tmp, n, &rpaphp_slot_head) { - slot = list_entry(tmp, struct slot, rpaphp_slot_list); - if (slot->dn == dn) - return slot; - } + list_for_each_safe(tmp, n, &rpaphp_slot_head) { + slot = list_entry(tmp, struct slot, rpaphp_slot_list); + if (slot->dn == dn) + return slot; + } - return NULL; + return NULL; } static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, @@ -126,9 +126,9 @@ static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, return NULL; } -static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) +static void dlpar_pci_add_bus(struct device_node *dn) { - struct pci_dn *pdn = dn->data; + struct pci_dn *pdn = PCI_DN(dn); struct pci_controller *phb = pdn->phb; struct pci_dev *dev = NULL; @@ -139,14 +139,14 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) if (!dev) { printk(KERN_ERR "%s: failed to create pci dev for %s\n", __FUNCTION__, dn->full_name); - return NULL; + return; } if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) of_scan_pci_bridge(dn, dev); - rpaphp_init_new_devs(dev->subordinate); + pcibios_fixup_new_pci_devices(dev->subordinate,0); /* Claim new bus resources */ pcibios_claim_one_bus(dev->bus); @@ -156,35 +156,35 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) /* Add new devices to global lists. Register in proc, sysfs. */ pci_bus_add_devices(phb->bus); - - /* Confirm new bridge dev was created */ - dev = dlpar_find_new_dev(phb->bus, dn); - if (dev) { - if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { - printk(KERN_ERR "%s: unexpected header type %d\n", - __FUNCTION__, dev->hdr_type); - return NULL; - } - } - - return dev; } static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) { struct pci_dev *dev; + struct pci_controller *phb; - if (rpaphp_find_pci_bus(dn)) + if (pcibios_find_pci_bus(dn)) return -EINVAL; /* Add pci bus */ - dev = dlpar_pci_add_bus(dn); + dlpar_pci_add_bus(dn); + + /* Confirm new bridge dev was created */ + phb = PCI_DN(dn)->phb; + dev = dlpar_find_new_dev(phb->bus, dn); + if (!dev) { printk(KERN_ERR "%s: unable to add bus %s\n", __FUNCTION__, drc_name); return -EIO; } + if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { + printk(KERN_ERR "%s: unexpected header type %d, unable to add bus %s\n", + __FUNCTION__, dev->hdr_type, drc_name); + return -EIO; + } + /* Add hotplug slot */ if (rpaphp_add_slot(dn)) { printk(KERN_ERR "%s: unable to add hotplug slot %s\n", @@ -221,13 +221,13 @@ static int dlpar_remove_phb(char *drc_name, struct device_node *dn) struct pci_dn *pdn; int rc = 0; - if (!rpaphp_find_pci_bus(dn)) + if (!pcibios_find_pci_bus(dn)) return -EINVAL; slot = find_slot(dn); if (slot) { /* Remove hotplug slot */ - if (rpaphp_remove_slot(slot)) { + if (rpaphp_deregister_slot(slot)) { printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", __FUNCTION__, drc_name); @@ -300,7 +300,7 @@ int dlpar_add_slot(char *drc_name) int node_type; int rc = -EIO; - if (down_interruptible(&rpadlpar_sem)) + if (mutex_lock_interruptible(&rpadlpar_mutex)) return -ERESTARTSYS; /* Find newly added node */ @@ -324,7 +324,7 @@ int dlpar_add_slot(char *drc_name) printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name); exit: - up(&rpadlpar_sem); + mutex_unlock(&rpadlpar_mutex); return rc; } @@ -366,21 +366,25 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) struct pci_bus *bus; struct slot *slot; - bus = rpaphp_find_pci_bus(dn); + bus = pcibios_find_pci_bus(dn); if (!bus) return -EINVAL; slot = find_slot(dn); if (slot) { /* Remove hotplug slot */ - if (rpaphp_remove_slot(slot)) { + if (rpaphp_deregister_slot(slot)) { printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", __FUNCTION__, drc_name); return -EIO; } } else { - rpaphp_unconfig_pci_adapter(bus); + struct pci_dev *dev, *tmp; + list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { + eeh_remove_bus_device(dev); + pci_remove_bus_device(dev); + } } if (unmap_bus_range(bus)) { @@ -413,7 +417,7 @@ int dlpar_remove_slot(char *drc_name) int node_type; int rc = 0; - if (down_interruptible(&rpadlpar_sem)) + if (mutex_lock_interruptible(&rpadlpar_mutex)) return -ERESTARTSYS; dn = find_dlpar_node(drc_name, &node_type); @@ -435,7 +439,7 @@ int dlpar_remove_slot(char *drc_name) } printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); exit: - up(&rpadlpar_sem); + mutex_unlock(&rpadlpar_mutex); return rc; }