aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/pseries/eeh_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/platforms/pseries/eeh_driver.c')
-rw-r--r--arch/powerpc/platforms/pseries/eeh_driver.c310
1 files changed, 162 insertions, 148 deletions
diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c
index baf92cd9dfab..a3fefb61097c 100644
--- a/arch/powerpc/platforms/pseries/eeh_driver.c
+++ b/arch/powerpc/platforms/pseries/eeh_driver.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/irq.h> 27#include <linux/irq.h>
28#include <linux/module.h>
28#include <linux/pci.h> 29#include <linux/pci.h>
29#include <asm/eeh.h> 30#include <asm/eeh.h>
30#include <asm/eeh_event.h> 31#include <asm/eeh_event.h>
@@ -47,6 +48,41 @@ static inline const char *eeh_pcid_name(struct pci_dev *pdev)
47 return ""; 48 return "";
48} 49}
49 50
51/**
52 * eeh_pcid_get - Get the PCI device driver
53 * @pdev: PCI device
54 *
55 * The function is used to retrieve the PCI device driver for
56 * the indicated PCI device. Besides, we will increase the reference
57 * of the PCI device driver to prevent that being unloaded on
58 * the fly. Otherwise, kernel crash would be seen.
59 */
60static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev)
61{
62 if (!pdev || !pdev->driver)
63 return NULL;
64
65 if (!try_module_get(pdev->driver->driver.owner))
66 return NULL;
67
68 return pdev->driver;
69}
70
71/**
72 * eeh_pcid_put - Dereference on the PCI device driver
73 * @pdev: PCI device
74 *
75 * The function is called to do dereference on the PCI device
76 * driver of the indicated PCI device.
77 */
78static inline void eeh_pcid_put(struct pci_dev *pdev)
79{
80 if (!pdev || !pdev->driver)
81 return;
82
83 module_put(pdev->driver->driver.owner);
84}
85
50#if 0 86#if 0
51static void print_device_node_tree(struct pci_dn *pdn, int dent) 87static void print_device_node_tree(struct pci_dn *pdn, int dent)
52{ 88{
@@ -93,7 +129,7 @@ static void eeh_disable_irq(struct pci_dev *dev)
93 if (!irq_has_action(dev->irq)) 129 if (!irq_has_action(dev->irq))
94 return; 130 return;
95 131
96 edev->mode |= EEH_MODE_IRQ_DISABLED; 132 edev->mode |= EEH_DEV_IRQ_DISABLED;
97 disable_irq_nosync(dev->irq); 133 disable_irq_nosync(dev->irq);
98} 134}
99 135
@@ -108,36 +144,44 @@ static void eeh_enable_irq(struct pci_dev *dev)
108{ 144{
109 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); 145 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
110 146
111 if ((edev->mode) & EEH_MODE_IRQ_DISABLED) { 147 if ((edev->mode) & EEH_DEV_IRQ_DISABLED) {
112 edev->mode &= ~EEH_MODE_IRQ_DISABLED; 148 edev->mode &= ~EEH_DEV_IRQ_DISABLED;
113 enable_irq(dev->irq); 149 enable_irq(dev->irq);
114 } 150 }
115} 151}
116 152
117/** 153/**
118 * eeh_report_error - Report pci error to each device driver 154 * eeh_report_error - Report pci error to each device driver
119 * @dev: PCI device 155 * @data: eeh device
120 * @userdata: return value 156 * @userdata: return value
121 * 157 *
122 * Report an EEH error to each device driver, collect up and 158 * Report an EEH error to each device driver, collect up and
123 * merge the device driver responses. Cumulative response 159 * merge the device driver responses. Cumulative response
124 * passed back in "userdata". 160 * passed back in "userdata".
125 */ 161 */
126static int eeh_report_error(struct pci_dev *dev, void *userdata) 162static void *eeh_report_error(void *data, void *userdata)
127{ 163{
164 struct eeh_dev *edev = (struct eeh_dev *)data;
165 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
128 enum pci_ers_result rc, *res = userdata; 166 enum pci_ers_result rc, *res = userdata;
129 struct pci_driver *driver = dev->driver; 167 struct pci_driver *driver;
130 168
169 /* We might not have the associated PCI device,
170 * then we should continue for next one.
171 */
172 if (!dev) return NULL;
131 dev->error_state = pci_channel_io_frozen; 173 dev->error_state = pci_channel_io_frozen;
132 174
133 if (!driver) 175 driver = eeh_pcid_get(dev);
134 return 0; 176 if (!driver) return NULL;
135 177
136 eeh_disable_irq(dev); 178 eeh_disable_irq(dev);
137 179
138 if (!driver->err_handler || 180 if (!driver->err_handler ||
139 !driver->err_handler->error_detected) 181 !driver->err_handler->error_detected) {
140 return 0; 182 eeh_pcid_put(dev);
183 return NULL;
184 }
141 185
142 rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen); 186 rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen);
143 187
@@ -145,27 +189,34 @@ static int eeh_report_error(struct pci_dev *dev, void *userdata)
145 if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; 189 if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
146 if (*res == PCI_ERS_RESULT_NONE) *res = rc; 190 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
147 191
148 return 0; 192 eeh_pcid_put(dev);
193 return NULL;
149} 194}
150 195
151/** 196/**
152 * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled 197 * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled
153 * @dev: PCI device 198 * @data: eeh device
154 * @userdata: return value 199 * @userdata: return value
155 * 200 *
156 * Tells each device driver that IO ports, MMIO and config space I/O 201 * Tells each device driver that IO ports, MMIO and config space I/O
157 * are now enabled. Collects up and merges the device driver responses. 202 * are now enabled. Collects up and merges the device driver responses.
158 * Cumulative response passed back in "userdata". 203 * Cumulative response passed back in "userdata".
159 */ 204 */
160static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) 205static void *eeh_report_mmio_enabled(void *data, void *userdata)
161{ 206{
207 struct eeh_dev *edev = (struct eeh_dev *)data;
208 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
162 enum pci_ers_result rc, *res = userdata; 209 enum pci_ers_result rc, *res = userdata;
163 struct pci_driver *driver = dev->driver; 210 struct pci_driver *driver;
164 211
165 if (!driver || 212 driver = eeh_pcid_get(dev);
166 !driver->err_handler || 213 if (!driver) return NULL;
167 !driver->err_handler->mmio_enabled) 214
168 return 0; 215 if (!driver->err_handler ||
216 !driver->err_handler->mmio_enabled) {
217 eeh_pcid_put(dev);
218 return NULL;
219 }
169 220
170 rc = driver->err_handler->mmio_enabled(dev); 221 rc = driver->err_handler->mmio_enabled(dev);
171 222
@@ -173,12 +224,13 @@ static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata)
173 if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; 224 if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
174 if (*res == PCI_ERS_RESULT_NONE) *res = rc; 225 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
175 226
176 return 0; 227 eeh_pcid_put(dev);
228 return NULL;
177} 229}
178 230
179/** 231/**
180 * eeh_report_reset - Tell device that slot has been reset 232 * eeh_report_reset - Tell device that slot has been reset
181 * @dev: PCI device 233 * @data: eeh device
182 * @userdata: return value 234 * @userdata: return value
183 * 235 *
184 * This routine must be called while EEH tries to reset particular 236 * This routine must be called while EEH tries to reset particular
@@ -186,21 +238,26 @@ static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata)
186 * some actions, usually to save data the driver needs so that the 238 * some actions, usually to save data the driver needs so that the
187 * driver can work again while the device is recovered. 239 * driver can work again while the device is recovered.
188 */ 240 */
189static int eeh_report_reset(struct pci_dev *dev, void *userdata) 241static void *eeh_report_reset(void *data, void *userdata)
190{ 242{
243 struct eeh_dev *edev = (struct eeh_dev *)data;
244 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
191 enum pci_ers_result rc, *res = userdata; 245 enum pci_ers_result rc, *res = userdata;
192 struct pci_driver *driver = dev->driver; 246 struct pci_driver *driver;
193
194 if (!driver)
195 return 0;
196 247
248 if (!dev) return NULL;
197 dev->error_state = pci_channel_io_normal; 249 dev->error_state = pci_channel_io_normal;
198 250
251 driver = eeh_pcid_get(dev);
252 if (!driver) return NULL;
253
199 eeh_enable_irq(dev); 254 eeh_enable_irq(dev);
200 255
201 if (!driver->err_handler || 256 if (!driver->err_handler ||
202 !driver->err_handler->slot_reset) 257 !driver->err_handler->slot_reset) {
203 return 0; 258 eeh_pcid_put(dev);
259 return NULL;
260 }
204 261
205 rc = driver->err_handler->slot_reset(dev); 262 rc = driver->err_handler->slot_reset(dev);
206 if ((*res == PCI_ERS_RESULT_NONE) || 263 if ((*res == PCI_ERS_RESULT_NONE) ||
@@ -208,109 +265,115 @@ static int eeh_report_reset(struct pci_dev *dev, void *userdata)
208 if (*res == PCI_ERS_RESULT_DISCONNECT && 265 if (*res == PCI_ERS_RESULT_DISCONNECT &&
209 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; 266 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
210 267
211 return 0; 268 eeh_pcid_put(dev);
269 return NULL;
212} 270}
213 271
214/** 272/**
215 * eeh_report_resume - Tell device to resume normal operations 273 * eeh_report_resume - Tell device to resume normal operations
216 * @dev: PCI device 274 * @data: eeh device
217 * @userdata: return value 275 * @userdata: return value
218 * 276 *
219 * This routine must be called to notify the device driver that it 277 * This routine must be called to notify the device driver that it
220 * could resume so that the device driver can do some initialization 278 * could resume so that the device driver can do some initialization
221 * to make the recovered device work again. 279 * to make the recovered device work again.
222 */ 280 */
223static int eeh_report_resume(struct pci_dev *dev, void *userdata) 281static void *eeh_report_resume(void *data, void *userdata)
224{ 282{
225 struct pci_driver *driver = dev->driver; 283 struct eeh_dev *edev = (struct eeh_dev *)data;
284 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
285 struct pci_driver *driver;
226 286
287 if (!dev) return NULL;
227 dev->error_state = pci_channel_io_normal; 288 dev->error_state = pci_channel_io_normal;
228 289
229 if (!driver) 290 driver = eeh_pcid_get(dev);
230 return 0; 291 if (!driver) return NULL;
231 292
232 eeh_enable_irq(dev); 293 eeh_enable_irq(dev);
233 294
234 if (!driver->err_handler || 295 if (!driver->err_handler ||
235 !driver->err_handler->resume) 296 !driver->err_handler->resume) {
236 return 0; 297 eeh_pcid_put(dev);
298 return NULL;
299 }
237 300
238 driver->err_handler->resume(dev); 301 driver->err_handler->resume(dev);
239 302
240 return 0; 303 eeh_pcid_put(dev);
304 return NULL;
241} 305}
242 306
243/** 307/**
244 * eeh_report_failure - Tell device driver that device is dead. 308 * eeh_report_failure - Tell device driver that device is dead.
245 * @dev: PCI device 309 * @data: eeh device
246 * @userdata: return value 310 * @userdata: return value
247 * 311 *
248 * This informs the device driver that the device is permanently 312 * This informs the device driver that the device is permanently
249 * dead, and that no further recovery attempts will be made on it. 313 * dead, and that no further recovery attempts will be made on it.
250 */ 314 */
251static int eeh_report_failure(struct pci_dev *dev, void *userdata) 315static void *eeh_report_failure(void *data, void *userdata)
252{ 316{
253 struct pci_driver *driver = dev->driver; 317 struct eeh_dev *edev = (struct eeh_dev *)data;
318 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
319 struct pci_driver *driver;
254 320
321 if (!dev) return NULL;
255 dev->error_state = pci_channel_io_perm_failure; 322 dev->error_state = pci_channel_io_perm_failure;
256 323
257 if (!driver) 324 driver = eeh_pcid_get(dev);
258 return 0; 325 if (!driver) return NULL;
259 326
260 eeh_disable_irq(dev); 327 eeh_disable_irq(dev);
261 328
262 if (!driver->err_handler || 329 if (!driver->err_handler ||
263 !driver->err_handler->error_detected) 330 !driver->err_handler->error_detected) {
264 return 0; 331 eeh_pcid_put(dev);
332 return NULL;
333 }
265 334
266 driver->err_handler->error_detected(dev, pci_channel_io_perm_failure); 335 driver->err_handler->error_detected(dev, pci_channel_io_perm_failure);
267 336
268 return 0; 337 eeh_pcid_put(dev);
338 return NULL;
269} 339}
270 340
271/** 341/**
272 * eeh_reset_device - Perform actual reset of a pci slot 342 * eeh_reset_device - Perform actual reset of a pci slot
273 * @edev: PE associated EEH device 343 * @pe: EEH PE
274 * @bus: PCI bus corresponding to the isolcated slot 344 * @bus: PCI bus corresponding to the isolcated slot
275 * 345 *
276 * This routine must be called to do reset on the indicated PE. 346 * This routine must be called to do reset on the indicated PE.
277 * During the reset, udev might be invoked because those affected 347 * During the reset, udev might be invoked because those affected
278 * PCI devices will be removed and then added. 348 * PCI devices will be removed and then added.
279 */ 349 */
280static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) 350static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
281{ 351{
282 struct device_node *dn;
283 int cnt, rc; 352 int cnt, rc;
284 353
285 /* pcibios will clear the counter; save the value */ 354 /* pcibios will clear the counter; save the value */
286 cnt = edev->freeze_count; 355 cnt = pe->freeze_count;
287 356
357 /*
358 * We don't remove the corresponding PE instances because
359 * we need the information afterwords. The attached EEH
360 * devices are expected to be attached soon when calling
361 * into pcibios_add_pci_devices().
362 */
288 if (bus) 363 if (bus)
289 pcibios_remove_pci_devices(bus); 364 __pcibios_remove_pci_devices(bus, 0);
290 365
291 /* Reset the pci controller. (Asserts RST#; resets config space). 366 /* Reset the pci controller. (Asserts RST#; resets config space).
292 * Reconfigure bridges and devices. Don't try to bring the system 367 * Reconfigure bridges and devices. Don't try to bring the system
293 * up if the reset failed for some reason. 368 * up if the reset failed for some reason.
294 */ 369 */
295 rc = eeh_reset_pe(edev); 370 rc = eeh_reset_pe(pe);
296 if (rc) 371 if (rc)
297 return rc; 372 return rc;
298 373
299 /* Walk over all functions on this device. */ 374 /* Restore PE */
300 dn = eeh_dev_to_of_node(edev); 375 eeh_ops->configure_bridge(pe);
301 if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent)) 376 eeh_pe_restore_bars(pe);
302 dn = dn->parent->child;
303
304 while (dn) {
305 struct eeh_dev *pedev = of_node_to_eeh_dev(dn);
306
307 /* On Power4, always true because eeh_pe_config_addr=0 */
308 if (edev->pe_config_addr == pedev->pe_config_addr) {
309 eeh_ops->configure_bridge(dn);
310 eeh_restore_bars(pedev);
311 }
312 dn = dn->sibling;
313 }
314 377
315 /* Give the system 5 seconds to finish running the user-space 378 /* Give the system 5 seconds to finish running the user-space
316 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, 379 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
@@ -322,7 +385,7 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus)
322 ssleep(5); 385 ssleep(5);
323 pcibios_add_pci_devices(bus); 386 pcibios_add_pci_devices(bus);
324 } 387 }
325 edev->freeze_count = cnt; 388 pe->freeze_count = cnt;
326 389
327 return 0; 390 return 0;
328} 391}
@@ -334,7 +397,7 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus)
334 397
335/** 398/**
336 * eeh_handle_event - Reset a PCI device after hard lockup. 399 * eeh_handle_event - Reset a PCI device after hard lockup.
337 * @event: EEH event 400 * @pe: EEH PE
338 * 401 *
339 * While PHB detects address or data parity errors on particular PCI 402 * While PHB detects address or data parity errors on particular PCI
340 * slot, the associated PE will be frozen. Besides, DMA's occurring 403 * slot, the associated PE will be frozen. Besides, DMA's occurring
@@ -349,69 +412,24 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus)
349 * drivers (which cause a second set of hotplug events to go out to 412 * drivers (which cause a second set of hotplug events to go out to
350 * userspace). 413 * userspace).
351 */ 414 */
352struct eeh_dev *handle_eeh_events(struct eeh_event *event) 415void eeh_handle_event(struct eeh_pe *pe)
353{ 416{
354 struct device_node *frozen_dn;
355 struct eeh_dev *frozen_edev;
356 struct pci_bus *frozen_bus; 417 struct pci_bus *frozen_bus;
357 int rc = 0; 418 int rc = 0;
358 enum pci_ers_result result = PCI_ERS_RESULT_NONE; 419 enum pci_ers_result result = PCI_ERS_RESULT_NONE;
359 const char *location, *pci_str, *drv_str, *bus_pci_str, *bus_drv_str;
360
361 frozen_dn = eeh_find_device_pe(eeh_dev_to_of_node(event->edev));
362 if (!frozen_dn) {
363 location = of_get_property(eeh_dev_to_of_node(event->edev), "ibm,loc-code", NULL);
364 location = location ? location : "unknown";
365 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint "
366 "for location=%s pci addr=%s\n",
367 location, eeh_pci_name(eeh_dev_to_pci_dev(event->edev)));
368 return NULL;
369 }
370
371 frozen_bus = pcibios_find_pci_bus(frozen_dn);
372 location = of_get_property(frozen_dn, "ibm,loc-code", NULL);
373 location = location ? location : "unknown";
374
375 /* There are two different styles for coming up with the PE.
376 * In the old style, it was the highest EEH-capable device
377 * which was always an EADS pci bridge. In the new style,
378 * there might not be any EADS bridges, and even when there are,
379 * the firmware marks them as "EEH incapable". So another
380 * two-step is needed to find the pci bus..
381 */
382 if (!frozen_bus)
383 frozen_bus = pcibios_find_pci_bus(frozen_dn->parent);
384 420
421 frozen_bus = eeh_pe_bus_get(pe);
385 if (!frozen_bus) { 422 if (!frozen_bus) {
386 printk(KERN_ERR "EEH: Cannot find PCI bus " 423 pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n",
387 "for location=%s dn=%s\n", 424 __func__, pe->phb->global_number, pe->addr);
388 location, frozen_dn->full_name); 425 return;
389 return NULL;
390 } 426 }
391 427
392 frozen_edev = of_node_to_eeh_dev(frozen_dn); 428 pe->freeze_count++;
393 frozen_edev->freeze_count++; 429 if (pe->freeze_count > EEH_MAX_ALLOWED_FREEZES)
394 pci_str = eeh_pci_name(eeh_dev_to_pci_dev(event->edev));
395 drv_str = eeh_pcid_name(eeh_dev_to_pci_dev(event->edev));
396
397 if (frozen_edev->freeze_count > EEH_MAX_ALLOWED_FREEZES)
398 goto excess_failures; 430 goto excess_failures;
399 431 pr_warning("EEH: This PCI device has failed %d times in the last hour\n",
400 printk(KERN_WARNING 432 pe->freeze_count);
401 "EEH: This PCI device has failed %d times in the last hour:\n",
402 frozen_edev->freeze_count);
403
404 if (frozen_edev->pdev) {
405 bus_pci_str = pci_name(frozen_edev->pdev);
406 bus_drv_str = eeh_pcid_name(frozen_edev->pdev);
407 printk(KERN_WARNING
408 "EEH: Bus location=%s driver=%s pci addr=%s\n",
409 location, bus_drv_str, bus_pci_str);
410 }
411
412 printk(KERN_WARNING
413 "EEH: Device location=%s driver=%s pci addr=%s\n",
414 location, drv_str, pci_str);
415 433
416 /* Walk the various device drivers attached to this slot through 434 /* Walk the various device drivers attached to this slot through
417 * a reset sequence, giving each an opportunity to do what it needs 435 * a reset sequence, giving each an opportunity to do what it needs
@@ -419,12 +437,12 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event)
419 * status ... if any child can't handle the reset, then the entire 437 * status ... if any child can't handle the reset, then the entire
420 * slot is dlpar removed and added. 438 * slot is dlpar removed and added.
421 */ 439 */
422 pci_walk_bus(frozen_bus, eeh_report_error, &result); 440 eeh_pe_dev_traverse(pe, eeh_report_error, &result);
423 441
424 /* Get the current PCI slot state. This can take a long time, 442 /* Get the current PCI slot state. This can take a long time,
425 * sometimes over 3 seconds for certain systems. 443 * sometimes over 3 seconds for certain systems.
426 */ 444 */
427 rc = eeh_ops->wait_state(eeh_dev_to_of_node(frozen_edev), MAX_WAIT_FOR_RECOVERY*1000); 445 rc = eeh_ops->wait_state(pe, MAX_WAIT_FOR_RECOVERY*1000);
428 if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) { 446 if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) {
429 printk(KERN_WARNING "EEH: Permanent failure\n"); 447 printk(KERN_WARNING "EEH: Permanent failure\n");
430 goto hard_fail; 448 goto hard_fail;
@@ -434,14 +452,14 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event)
434 * don't post the error log until after all dev drivers 452 * don't post the error log until after all dev drivers
435 * have been informed. 453 * have been informed.
436 */ 454 */
437 eeh_slot_error_detail(frozen_edev, EEH_LOG_TEMP); 455 eeh_slot_error_detail(pe, EEH_LOG_TEMP);
438 456
439 /* If all device drivers were EEH-unaware, then shut 457 /* If all device drivers were EEH-unaware, then shut
440 * down all of the device drivers, and hope they 458 * down all of the device drivers, and hope they
441 * go down willingly, without panicing the system. 459 * go down willingly, without panicing the system.
442 */ 460 */
443 if (result == PCI_ERS_RESULT_NONE) { 461 if (result == PCI_ERS_RESULT_NONE) {
444 rc = eeh_reset_device(frozen_edev, frozen_bus); 462 rc = eeh_reset_device(pe, frozen_bus);
445 if (rc) { 463 if (rc) {
446 printk(KERN_WARNING "EEH: Unable to reset, rc=%d\n", rc); 464 printk(KERN_WARNING "EEH: Unable to reset, rc=%d\n", rc);
447 goto hard_fail; 465 goto hard_fail;
@@ -450,7 +468,7 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event)
450 468
451 /* If all devices reported they can proceed, then re-enable MMIO */ 469 /* If all devices reported they can proceed, then re-enable MMIO */
452 if (result == PCI_ERS_RESULT_CAN_RECOVER) { 470 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
453 rc = eeh_pci_enable(frozen_edev, EEH_OPT_THAW_MMIO); 471 rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO);
454 472
455 if (rc < 0) 473 if (rc < 0)
456 goto hard_fail; 474 goto hard_fail;
@@ -458,13 +476,13 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event)
458 result = PCI_ERS_RESULT_NEED_RESET; 476 result = PCI_ERS_RESULT_NEED_RESET;
459 } else { 477 } else {
460 result = PCI_ERS_RESULT_NONE; 478 result = PCI_ERS_RESULT_NONE;
461 pci_walk_bus(frozen_bus, eeh_report_mmio_enabled, &result); 479 eeh_pe_dev_traverse(pe, eeh_report_mmio_enabled, &result);
462 } 480 }
463 } 481 }
464 482
465 /* If all devices reported they can proceed, then re-enable DMA */ 483 /* If all devices reported they can proceed, then re-enable DMA */
466 if (result == PCI_ERS_RESULT_CAN_RECOVER) { 484 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
467 rc = eeh_pci_enable(frozen_edev, EEH_OPT_THAW_DMA); 485 rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA);
468 486
469 if (rc < 0) 487 if (rc < 0)
470 goto hard_fail; 488 goto hard_fail;
@@ -482,13 +500,13 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event)
482 500
483 /* If any device called out for a reset, then reset the slot */ 501 /* If any device called out for a reset, then reset the slot */
484 if (result == PCI_ERS_RESULT_NEED_RESET) { 502 if (result == PCI_ERS_RESULT_NEED_RESET) {
485 rc = eeh_reset_device(frozen_edev, NULL); 503 rc = eeh_reset_device(pe, NULL);
486 if (rc) { 504 if (rc) {
487 printk(KERN_WARNING "EEH: Cannot reset, rc=%d\n", rc); 505 printk(KERN_WARNING "EEH: Cannot reset, rc=%d\n", rc);
488 goto hard_fail; 506 goto hard_fail;
489 } 507 }
490 result = PCI_ERS_RESULT_NONE; 508 result = PCI_ERS_RESULT_NONE;
491 pci_walk_bus(frozen_bus, eeh_report_reset, &result); 509 eeh_pe_dev_traverse(pe, eeh_report_reset, &result);
492 } 510 }
493 511
494 /* All devices should claim they have recovered by now. */ 512 /* All devices should claim they have recovered by now. */
@@ -499,9 +517,9 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event)
499 } 517 }
500 518
501 /* Tell all device drivers that they can resume operations */ 519 /* Tell all device drivers that they can resume operations */
502 pci_walk_bus(frozen_bus, eeh_report_resume, NULL); 520 eeh_pe_dev_traverse(pe, eeh_report_resume, NULL);
503 521
504 return frozen_edev; 522 return;
505 523
506excess_failures: 524excess_failures:
507 /* 525 /*
@@ -509,30 +527,26 @@ excess_failures:
509 * are due to poorly seated PCI cards. Only 10% or so are 527 * are due to poorly seated PCI cards. Only 10% or so are
510 * due to actual, failed cards. 528 * due to actual, failed cards.
511 */ 529 */
512 printk(KERN_ERR 530 pr_err("EEH: PHB#%d-PE#%x has failed %d times in the\n"
513 "EEH: PCI device at location=%s driver=%s pci addr=%s\n" 531 "last hour and has been permanently disabled.\n"
514 "has failed %d times in the last hour " 532 "Please try reseating or replacing it.\n",
515 "and has been permanently disabled.\n" 533 pe->phb->global_number, pe->addr,
516 "Please try reseating this device or replacing it.\n", 534 pe->freeze_count);
517 location, drv_str, pci_str, frozen_edev->freeze_count);
518 goto perm_error; 535 goto perm_error;
519 536
520hard_fail: 537hard_fail:
521 printk(KERN_ERR 538 pr_err("EEH: Unable to recover from failure from PHB#%d-PE#%x.\n"
522 "EEH: Unable to recover from failure of PCI device " 539 "Please try reseating or replacing it\n",
523 "at location=%s driver=%s pci addr=%s\n" 540 pe->phb->global_number, pe->addr);
524 "Please try reseating this device or replacing it.\n",
525 location, drv_str, pci_str);
526 541
527perm_error: 542perm_error:
528 eeh_slot_error_detail(frozen_edev, EEH_LOG_PERM); 543 eeh_slot_error_detail(pe, EEH_LOG_PERM);
529 544
530 /* Notify all devices that they're about to go down. */ 545 /* Notify all devices that they're about to go down. */
531 pci_walk_bus(frozen_bus, eeh_report_failure, NULL); 546 eeh_pe_dev_traverse(pe, eeh_report_failure, NULL);
532 547
533 /* Shut down the device drivers for good. */ 548 /* Shut down the device drivers for good. */
534 pcibios_remove_pci_devices(frozen_bus); 549 if (frozen_bus)
535 550 pcibios_remove_pci_devices(frozen_bus);
536 return NULL;
537} 551}
538 552