2 * The file intends to implement the functions needed by EEH, which is
3 * built on IODA compliant chip. Actually, lots of functions related
4 * to EEH would be built based on the OPAL APIs.
6 * Copyright Benjamin Herrenschmidt & Gavin Shan, IBM Corporation 2013.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/bootmem.h>
15 #include <linux/delay.h>
16 #include <linux/init.h>
18 #include <linux/irq.h>
19 #include <linux/kernel.h>
20 #include <linux/msi.h>
21 #include <linux/pci.h>
22 #include <linux/string.h>
25 #include <asm/eeh_event.h>
27 #include <asm/iommu.h>
28 #include <asm/msi_bitmap.h>
30 #include <asm/pci-bridge.h>
31 #include <asm/ppc-pci.h>
37 /* Debugging option */
38 #ifdef IODA_EEH_DBG_ON
39 #define IODA_EEH_DBG(args...) pr_info(args)
41 #define IODA_EEH_DBG(args...)
44 static char *hub_diag
= NULL
;
47 * ioda_eeh_post_init - Chip dependent post initialization
48 * @hose: PCI controller
50 * The function will be called after eeh PEs and devices
51 * have been built. That means the EEH is ready to supply
52 * service with I/O cache.
54 static int ioda_eeh_post_init(struct pci_controller
*hose
)
56 struct pnv_phb
*phb
= hose
->private_data
;
58 /* FIXME: Enable it for PHB3 later */
59 if (phb
->type
== PNV_PHB_IODA1
) {
61 hub_diag
= (char *)__get_free_page(GFP_KERNEL
|
64 pr_err("%s: Out of memory !\n",
77 * ioda_eeh_set_option - Set EEH operation or I/O setting
81 * Enable or disable EEH option for the indicated PE. The
82 * function also can be used to enable I/O or DMA for the
85 static int ioda_eeh_set_option(struct eeh_pe
*pe
, int option
)
89 struct pci_controller
*hose
= pe
->phb
;
90 struct pnv_phb
*phb
= hose
->private_data
;
92 /* Check on PE number */
93 if (pe
->addr
< 0 || pe
->addr
>= phb
->ioda
.total_pe
) {
94 pr_err("%s: PE address %x out of range [0, %x] "
96 __func__
, pe
->addr
, phb
->ioda
.total_pe
,
103 case EEH_OPT_DISABLE
:
109 case EEH_OPT_THAW_MMIO
:
110 ret
= opal_pci_eeh_freeze_clear(phb
->opal_id
, pe_no
,
111 OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO
);
113 pr_warning("%s: Failed to enable MMIO for "
114 "PHB#%x-PE#%x, err=%lld\n",
115 __func__
, hose
->global_number
, pe_no
, ret
);
120 case EEH_OPT_THAW_DMA
:
121 ret
= opal_pci_eeh_freeze_clear(phb
->opal_id
, pe_no
,
122 OPAL_EEH_ACTION_CLEAR_FREEZE_DMA
);
124 pr_warning("%s: Failed to enable DMA for "
125 "PHB#%x-PE#%x, err=%lld\n",
126 __func__
, hose
->global_number
, pe_no
, ret
);
132 pr_warning("%s: Invalid option %d\n", __func__
, option
);
140 * ioda_eeh_get_state - Retrieve the state of PE
143 * The PE's state should be retrieved from the PEEV, PEST
144 * IODA tables. Since the OPAL has exported the function
145 * to do it, it'd better to use that.
147 static int ioda_eeh_get_state(struct eeh_pe
*pe
)
154 struct pci_controller
*hose
= pe
->phb
;
155 struct pnv_phb
*phb
= hose
->private_data
;
158 * Sanity check on PE address. The PHB PE address should
161 if (pe
->addr
< 0 || pe
->addr
>= phb
->ioda
.total_pe
) {
162 pr_err("%s: PE address %x out of range [0, %x] "
164 __func__
, pe
->addr
, phb
->ioda
.total_pe
,
165 hose
->global_number
);
166 return EEH_STATE_NOT_SUPPORT
;
169 /* Retrieve PE status through OPAL */
171 ret
= opal_pci_eeh_freeze_status(phb
->opal_id
, pe_no
,
172 &fstate
, &pcierr
, NULL
);
174 pr_err("%s: Failed to get EEH status on "
175 "PHB#%x-PE#%x\n, err=%lld\n",
176 __func__
, hose
->global_number
, pe_no
, ret
);
177 return EEH_STATE_NOT_SUPPORT
;
180 /* Check PHB status */
181 if (pe
->type
& EEH_PE_PHB
) {
183 result
&= ~EEH_STATE_RESET_ACTIVE
;
185 if (pcierr
!= OPAL_EEH_PHB_ERROR
) {
186 result
|= EEH_STATE_MMIO_ACTIVE
;
187 result
|= EEH_STATE_DMA_ACTIVE
;
188 result
|= EEH_STATE_MMIO_ENABLED
;
189 result
|= EEH_STATE_DMA_ENABLED
;
195 /* Parse result out */
198 case OPAL_EEH_STOPPED_NOT_FROZEN
:
199 result
&= ~EEH_STATE_RESET_ACTIVE
;
200 result
|= EEH_STATE_MMIO_ACTIVE
;
201 result
|= EEH_STATE_DMA_ACTIVE
;
202 result
|= EEH_STATE_MMIO_ENABLED
;
203 result
|= EEH_STATE_DMA_ENABLED
;
205 case OPAL_EEH_STOPPED_MMIO_FREEZE
:
206 result
&= ~EEH_STATE_RESET_ACTIVE
;
207 result
|= EEH_STATE_DMA_ACTIVE
;
208 result
|= EEH_STATE_DMA_ENABLED
;
210 case OPAL_EEH_STOPPED_DMA_FREEZE
:
211 result
&= ~EEH_STATE_RESET_ACTIVE
;
212 result
|= EEH_STATE_MMIO_ACTIVE
;
213 result
|= EEH_STATE_MMIO_ENABLED
;
215 case OPAL_EEH_STOPPED_MMIO_DMA_FREEZE
:
216 result
&= ~EEH_STATE_RESET_ACTIVE
;
218 case OPAL_EEH_STOPPED_RESET
:
219 result
|= EEH_STATE_RESET_ACTIVE
;
221 case OPAL_EEH_STOPPED_TEMP_UNAVAIL
:
222 result
|= EEH_STATE_UNAVAILABLE
;
224 case OPAL_EEH_STOPPED_PERM_UNAVAIL
:
225 result
|= EEH_STATE_NOT_SUPPORT
;
228 pr_warning("%s: Unexpected EEH status 0x%x "
230 __func__
, fstate
, hose
->global_number
, pe_no
);
236 static int ioda_eeh_pe_clear(struct eeh_pe
*pe
)
238 struct pci_controller
*hose
;
247 phb
= pe
->phb
->private_data
;
249 /* Clear the EEH error on the PE */
250 ret
= opal_pci_eeh_freeze_clear(phb
->opal_id
,
251 pe_no
, OPAL_EEH_ACTION_CLEAR_FREEZE_ALL
);
253 pr_err("%s: Failed to clear EEH error for "
254 "PHB#%x-PE#%x, err=%lld\n",
255 __func__
, hose
->global_number
, pe_no
, ret
);
260 * Read the PE state back and verify that the frozen
261 * state has been removed.
263 ret
= opal_pci_eeh_freeze_status(phb
->opal_id
, pe_no
,
264 &fstate
, &pcierr
, NULL
);
266 pr_err("%s: Failed to get EEH status on "
267 "PHB#%x-PE#%x\n, err=%lld\n",
268 __func__
, hose
->global_number
, pe_no
, ret
);
272 if (fstate
!= OPAL_EEH_STOPPED_NOT_FROZEN
) {
273 pr_err("%s: Frozen state not cleared on "
274 "PHB#%x-PE#%x, sts=%x\n",
275 __func__
, hose
->global_number
, pe_no
, fstate
);
282 static s64
ioda_eeh_phb_poll(struct pnv_phb
*phb
)
284 s64 rc
= OPAL_HARDWARE
;
287 rc
= opal_pci_poll(phb
->opal_id
);
297 static int ioda_eeh_phb_reset(struct pci_controller
*hose
, int option
)
299 struct pnv_phb
*phb
= hose
->private_data
;
300 s64 rc
= OPAL_HARDWARE
;
302 pr_debug("%s: Reset PHB#%x, option=%d\n",
303 __func__
, hose
->global_number
, option
);
305 /* Issue PHB complete reset request */
306 if (option
== EEH_RESET_FUNDAMENTAL
||
307 option
== EEH_RESET_HOT
)
308 rc
= opal_pci_reset(phb
->opal_id
,
311 else if (option
== EEH_RESET_DEACTIVATE
)
312 rc
= opal_pci_reset(phb
->opal_id
,
314 OPAL_DEASSERT_RESET
);
319 * Poll state of the PHB until the request is done
322 rc
= ioda_eeh_phb_poll(phb
);
324 if (rc
!= OPAL_SUCCESS
)
330 static int ioda_eeh_root_reset(struct pci_controller
*hose
, int option
)
332 struct pnv_phb
*phb
= hose
->private_data
;
333 s64 rc
= OPAL_SUCCESS
;
335 pr_debug("%s: Reset PHB#%x, option=%d\n",
336 __func__
, hose
->global_number
, option
);
339 * During the reset deassert time, we needn't care
340 * the reset scope because the firmware does nothing
341 * for fundamental or hot reset during deassert phase.
343 if (option
== EEH_RESET_FUNDAMENTAL
)
344 rc
= opal_pci_reset(phb
->opal_id
,
345 OPAL_PCI_FUNDAMENTAL_RESET
,
347 else if (option
== EEH_RESET_HOT
)
348 rc
= opal_pci_reset(phb
->opal_id
,
351 else if (option
== EEH_RESET_DEACTIVATE
)
352 rc
= opal_pci_reset(phb
->opal_id
,
354 OPAL_DEASSERT_RESET
);
358 /* Poll state of the PHB until the request is done */
359 rc
= ioda_eeh_phb_poll(phb
);
361 if (rc
!= OPAL_SUCCESS
)
367 static int ioda_eeh_bridge_reset(struct pci_controller
*hose
,
368 struct pci_dev
*dev
, int option
)
372 pr_debug("%s: Reset device %04x:%02x:%02x.%01x with option %d\n",
373 __func__
, hose
->global_number
, dev
->bus
->number
,
374 PCI_SLOT(dev
->devfn
), PCI_FUNC(dev
->devfn
), option
);
377 case EEH_RESET_FUNDAMENTAL
:
379 pci_read_config_word(dev
, PCI_BRIDGE_CONTROL
, &ctrl
);
380 ctrl
|= PCI_BRIDGE_CTL_BUS_RESET
;
381 pci_write_config_word(dev
, PCI_BRIDGE_CONTROL
, ctrl
);
383 case EEH_RESET_DEACTIVATE
:
384 pci_read_config_word(dev
, PCI_BRIDGE_CONTROL
, &ctrl
);
385 ctrl
&= ~PCI_BRIDGE_CTL_BUS_RESET
;
386 pci_write_config_word(dev
, PCI_BRIDGE_CONTROL
, ctrl
);
394 * ioda_eeh_reset - Reset the indicated PE
396 * @option: reset option
398 * Do reset on the indicated PE. For PCI bus sensitive PE,
399 * we need to reset the parent p2p bridge. The PHB has to
400 * be reinitialized if the p2p bridge is root bridge. For
401 * PCI device sensitive PE, we will try to reset the device
402 * through FLR. For now, we don't have OPAL APIs to do HARD
403 * reset yet, so all reset would be SOFT (HOT) reset.
405 static int ioda_eeh_reset(struct eeh_pe
*pe
, int option
)
407 struct pci_controller
*hose
= pe
->phb
;
408 struct eeh_dev
*edev
;
413 * Anyway, we have to clear the problematic state for the
414 * corresponding PE. However, we needn't do it if the PE
415 * is PHB associated. That means the PHB is having fatal
416 * errors and it needs reset. Further more, the AIB interface
417 * isn't reliable any more.
419 if (!(pe
->type
& EEH_PE_PHB
) &&
420 (option
== EEH_RESET_HOT
||
421 option
== EEH_RESET_FUNDAMENTAL
)) {
422 ret
= ioda_eeh_pe_clear(pe
);
428 * The rules applied to reset, either fundamental or hot reset:
430 * We always reset the direct upstream bridge of the PE. If the
431 * direct upstream bridge isn't root bridge, we always take hot
432 * reset no matter what option (fundamental or hot) is. Otherwise,
433 * we should do the reset according to the required option.
435 if (pe
->type
& EEH_PE_PHB
) {
436 ret
= ioda_eeh_phb_reset(hose
, option
);
438 if (pe
->type
& EEH_PE_DEVICE
) {
440 * If it's device PE, we didn't refer to the parent
441 * PCI bus yet. So we have to figure it out indirectly.
443 edev
= list_first_entry(&pe
->edevs
,
444 struct eeh_dev
, list
);
445 dev
= eeh_dev_to_pci_dev(edev
);
446 dev
= dev
->bus
->self
;
449 * If it's bus PE, the parent PCI bus is already there
450 * and just pick it up.
456 * Do reset based on the fact that the direct upstream bridge
457 * is root bridge (port) or not.
459 if (dev
->bus
->number
== 0)
460 ret
= ioda_eeh_root_reset(hose
, option
);
462 ret
= ioda_eeh_bridge_reset(hose
, dev
, option
);
469 * ioda_eeh_get_log - Retrieve error log
471 * @severity: Severity level of the log
472 * @drv_log: buffer to store the log
473 * @len: space of the log buffer
475 * The function is used to retrieve error log from P7IOC.
477 static int ioda_eeh_get_log(struct eeh_pe
*pe
, int severity
,
478 char *drv_log
, unsigned long len
)
482 struct pci_controller
*hose
= pe
->phb
;
483 struct pnv_phb
*phb
= hose
->private_data
;
485 spin_lock_irqsave(&phb
->lock
, flags
);
487 ret
= opal_pci_get_phb_diag_data2(phb
->opal_id
,
488 phb
->diag
.blob
, PNV_PCI_DIAG_BUF_SIZE
);
490 spin_unlock_irqrestore(&phb
->lock
, flags
);
491 pr_warning("%s: Failed to get log for PHB#%x-PE#%x\n",
492 __func__
, hose
->global_number
, pe
->addr
);
497 * FIXME: We probably need log the error in somewhere.
498 * Lets make it up in future.
500 /* pr_info("%s", phb->diag.blob); */
502 spin_unlock_irqrestore(&phb
->lock
, flags
);
508 * ioda_eeh_configure_bridge - Configure the PCI bridges for the indicated PE
511 * For particular PE, it might have included PCI bridges. In order
512 * to make the PE work properly, those PCI bridges should be configured
513 * correctly. However, we need do nothing on P7IOC since the reset
514 * function will do everything that should be covered by the function.
516 static int ioda_eeh_configure_bridge(struct eeh_pe
*pe
)
521 static void ioda_eeh_hub_diag_common(struct OpalIoP7IOCErrorData
*data
)
524 pr_info(" GEM XFIR: %016llx\n", data
->gemXfir
);
525 pr_info(" GEM RFIR: %016llx\n", data
->gemRfir
);
526 pr_info(" GEM RIRQFIR: %016llx\n", data
->gemRirqfir
);
527 pr_info(" GEM Mask: %016llx\n", data
->gemMask
);
528 pr_info(" GEM RWOF: %016llx\n", data
->gemRwof
);
531 pr_info(" LEM FIR: %016llx\n", data
->lemFir
);
532 pr_info(" LEM Error Mask: %016llx\n", data
->lemErrMask
);
533 pr_info(" LEM Action 0: %016llx\n", data
->lemAction0
);
534 pr_info(" LEM Action 1: %016llx\n", data
->lemAction1
);
535 pr_info(" LEM WOF: %016llx\n", data
->lemWof
);
538 static void ioda_eeh_hub_diag(struct pci_controller
*hose
)
540 struct pnv_phb
*phb
= hose
->private_data
;
541 struct OpalIoP7IOCErrorData
*data
;
544 data
= (struct OpalIoP7IOCErrorData
*)ioda_eeh_hub_diag
;
545 rc
= opal_pci_get_hub_diag_data(phb
->hub_id
, data
, PAGE_SIZE
);
546 if (rc
!= OPAL_SUCCESS
) {
547 pr_warning("%s: Failed to get HUB#%llx diag-data (%ld)\n",
548 __func__
, phb
->hub_id
, rc
);
552 switch (data
->type
) {
553 case OPAL_P7IOC_DIAG_TYPE_RGC
:
554 pr_info("P7IOC diag-data for RGC\n\n");
555 ioda_eeh_hub_diag_common(data
);
556 pr_info(" RGC Status: %016llx\n", data
->rgc
.rgcStatus
);
557 pr_info(" RGC LDCP: %016llx\n", data
->rgc
.rgcLdcp
);
559 case OPAL_P7IOC_DIAG_TYPE_BI
:
560 pr_info("P7IOC diag-data for BI %s\n\n",
561 data
->bi
.biDownbound
? "Downbound" : "Upbound");
562 ioda_eeh_hub_diag_common(data
);
563 pr_info(" BI LDCP 0: %016llx\n", data
->bi
.biLdcp0
);
564 pr_info(" BI LDCP 1: %016llx\n", data
->bi
.biLdcp1
);
565 pr_info(" BI LDCP 2: %016llx\n", data
->bi
.biLdcp2
);
566 pr_info(" BI Fence Status: %016llx\n", data
->bi
.biFenceStatus
);
568 case OPAL_P7IOC_DIAG_TYPE_CI
:
569 pr_info("P7IOC diag-data for CI Port %d\\nn",
571 ioda_eeh_hub_diag_common(data
);
572 pr_info(" CI Port Status: %016llx\n", data
->ci
.ciPortStatus
);
573 pr_info(" CI Port LDCP: %016llx\n", data
->ci
.ciPortLdcp
);
575 case OPAL_P7IOC_DIAG_TYPE_MISC
:
576 pr_info("P7IOC diag-data for MISC\n\n");
577 ioda_eeh_hub_diag_common(data
);
579 case OPAL_P7IOC_DIAG_TYPE_I2C
:
580 pr_info("P7IOC diag-data for I2C\n\n");
581 ioda_eeh_hub_diag_common(data
);
584 pr_warning("%s: Invalid type of HUB#%llx diag-data (%d)\n",
585 __func__
, phb
->hub_id
, data
->type
);
589 static void ioda_eeh_p7ioc_phb_diag(struct pci_controller
*hose
,
590 struct OpalIoPhbErrorCommon
*common
)
592 struct OpalIoP7IOCPhbErrorData
*data
;
595 data
= (struct OpalIoP7IOCPhbErrorData
*)common
;
597 pr_info("P7IOC PHB#%x Diag-data (Version: %d)\n\n",
598 hose
->global_number
, common
->version
);
600 pr_info(" brdgCtl: %08x\n", data
->brdgCtl
);
602 pr_info(" portStatusReg: %08x\n", data
->portStatusReg
);
603 pr_info(" rootCmplxStatus: %08x\n", data
->rootCmplxStatus
);
604 pr_info(" busAgentStatus: %08x\n", data
->busAgentStatus
);
606 pr_info(" deviceStatus: %08x\n", data
->deviceStatus
);
607 pr_info(" slotStatus: %08x\n", data
->slotStatus
);
608 pr_info(" linkStatus: %08x\n", data
->linkStatus
);
609 pr_info(" devCmdStatus: %08x\n", data
->devCmdStatus
);
610 pr_info(" devSecStatus: %08x\n", data
->devSecStatus
);
612 pr_info(" rootErrorStatus: %08x\n", data
->rootErrorStatus
);
613 pr_info(" uncorrErrorStatus: %08x\n", data
->uncorrErrorStatus
);
614 pr_info(" corrErrorStatus: %08x\n", data
->corrErrorStatus
);
615 pr_info(" tlpHdr1: %08x\n", data
->tlpHdr1
);
616 pr_info(" tlpHdr2: %08x\n", data
->tlpHdr2
);
617 pr_info(" tlpHdr3: %08x\n", data
->tlpHdr3
);
618 pr_info(" tlpHdr4: %08x\n", data
->tlpHdr4
);
619 pr_info(" sourceId: %08x\n", data
->sourceId
);
621 pr_info(" errorClass: %016llx\n", data
->errorClass
);
622 pr_info(" correlator: %016llx\n", data
->correlator
);
623 pr_info(" p7iocPlssr: %016llx\n", data
->p7iocPlssr
);
624 pr_info(" p7iocCsr: %016llx\n", data
->p7iocCsr
);
625 pr_info(" lemFir: %016llx\n", data
->lemFir
);
626 pr_info(" lemErrorMask: %016llx\n", data
->lemErrorMask
);
627 pr_info(" lemWOF: %016llx\n", data
->lemWOF
);
628 pr_info(" phbErrorStatus: %016llx\n", data
->phbErrorStatus
);
629 pr_info(" phbFirstErrorStatus: %016llx\n", data
->phbFirstErrorStatus
);
630 pr_info(" phbErrorLog0: %016llx\n", data
->phbErrorLog0
);
631 pr_info(" phbErrorLog1: %016llx\n", data
->phbErrorLog1
);
632 pr_info(" mmioErrorStatus: %016llx\n", data
->mmioErrorStatus
);
633 pr_info(" mmioFirstErrorStatus: %016llx\n", data
->mmioFirstErrorStatus
);
634 pr_info(" mmioErrorLog0: %016llx\n", data
->mmioErrorLog0
);
635 pr_info(" mmioErrorLog1: %016llx\n", data
->mmioErrorLog1
);
636 pr_info(" dma0ErrorStatus: %016llx\n", data
->dma0ErrorStatus
);
637 pr_info(" dma0FirstErrorStatus: %016llx\n", data
->dma0FirstErrorStatus
);
638 pr_info(" dma0ErrorLog0: %016llx\n", data
->dma0ErrorLog0
);
639 pr_info(" dma0ErrorLog1: %016llx\n", data
->dma0ErrorLog1
);
640 pr_info(" dma1ErrorStatus: %016llx\n", data
->dma1ErrorStatus
);
641 pr_info(" dma1FirstErrorStatus: %016llx\n", data
->dma1FirstErrorStatus
);
642 pr_info(" dma1ErrorLog0: %016llx\n", data
->dma1ErrorLog0
);
643 pr_info(" dma1ErrorLog1: %016llx\n", data
->dma1ErrorLog1
);
645 for (i
= 0; i
< OPAL_P7IOC_NUM_PEST_REGS
; i
++) {
646 if ((data
->pestA
[i
] >> 63) == 0 &&
647 (data
->pestB
[i
] >> 63) == 0)
650 pr_info(" PE[%3d] PESTA: %016llx\n", i
, data
->pestA
[i
]);
651 pr_info(" PESTB: %016llx\n", data
->pestB
[i
]);
655 static void ioda_eeh_phb_diag(struct pci_controller
*hose
)
657 struct pnv_phb
*phb
= hose
->private_data
;
658 struct OpalIoPhbErrorCommon
*common
;
661 common
= (struct OpalIoPhbErrorCommon
*)phb
->diag
.blob
;
662 rc
= opal_pci_get_phb_diag_data2(phb
->opal_id
, common
, PAGE_SIZE
);
663 if (rc
!= OPAL_SUCCESS
) {
664 pr_warning("%s: Failed to get diag-data for PHB#%x (%ld)\n",
665 __func__
, hose
->global_number
, rc
);
669 switch (common
->ioType
) {
670 case OPAL_PHB_ERROR_DATA_TYPE_P7IOC
:
671 ioda_eeh_p7ioc_phb_diag(hose
, common
);
674 pr_warning("%s: Unrecognized I/O chip %d\n",
675 __func__
, common
->ioType
);
679 static int ioda_eeh_get_phb_pe(struct pci_controller
*hose
,
682 struct eeh_pe
*phb_pe
;
684 phb_pe
= eeh_phb_pe_get(hose
);
686 pr_warning("%s Can't find PE for PHB#%d\n",
687 __func__
, hose
->global_number
);
695 static int ioda_eeh_get_pe(struct pci_controller
*hose
,
696 u16 pe_no
, struct eeh_pe
**pe
)
698 struct eeh_pe
*phb_pe
, *dev_pe
;
701 /* Find the PHB PE */
702 if (ioda_eeh_get_phb_pe(hose
, &phb_pe
))
705 /* Find the PE according to PE# */
706 memset(&dev
, 0, sizeof(struct eeh_dev
));
708 dev
.pe_config_addr
= pe_no
;
709 dev_pe
= eeh_pe_get(&dev
);
711 pr_warning("%s: Can't find PE for PHB#%x - PE#%x\n",
712 __func__
, hose
->global_number
, pe_no
);
721 * ioda_eeh_next_error - Retrieve next error for EEH core to handle
722 * @pe: The affected PE
724 * The function is expected to be called by EEH core while it gets
725 * special EEH event (without binding PE). The function calls to
726 * OPAL APIs for next error to handle. The informational error is
727 * handled internally by platform. However, the dead IOC, dead PHB,
728 * fenced PHB and frozen PE should be handled by EEH core eventually.
730 static int ioda_eeh_next_error(struct eeh_pe
**pe
)
732 struct pci_controller
*hose
, *tmp
;
735 u16 err_type
, severity
;
739 /* While running here, it's safe to purge the event queue */
740 eeh_remove_event(NULL
);
742 list_for_each_entry_safe(hose
, tmp
, &hose_list
, list_node
) {
744 * If the subordinate PCI buses of the PHB has been
745 * removed, we needn't take care of it any more.
747 phb
= hose
->private_data
;
751 rc
= opal_pci_next_error(phb
->opal_id
,
752 &frozen_pe_no
, &err_type
, &severity
);
754 /* If OPAL API returns error, we needn't proceed */
755 if (rc
!= OPAL_SUCCESS
) {
756 IODA_EEH_DBG("%s: Invalid return value on "
757 "PHB#%x (0x%lx) from opal_pci_next_error",
758 __func__
, hose
->global_number
, rc
);
762 /* If the PHB doesn't have error, stop processing */
763 if (err_type
== OPAL_EEH_NO_ERROR
||
764 severity
== OPAL_EEH_SEV_NO_ERROR
) {
765 IODA_EEH_DBG("%s: No error found on PHB#%x\n",
766 __func__
, hose
->global_number
);
771 * Processing the error. We're expecting the error with
772 * highest priority reported upon multiple errors on the
775 IODA_EEH_DBG("%s: Error (%d, %d, %d) on PHB#%x\n",
776 err_type
, severity
, pe_no
, hose
->global_number
);
778 case OPAL_EEH_IOC_ERROR
:
779 if (severity
== OPAL_EEH_SEV_IOC_DEAD
) {
780 list_for_each_entry_safe(hose
, tmp
,
781 &hose_list
, list_node
) {
782 phb
= hose
->private_data
;
786 WARN(1, "EEH: dead IOC detected\n");
789 } else if (severity
== OPAL_EEH_SEV_INF
)
790 ioda_eeh_hub_diag(hose
);
793 case OPAL_EEH_PHB_ERROR
:
794 if (severity
== OPAL_EEH_SEV_PHB_DEAD
) {
795 if (ioda_eeh_get_phb_pe(hose
, pe
))
798 WARN(1, "EEH: dead PHB#%x detected\n",
799 hose
->global_number
);
803 } else if (severity
== OPAL_EEH_SEV_PHB_FENCED
) {
804 if (ioda_eeh_get_phb_pe(hose
, pe
))
807 WARN(1, "EEH: fenced PHB#%x detected\n",
808 hose
->global_number
);
811 } else if (severity
== OPAL_EEH_SEV_INF
)
812 ioda_eeh_phb_diag(hose
);
815 case OPAL_EEH_PE_ERROR
:
816 if (ioda_eeh_get_pe(hose
, frozen_pe_no
, pe
))
819 WARN(1, "EEH: Frozen PE#%x on PHB#%x detected\n",
820 (*pe
)->addr
, (*pe
)->phb
->global_number
);
831 struct pnv_eeh_ops ioda_eeh_ops
= {
832 .post_init
= ioda_eeh_post_init
,
833 .set_option
= ioda_eeh_set_option
,
834 .get_state
= ioda_eeh_get_state
,
835 .reset
= ioda_eeh_reset
,
836 .get_log
= ioda_eeh_get_log
,
837 .configure_bridge
= ioda_eeh_configure_bridge
,
838 .next_error
= ioda_eeh_next_error