1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <linux/delay.h>
26#include <linux/interrupt.h>
27#include <linux/irq.h>
28#include <linux/module.h>
29#include <linux/pci.h>
30#include <asm/eeh.h>
31#include <asm/eeh_event.h>
32#include <asm/ppc-pci.h>
33#include <asm/pci-bridge.h>
34#include <asm/prom.h>
35#include <asm/rtas.h>
36
37struct eeh_rmv_data {
38 struct list_head edev_list;
39 int removed;
40};
41
42
43
44
45
46
47
48
49static inline const char *eeh_pcid_name(struct pci_dev *pdev)
50{
51 if (pdev && pdev->dev.driver)
52 return pdev->dev.driver->name;
53 return "";
54}
55
56
57
58
59
60
61
62
63
64
65static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev)
66{
67 if (!pdev || !pdev->driver)
68 return NULL;
69
70 if (!try_module_get(pdev->driver->driver.owner))
71 return NULL;
72
73 return pdev->driver;
74}
75
76
77
78
79
80
81
82
83static inline void eeh_pcid_put(struct pci_dev *pdev)
84{
85 if (!pdev || !pdev->driver)
86 return;
87
88 module_put(pdev->driver->driver.owner);
89}
90
91
92
93
94
95
96
97
98
99
100
101static void eeh_disable_irq(struct pci_dev *dev)
102{
103 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
104
105
106
107
108
109 if (dev->msi_enabled || dev->msix_enabled)
110 return;
111
112 if (!irq_has_action(dev->irq))
113 return;
114
115 edev->mode |= EEH_DEV_IRQ_DISABLED;
116 disable_irq_nosync(dev->irq);
117}
118
119
120
121
122
123
124
125
126static void eeh_enable_irq(struct pci_dev *dev)
127{
128 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
129
130 if ((edev->mode) & EEH_DEV_IRQ_DISABLED) {
131 edev->mode &= ~EEH_DEV_IRQ_DISABLED;
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 if (irqd_irq_disabled(irq_get_irq_data(dev->irq)))
153 enable_irq(dev->irq);
154 }
155}
156
157static bool eeh_dev_removed(struct eeh_dev *edev)
158{
159
160 if (!edev || (edev->mode & EEH_DEV_REMOVED))
161 return true;
162
163 return false;
164}
165
166static void *eeh_dev_save_state(void *data, void *userdata)
167{
168 struct eeh_dev *edev = data;
169 struct pci_dev *pdev;
170
171 if (!edev)
172 return NULL;
173
174 pdev = eeh_dev_to_pci_dev(edev);
175 if (!pdev)
176 return NULL;
177
178 pci_save_state(pdev);
179 return NULL;
180}
181
182
183
184
185
186
187
188
189
190
191static void *eeh_report_error(void *data, void *userdata)
192{
193 struct eeh_dev *edev = (struct eeh_dev *)data;
194 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
195 enum pci_ers_result rc, *res = userdata;
196 struct pci_driver *driver;
197
198 if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe))
199 return NULL;
200 dev->error_state = pci_channel_io_frozen;
201
202 driver = eeh_pcid_get(dev);
203 if (!driver) return NULL;
204
205 eeh_disable_irq(dev);
206
207 if (!driver->err_handler ||
208 !driver->err_handler->error_detected) {
209 eeh_pcid_put(dev);
210 return NULL;
211 }
212
213 rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen);
214
215
216 if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
217 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
218
219 edev->in_error = true;
220 eeh_pcid_put(dev);
221 return NULL;
222}
223
224
225
226
227
228
229
230
231
232
233static void *eeh_report_mmio_enabled(void *data, void *userdata)
234{
235 struct eeh_dev *edev = (struct eeh_dev *)data;
236 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
237 enum pci_ers_result rc, *res = userdata;
238 struct pci_driver *driver;
239
240 if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe))
241 return NULL;
242
243 driver = eeh_pcid_get(dev);
244 if (!driver) return NULL;
245
246 if (!driver->err_handler ||
247 !driver->err_handler->mmio_enabled ||
248 (edev->mode & EEH_DEV_NO_HANDLER)) {
249 eeh_pcid_put(dev);
250 return NULL;
251 }
252
253 rc = driver->err_handler->mmio_enabled(dev);
254
255
256 if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
257 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
258
259 eeh_pcid_put(dev);
260 return NULL;
261}
262
263
264
265
266
267
268
269
270
271
272
273static void *eeh_report_reset(void *data, void *userdata)
274{
275 struct eeh_dev *edev = (struct eeh_dev *)data;
276 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
277 enum pci_ers_result rc, *res = userdata;
278 struct pci_driver *driver;
279
280 if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe))
281 return NULL;
282 dev->error_state = pci_channel_io_normal;
283
284 driver = eeh_pcid_get(dev);
285 if (!driver) return NULL;
286
287 eeh_enable_irq(dev);
288
289 if (!driver->err_handler ||
290 !driver->err_handler->slot_reset ||
291 (edev->mode & EEH_DEV_NO_HANDLER) ||
292 (!edev->in_error)) {
293 eeh_pcid_put(dev);
294 return NULL;
295 }
296
297 rc = driver->err_handler->slot_reset(dev);
298 if ((*res == PCI_ERS_RESULT_NONE) ||
299 (*res == PCI_ERS_RESULT_RECOVERED)) *res = rc;
300 if (*res == PCI_ERS_RESULT_DISCONNECT &&
301 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
302
303 eeh_pcid_put(dev);
304 return NULL;
305}
306
307static void *eeh_dev_restore_state(void *data, void *userdata)
308{
309 struct eeh_dev *edev = data;
310 struct pci_dev *pdev;
311
312 if (!edev)
313 return NULL;
314
315 pdev = eeh_dev_to_pci_dev(edev);
316 if (!pdev)
317 return NULL;
318
319 pci_restore_state(pdev);
320 return NULL;
321}
322
323
324
325
326
327
328
329
330
331
332static void *eeh_report_resume(void *data, void *userdata)
333{
334 struct eeh_dev *edev = (struct eeh_dev *)data;
335 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
336 bool was_in_error;
337 struct pci_driver *driver;
338
339 if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe))
340 return NULL;
341 dev->error_state = pci_channel_io_normal;
342
343 driver = eeh_pcid_get(dev);
344 if (!driver) return NULL;
345
346 was_in_error = edev->in_error;
347 edev->in_error = false;
348 eeh_enable_irq(dev);
349
350 if (!driver->err_handler ||
351 !driver->err_handler->resume ||
352 (edev->mode & EEH_DEV_NO_HANDLER) || !was_in_error) {
353 edev->mode &= ~EEH_DEV_NO_HANDLER;
354 eeh_pcid_put(dev);
355 return NULL;
356 }
357
358 driver->err_handler->resume(dev);
359
360 eeh_pcid_put(dev);
361 return NULL;
362}
363
364
365
366
367
368
369
370
371
372static void *eeh_report_failure(void *data, void *userdata)
373{
374 struct eeh_dev *edev = (struct eeh_dev *)data;
375 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
376 struct pci_driver *driver;
377
378 if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe))
379 return NULL;
380 dev->error_state = pci_channel_io_perm_failure;
381
382 driver = eeh_pcid_get(dev);
383 if (!driver) return NULL;
384
385 eeh_disable_irq(dev);
386
387 if (!driver->err_handler ||
388 !driver->err_handler->error_detected) {
389 eeh_pcid_put(dev);
390 return NULL;
391 }
392
393 driver->err_handler->error_detected(dev, pci_channel_io_perm_failure);
394
395 eeh_pcid_put(dev);
396 return NULL;
397}
398
399static void *eeh_add_virt_device(void *data, void *userdata)
400{
401 struct pci_driver *driver;
402 struct eeh_dev *edev = (struct eeh_dev *)data;
403 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
404 struct pci_dn *pdn = eeh_dev_to_pdn(edev);
405
406 if (!(edev->physfn)) {
407 pr_warn("%s: EEH dev %04x:%02x:%02x.%01x not for VF\n",
408 __func__, edev->phb->global_number, pdn->busno,
409 PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
410 return NULL;
411 }
412
413 driver = eeh_pcid_get(dev);
414 if (driver) {
415 eeh_pcid_put(dev);
416 if (driver->err_handler)
417 return NULL;
418 }
419
420#ifdef CONFIG_PPC_POWERNV
421 pci_iov_add_virtfn(edev->physfn, pdn->vf_index, 0);
422#endif
423 return NULL;
424}
425
426static void *eeh_rmv_device(void *data, void *userdata)
427{
428 struct pci_driver *driver;
429 struct eeh_dev *edev = (struct eeh_dev *)data;
430 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
431 struct eeh_rmv_data *rmv_data = (struct eeh_rmv_data *)userdata;
432 int *removed = rmv_data ? &rmv_data->removed : NULL;
433
434
435
436
437
438
439
440
441 if (!dev || (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE))
442 return NULL;
443
444
445
446
447
448
449
450
451 if (eeh_dev_removed(edev))
452 return NULL;
453
454 driver = eeh_pcid_get(dev);
455 if (driver) {
456 eeh_pcid_put(dev);
457 if (removed &&
458 eeh_pe_passed(edev->pe))
459 return NULL;
460 if (removed &&
461 driver->err_handler &&
462 driver->err_handler->error_detected &&
463 driver->err_handler->slot_reset)
464 return NULL;
465 }
466
467
468 pr_debug("EEH: Removing %s without EEH sensitive driver\n",
469 pci_name(dev));
470 edev->bus = dev->bus;
471 edev->mode |= EEH_DEV_DISCONNECTED;
472 if (removed)
473 (*removed)++;
474
475 if (edev->physfn) {
476#ifdef CONFIG_PPC_POWERNV
477 struct pci_dn *pdn = eeh_dev_to_pdn(edev);
478
479 pci_iov_remove_virtfn(edev->physfn, pdn->vf_index, 0);
480 edev->pdev = NULL;
481
482
483
484
485
486 pdn->pe_number = IODA_INVALID_PE;
487#endif
488 if (rmv_data)
489 list_add(&edev->rmv_list, &rmv_data->edev_list);
490 } else {
491 pci_lock_rescan_remove();
492 pci_stop_and_remove_bus_device(dev);
493 pci_unlock_rescan_remove();
494 }
495
496 return NULL;
497}
498
499static void *eeh_pe_detach_dev(void *data, void *userdata)
500{
501 struct eeh_pe *pe = (struct eeh_pe *)data;
502 struct eeh_dev *edev, *tmp;
503
504 eeh_pe_for_each_dev(pe, edev, tmp) {
505 if (!(edev->mode & EEH_DEV_DISCONNECTED))
506 continue;
507
508 edev->mode &= ~(EEH_DEV_DISCONNECTED | EEH_DEV_IRQ_DISABLED);
509 eeh_rmv_from_parent_pe(edev);
510 }
511
512 return NULL;
513}
514
515
516
517
518
519
520
521
522static void *__eeh_clear_pe_frozen_state(void *data, void *flag)
523{
524 struct eeh_pe *pe = (struct eeh_pe *)data;
525 bool *clear_sw_state = flag;
526 int i, rc = 1;
527
528 for (i = 0; rc && i < 3; i++)
529 rc = eeh_unfreeze_pe(pe, clear_sw_state);
530
531
532 if (rc) {
533 pr_warn("%s: Failure %d unfreezing PHB#%x-PE#%x\n",
534 __func__, rc, pe->phb->global_number, pe->addr);
535 return (void *)pe;
536 }
537
538 return NULL;
539}
540
541static int eeh_clear_pe_frozen_state(struct eeh_pe *pe,
542 bool clear_sw_state)
543{
544 void *rc;
545
546 rc = eeh_pe_traverse(pe, __eeh_clear_pe_frozen_state, &clear_sw_state);
547 if (!rc)
548 eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
549
550 return rc ? -EIO : 0;
551}
552
553int eeh_pe_reset_and_recover(struct eeh_pe *pe)
554{
555 int result, ret;
556
557
558 if (pe->state & EEH_PE_RECOVERING)
559 return 0;
560
561
562 eeh_pe_state_mark(pe, EEH_PE_RECOVERING);
563
564
565 eeh_pe_dev_traverse(pe, eeh_dev_save_state, NULL);
566
567
568 eeh_pe_dev_traverse(pe, eeh_report_error, &result);
569
570
571 ret = eeh_reset_pe(pe);
572 if (ret) {
573 eeh_pe_state_clear(pe, EEH_PE_RECOVERING);
574 return ret;
575 }
576
577
578 ret = eeh_clear_pe_frozen_state(pe, true);
579 if (ret) {
580 eeh_pe_state_clear(pe, EEH_PE_RECOVERING);
581 return ret;
582 }
583
584
585 eeh_pe_dev_traverse(pe, eeh_report_reset, &result);
586
587
588 eeh_pe_dev_traverse(pe, eeh_dev_restore_state, NULL);
589
590
591 eeh_pe_dev_traverse(pe, eeh_report_resume, NULL);
592
593
594 eeh_pe_state_clear(pe, EEH_PE_RECOVERING);
595
596 return 0;
597}
598
599
600
601
602
603
604
605
606
607
608static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
609 struct eeh_rmv_data *rmv_data)
610{
611 struct pci_bus *frozen_bus = eeh_pe_bus_get(pe);
612 struct timeval tstamp;
613 int cnt, rc;
614 struct eeh_dev *edev;
615
616
617 cnt = pe->freeze_count;
618 tstamp = pe->tstamp;
619
620
621
622
623
624
625
626 eeh_pe_state_mark(pe, EEH_PE_KEEP);
627 if (bus) {
628 if (pe->type & EEH_PE_VF) {
629 eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);
630 } else {
631 eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
632 pci_lock_rescan_remove();
633 pcibios_remove_pci_devices(bus);
634 pci_unlock_rescan_remove();
635 }
636 } else if (frozen_bus) {
637 eeh_pe_dev_traverse(pe, eeh_rmv_device, &rmv_data);
638 }
639
640
641
642
643
644
645
646
647
648
649 rc = eeh_reset_pe(pe);
650 if (rc)
651 return rc;
652
653 pci_lock_rescan_remove();
654
655
656 eeh_ops->configure_bridge(pe);
657 eeh_pe_restore_bars(pe);
658
659
660 rc = eeh_clear_pe_frozen_state(pe, false);
661 if (rc)
662 return rc;
663
664
665
666
667
668
669
670 if (bus) {
671 pr_info("EEH: Sleep 5s ahead of complete hotplug\n");
672 ssleep(5);
673
674
675
676
677
678
679 edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
680 eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
681 if (pe->type & EEH_PE_VF)
682 eeh_add_virt_device(edev, NULL);
683 else
684 pcibios_add_pci_devices(bus);
685 } else if (frozen_bus && rmv_data->removed) {
686 pr_info("EEH: Sleep 5s ahead of partial hotplug\n");
687 ssleep(5);
688
689 edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
690 eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
691 if (pe->type & EEH_PE_VF)
692 eeh_add_virt_device(edev, NULL);
693 else
694 pcibios_add_pci_devices(frozen_bus);
695 }
696 eeh_pe_state_clear(pe, EEH_PE_KEEP);
697
698 pe->tstamp = tstamp;
699 pe->freeze_count = cnt;
700
701 pci_unlock_rescan_remove();
702 return 0;
703}
704
705
706
707
708#define MAX_WAIT_FOR_RECOVERY 300
709
710static void eeh_handle_normal_event(struct eeh_pe *pe)
711{
712 struct pci_bus *frozen_bus;
713 struct eeh_dev *edev, *tmp;
714 int rc = 0;
715 enum pci_ers_result result = PCI_ERS_RESULT_NONE;
716 struct eeh_rmv_data rmv_data = {LIST_HEAD_INIT(rmv_data.edev_list), 0};
717
718 frozen_bus = eeh_pe_bus_get(pe);
719 if (!frozen_bus) {
720 pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n",
721 __func__, pe->phb->global_number, pe->addr);
722 return;
723 }
724
725 eeh_pe_update_time_stamp(pe);
726 pe->freeze_count++;
727 if (pe->freeze_count > eeh_max_freezes)
728 goto excess_failures;
729 pr_warn("EEH: This PCI device has failed %d times in the last hour\n",
730 pe->freeze_count);
731
732
733
734
735
736
737
738
739
740
741
742 pr_info("EEH: Notify device drivers to shutdown\n");
743 eeh_pe_dev_traverse(pe, eeh_report_error, &result);
744 if ((pe->type & EEH_PE_PHB) &&
745 result != PCI_ERS_RESULT_NONE &&
746 result != PCI_ERS_RESULT_NEED_RESET)
747 result = PCI_ERS_RESULT_NEED_RESET;
748
749
750
751
752 rc = eeh_ops->wait_state(pe, MAX_WAIT_FOR_RECOVERY*1000);
753 if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) {
754 pr_warn("EEH: Permanent failure\n");
755 goto hard_fail;
756 }
757
758
759
760
761
762 pr_info("EEH: Collect temporary log\n");
763 eeh_slot_error_detail(pe, EEH_LOG_TEMP);
764
765
766
767
768
769 if (result == PCI_ERS_RESULT_NONE) {
770 pr_info("EEH: Reset with hotplug activity\n");
771 rc = eeh_reset_device(pe, frozen_bus, NULL);
772 if (rc) {
773 pr_warn("%s: Unable to reset, err=%d\n",
774 __func__, rc);
775 goto hard_fail;
776 }
777 }
778
779
780 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
781 pr_info("EEH: Enable I/O for affected devices\n");
782 rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO);
783
784 if (rc < 0)
785 goto hard_fail;
786 if (rc) {
787 result = PCI_ERS_RESULT_NEED_RESET;
788 } else {
789 pr_info("EEH: Notify device drivers to resume I/O\n");
790 eeh_pe_dev_traverse(pe, eeh_report_mmio_enabled, &result);
791 }
792 }
793
794
795 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
796 pr_info("EEH: Enabled DMA for affected devices\n");
797 rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA);
798
799 if (rc < 0)
800 goto hard_fail;
801 if (rc) {
802 result = PCI_ERS_RESULT_NEED_RESET;
803 } else {
804
805
806
807
808
809 eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
810 result = PCI_ERS_RESULT_RECOVERED;
811 }
812 }
813
814
815 if (result == PCI_ERS_RESULT_DISCONNECT) {
816 pr_warn("EEH: Device driver gave up\n");
817 goto hard_fail;
818 }
819
820
821 if (result == PCI_ERS_RESULT_NEED_RESET) {
822 pr_info("EEH: Reset without hotplug activity\n");
823 rc = eeh_reset_device(pe, NULL, &rmv_data);
824 if (rc) {
825 pr_warn("%s: Cannot reset, err=%d\n",
826 __func__, rc);
827 goto hard_fail;
828 }
829
830 pr_info("EEH: Notify device drivers "
831 "the completion of reset\n");
832 result = PCI_ERS_RESULT_NONE;
833 eeh_pe_dev_traverse(pe, eeh_report_reset, &result);
834 }
835
836
837 if ((result != PCI_ERS_RESULT_RECOVERED) &&
838 (result != PCI_ERS_RESULT_NONE)) {
839 pr_warn("EEH: Not recovered\n");
840 goto hard_fail;
841 }
842
843
844
845
846
847 list_for_each_entry_safe(edev, tmp, &rmv_data.edev_list, rmv_list) {
848 eeh_add_virt_device(edev, NULL);
849 list_del(&edev->rmv_list);
850 }
851
852
853 pr_info("EEH: Notify device driver to resume\n");
854 eeh_pe_dev_traverse(pe, eeh_report_resume, NULL);
855
856 return;
857
858excess_failures:
859
860
861
862
863
864 pr_err("EEH: PHB#%d-PE#%x has failed %d times in the\n"
865 "last hour and has been permanently disabled.\n"
866 "Please try reseating or replacing it.\n",
867 pe->phb->global_number, pe->addr,
868 pe->freeze_count);
869 goto perm_error;
870
871hard_fail:
872 pr_err("EEH: Unable to recover from failure from PHB#%d-PE#%x.\n"
873 "Please try reseating or replacing it\n",
874 pe->phb->global_number, pe->addr);
875
876perm_error:
877 eeh_slot_error_detail(pe, EEH_LOG_PERM);
878
879
880 eeh_pe_dev_traverse(pe, eeh_report_failure, NULL);
881
882
883 eeh_pe_state_mark(pe, EEH_PE_REMOVED);
884
885
886
887
888
889
890 if (frozen_bus) {
891 if (pe->type & EEH_PE_VF) {
892 eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);
893 eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
894 } else {
895 eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
896 eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
897
898 pci_lock_rescan_remove();
899 pcibios_remove_pci_devices(frozen_bus);
900 pci_unlock_rescan_remove();
901 }
902 }
903}
904
905static void eeh_handle_special_event(void)
906{
907 struct eeh_pe *pe, *phb_pe;
908 struct pci_bus *bus;
909 struct pci_controller *hose;
910 unsigned long flags;
911 int rc;
912
913
914 do {
915 rc = eeh_ops->next_error(&pe);
916
917 switch (rc) {
918 case EEH_NEXT_ERR_DEAD_IOC:
919
920 eeh_serialize_lock(&flags);
921
922
923 eeh_remove_event(NULL, true);
924
925 list_for_each_entry(hose, &hose_list, list_node) {
926 phb_pe = eeh_phb_pe_get(hose);
927 if (!phb_pe) continue;
928
929 eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED);
930 }
931
932 eeh_serialize_unlock(flags);
933
934 break;
935 case EEH_NEXT_ERR_FROZEN_PE:
936 case EEH_NEXT_ERR_FENCED_PHB:
937 case EEH_NEXT_ERR_DEAD_PHB:
938
939 eeh_serialize_lock(&flags);
940
941
942 eeh_remove_event(pe, true);
943
944 if (rc == EEH_NEXT_ERR_DEAD_PHB)
945 eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
946 else
947 eeh_pe_state_mark(pe,
948 EEH_PE_ISOLATED | EEH_PE_RECOVERING);
949
950 eeh_serialize_unlock(flags);
951
952 break;
953 case EEH_NEXT_ERR_NONE:
954 return;
955 default:
956 pr_warn("%s: Invalid value %d from next_error()\n",
957 __func__, rc);
958 return;
959 }
960
961
962
963
964
965
966 if (rc == EEH_NEXT_ERR_FROZEN_PE ||
967 rc == EEH_NEXT_ERR_FENCED_PHB) {
968 eeh_handle_normal_event(pe);
969 eeh_pe_state_clear(pe, EEH_PE_RECOVERING);
970 } else {
971 pci_lock_rescan_remove();
972 list_for_each_entry(hose, &hose_list, list_node) {
973 phb_pe = eeh_phb_pe_get(hose);
974 if (!phb_pe ||
975 !(phb_pe->state & EEH_PE_ISOLATED) ||
976 (phb_pe->state & EEH_PE_RECOVERING))
977 continue;
978
979
980 eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
981 bus = eeh_pe_bus_get(phb_pe);
982 eeh_pe_dev_traverse(pe,
983 eeh_report_failure, NULL);
984 pcibios_remove_pci_devices(bus);
985 }
986 pci_unlock_rescan_remove();
987 }
988
989
990
991
992
993 if (rc == EEH_NEXT_ERR_DEAD_IOC)
994 break;
995 } while (rc != EEH_NEXT_ERR_NONE);
996}
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015void eeh_handle_event(struct eeh_pe *pe)
1016{
1017 if (pe)
1018 eeh_handle_normal_event(pe);
1019 else
1020 eeh_handle_special_event();
1021}
1022