aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/rpadlpar_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/rpadlpar_core.c')
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 7d93dbaf628d..3eefe2cec72d 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -103,13 +103,13 @@ static struct slot *find_slot(struct device_node *dn)
103 struct list_head *tmp, *n; 103 struct list_head *tmp, *n;
104 struct slot *slot; 104 struct slot *slot;
105 105
106 list_for_each_safe(tmp, n, &rpaphp_slot_head) { 106 list_for_each_safe(tmp, n, &rpaphp_slot_head) {
107 slot = list_entry(tmp, struct slot, rpaphp_slot_list); 107 slot = list_entry(tmp, struct slot, rpaphp_slot_list);
108 if (slot->dn == dn) 108 if (slot->dn == dn)
109 return slot; 109 return slot;
110 } 110 }
111 111
112 return NULL; 112 return NULL;
113} 113}
114 114
115static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, 115static 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,
126 return NULL; 126 return NULL;
127} 127}
128 128
129static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) 129static void dlpar_pci_add_bus(struct device_node *dn)
130{ 130{
131 struct pci_dn *pdn = dn->data; 131 struct pci_dn *pdn = PCI_DN(dn);
132 struct pci_controller *phb = pdn->phb; 132 struct pci_controller *phb = pdn->phb;
133 struct pci_dev *dev = NULL; 133 struct pci_dev *dev = NULL;
134 134
@@ -139,52 +139,52 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
139 if (!dev) { 139 if (!dev) {
140 printk(KERN_ERR "%s: failed to create pci dev for %s\n", 140 printk(KERN_ERR "%s: failed to create pci dev for %s\n",
141 __FUNCTION__, dn->full_name); 141 __FUNCTION__, dn->full_name);
142 return NULL; 142 return;
143 } 143 }
144 144
145 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 145 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
146 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 146 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
147 of_scan_pci_bridge(dn, dev); 147 of_scan_pci_bridge(dn, dev);
148 148
149 rpaphp_init_new_devs(dev->subordinate); 149 pcibios_fixup_new_pci_devices(dev->subordinate,0);
150 150
151 /* Claim new bus resources */ 151 /* Claim new bus resources */
152 pcibios_claim_one_bus(dev->bus); 152 pcibios_claim_one_bus(dev->bus);
153 153
154 /* ioremap() for child bus, which may or may not succeed */ 154 /* ioremap() for child bus, which may or may not succeed */
155 (void) remap_bus_range(dev->bus); 155 remap_bus_range(dev->subordinate);
156 156
157 /* Add new devices to global lists. Register in proc, sysfs. */ 157 /* Add new devices to global lists. Register in proc, sysfs. */
158 pci_bus_add_devices(phb->bus); 158 pci_bus_add_devices(phb->bus);
159
160 /* Confirm new bridge dev was created */
161 dev = dlpar_find_new_dev(phb->bus, dn);
162 if (dev) {
163 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
164 printk(KERN_ERR "%s: unexpected header type %d\n",
165 __FUNCTION__, dev->hdr_type);
166 return NULL;
167 }
168 }
169
170 return dev;
171} 159}
172 160
173static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) 161static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
174{ 162{
175 struct pci_dev *dev; 163 struct pci_dev *dev;
164 struct pci_controller *phb;
176 165
177 if (rpaphp_find_pci_bus(dn)) 166 if (pcibios_find_pci_bus(dn))
178 return -EINVAL; 167 return -EINVAL;
179 168
180 /* Add pci bus */ 169 /* Add pci bus */
181 dev = dlpar_pci_add_bus(dn); 170 dlpar_pci_add_bus(dn);
171
172 /* Confirm new bridge dev was created */
173 phb = PCI_DN(dn)->phb;
174 dev = dlpar_find_new_dev(phb->bus, dn);
175
182 if (!dev) { 176 if (!dev) {
183 printk(KERN_ERR "%s: unable to add bus %s\n", __FUNCTION__, 177 printk(KERN_ERR "%s: unable to add bus %s\n", __FUNCTION__,
184 drc_name); 178 drc_name);
185 return -EIO; 179 return -EIO;
186 } 180 }
187 181
182 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
183 printk(KERN_ERR "%s: unexpected header type %d, unable to add bus %s\n",
184 __FUNCTION__, dev->hdr_type, drc_name);
185 return -EIO;
186 }
187
188 /* Add hotplug slot */ 188 /* Add hotplug slot */
189 if (rpaphp_add_slot(dn)) { 189 if (rpaphp_add_slot(dn)) {
190 printk(KERN_ERR "%s: unable to add hotplug slot %s\n", 190 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)
221 struct pci_dn *pdn; 221 struct pci_dn *pdn;
222 int rc = 0; 222 int rc = 0;
223 223
224 if (!rpaphp_find_pci_bus(dn)) 224 if (!pcibios_find_pci_bus(dn))
225 return -EINVAL; 225 return -EINVAL;
226 226
227 slot = find_slot(dn); 227 slot = find_slot(dn);
228 if (slot) { 228 if (slot) {
229 /* Remove hotplug slot */ 229 /* Remove hotplug slot */
230 if (rpaphp_remove_slot(slot)) { 230 if (rpaphp_deregister_slot(slot)) {
231 printk(KERN_ERR 231 printk(KERN_ERR
232 "%s: unable to remove hotplug slot %s\n", 232 "%s: unable to remove hotplug slot %s\n",
233 __FUNCTION__, drc_name); 233 __FUNCTION__, drc_name);
@@ -366,21 +366,25 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
366 struct pci_bus *bus; 366 struct pci_bus *bus;
367 struct slot *slot; 367 struct slot *slot;
368 368
369 bus = rpaphp_find_pci_bus(dn); 369 bus = pcibios_find_pci_bus(dn);
370 if (!bus) 370 if (!bus)
371 return -EINVAL; 371 return -EINVAL;
372 372
373 slot = find_slot(dn); 373 slot = find_slot(dn);
374 if (slot) { 374 if (slot) {
375 /* Remove hotplug slot */ 375 /* Remove hotplug slot */
376 if (rpaphp_remove_slot(slot)) { 376 if (rpaphp_deregister_slot(slot)) {
377 printk(KERN_ERR 377 printk(KERN_ERR
378 "%s: unable to remove hotplug slot %s\n", 378 "%s: unable to remove hotplug slot %s\n",
379 __FUNCTION__, drc_name); 379 __FUNCTION__, drc_name);
380 return -EIO; 380 return -EIO;
381 } 381 }
382 } else { 382 } else {
383 rpaphp_unconfig_pci_adapter(bus); 383 struct pci_dev *dev, *tmp;
384 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
385 eeh_remove_bus_device(dev);
386 pci_remove_bus_device(dev);
387 }
384 } 388 }
385 389
386 if (unmap_bus_range(bus)) { 390 if (unmap_bus_range(bus)) {