2 * The file intends to implement the platform dependent EEH operations on
3 * powernv platform. Actually, the powernv was created in order to fully
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/atomic.h>
15 #include <linux/debugfs.h>
16 #include <linux/delay.h>
17 #include <linux/export.h>
18 #include <linux/init.h>
19 #include <linux/interrupt.h>
20 #include <linux/list.h>
21 #include <linux/msi.h>
23 #include <linux/pci.h>
24 #include <linux/proc_fs.h>
25 #include <linux/rbtree.h>
26 #include <linux/sched.h>
27 #include <linux/seq_file.h>
28 #include <linux/spinlock.h>
31 #include <asm/eeh_event.h>
32 #include <asm/firmware.h>
34 #include <asm/iommu.h>
35 #include <asm/machdep.h>
36 #include <asm/msi_bitmap.h>
38 #include <asm/ppc-pci.h>
43 static bool pnv_eeh_nb_init
= false;
44 static int eeh_event_irq
= -EINVAL
;
46 static int pnv_eeh_init(void)
48 struct pci_controller
*hose
;
51 if (!firmware_has_feature(FW_FEATURE_OPALv3
)) {
52 pr_warn("%s: OPALv3 is required !\n",
58 eeh_add_flag(EEH_PROBE_MODE_DEV
);
61 * P7IOC blocks PCI config access to frozen PE, but PHB3
62 * doesn't do that. So we have to selectively enable I/O
63 * prior to collecting error log.
65 list_for_each_entry(hose
, &hose_list
, list_node
) {
66 phb
= hose
->private_data
;
68 if (phb
->model
== PNV_PHB_MODEL_P7IOC
)
69 eeh_add_flag(EEH_ENABLE_IO_FOR_LOG
);
72 * PE#0 should be regarded as valid by EEH core
73 * if it's not the reserved one. Currently, we
74 * have the reserved PE#255 and PE#127 for PHB3
75 * and P7IOC separately. So we should regard
76 * PE#0 as valid for PHB3 and P7IOC.
78 if (phb
->ioda
.reserved_pe
!= 0)
79 eeh_add_flag(EEH_VALID_PE_ZERO
);
87 static irqreturn_t
pnv_eeh_event(int irq
, void *data
)
90 * We simply send a special EEH event if EEH has been
91 * enabled. We don't care about EEH events until we've
92 * finished processing the outstanding ones. Event processing
93 * gets unmasked in next_error() if EEH is enabled.
95 disable_irq_nosync(irq
);
98 eeh_send_failure_event(NULL
);
103 #ifdef CONFIG_DEBUG_FS
104 static ssize_t
pnv_eeh_ei_write(struct file
*filp
,
105 const char __user
*user_buf
,
106 size_t count
, loff_t
*ppos
)
108 struct pci_controller
*hose
= filp
->private_data
;
109 struct eeh_dev
*edev
;
111 int pe_no
, type
, func
;
112 unsigned long addr
, mask
;
116 if (!eeh_ops
|| !eeh_ops
->err_inject
)
119 /* Copy over argument buffer */
120 ret
= simple_write_to_buffer(buf
, sizeof(buf
), ppos
, user_buf
, count
);
124 /* Retrieve parameters */
125 ret
= sscanf(buf
, "%x:%x:%x:%lx:%lx",
126 &pe_no
, &type
, &func
, &addr
, &mask
);
131 edev
= kzalloc(sizeof(*edev
), GFP_KERNEL
);
135 edev
->pe_config_addr
= pe_no
;
136 pe
= eeh_pe_get(edev
);
141 /* Do error injection */
142 ret
= eeh_ops
->err_inject(pe
, type
, func
, addr
, mask
);
143 return ret
< 0 ? ret
: count
;
146 static const struct file_operations pnv_eeh_ei_fops
= {
149 .write
= pnv_eeh_ei_write
,
152 static int pnv_eeh_dbgfs_set(void *data
, int offset
, u64 val
)
154 struct pci_controller
*hose
= data
;
155 struct pnv_phb
*phb
= hose
->private_data
;
157 out_be64(phb
->regs
+ offset
, val
);
161 static int pnv_eeh_dbgfs_get(void *data
, int offset
, u64
*val
)
163 struct pci_controller
*hose
= data
;
164 struct pnv_phb
*phb
= hose
->private_data
;
166 *val
= in_be64(phb
->regs
+ offset
);
170 static int pnv_eeh_outb_dbgfs_set(void *data
, u64 val
)
172 return pnv_eeh_dbgfs_set(data
, 0xD10, val
);
175 static int pnv_eeh_outb_dbgfs_get(void *data
, u64
*val
)
177 return pnv_eeh_dbgfs_get(data
, 0xD10, val
);
180 static int pnv_eeh_inbA_dbgfs_set(void *data
, u64 val
)
182 return pnv_eeh_dbgfs_set(data
, 0xD90, val
);
185 static int pnv_eeh_inbA_dbgfs_get(void *data
, u64
*val
)
187 return pnv_eeh_dbgfs_get(data
, 0xD90, val
);
190 static int pnv_eeh_inbB_dbgfs_set(void *data
, u64 val
)
192 return pnv_eeh_dbgfs_set(data
, 0xE10, val
);
195 static int pnv_eeh_inbB_dbgfs_get(void *data
, u64
*val
)
197 return pnv_eeh_dbgfs_get(data
, 0xE10, val
);
200 DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_outb_dbgfs_ops
, pnv_eeh_outb_dbgfs_get
,
201 pnv_eeh_outb_dbgfs_set
, "0x%llx\n");
202 DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_inbA_dbgfs_ops
, pnv_eeh_inbA_dbgfs_get
,
203 pnv_eeh_inbA_dbgfs_set
, "0x%llx\n");
204 DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_inbB_dbgfs_ops
, pnv_eeh_inbB_dbgfs_get
,
205 pnv_eeh_inbB_dbgfs_set
, "0x%llx\n");
206 #endif /* CONFIG_DEBUG_FS */
209 * pnv_eeh_post_init - EEH platform dependent post initialization
211 * EEH platform dependent post initialization on powernv. When
212 * the function is called, the EEH PEs and devices should have
213 * been built. If the I/O cache staff has been built, EEH is
214 * ready to supply service.
216 static int pnv_eeh_post_init(void)
218 struct pci_controller
*hose
;
222 /* Register OPAL event notifier */
223 if (!pnv_eeh_nb_init
) {
224 eeh_event_irq
= opal_event_request(ilog2(OPAL_EVENT_PCI_ERROR
));
225 if (eeh_event_irq
< 0) {
226 pr_err("%s: Can't register OPAL event interrupt (%d)\n",
227 __func__
, eeh_event_irq
);
228 return eeh_event_irq
;
231 ret
= request_irq(eeh_event_irq
, pnv_eeh_event
,
232 IRQ_TYPE_LEVEL_HIGH
, "opal-eeh", NULL
);
234 irq_dispose_mapping(eeh_event_irq
);
235 pr_err("%s: Can't request OPAL event interrupt (%d)\n",
236 __func__
, eeh_event_irq
);
240 pnv_eeh_nb_init
= true;
244 disable_irq(eeh_event_irq
);
246 list_for_each_entry(hose
, &hose_list
, list_node
) {
247 phb
= hose
->private_data
;
250 * If EEH is enabled, we're going to rely on that.
251 * Otherwise, we restore to conventional mechanism
252 * to clear frozen PE during PCI config access.
255 phb
->flags
|= PNV_PHB_FLAG_EEH
;
257 phb
->flags
&= ~PNV_PHB_FLAG_EEH
;
259 /* Create debugfs entries */
260 #ifdef CONFIG_DEBUG_FS
261 if (phb
->has_dbgfs
|| !phb
->dbgfs
)
265 debugfs_create_file("err_injct", 0200,
269 debugfs_create_file("err_injct_outbound", 0600,
271 &pnv_eeh_outb_dbgfs_ops
);
272 debugfs_create_file("err_injct_inboundA", 0600,
274 &pnv_eeh_inbA_dbgfs_ops
);
275 debugfs_create_file("err_injct_inboundB", 0600,
277 &pnv_eeh_inbB_dbgfs_ops
);
278 #endif /* CONFIG_DEBUG_FS */
284 static int pnv_eeh_find_cap(struct pci_dn
*pdn
, int cap
)
286 int pos
= PCI_CAPABILITY_LIST
;
287 int cnt
= 48; /* Maximal number of capabilities */
293 /* Check if the device supports capabilities */
294 pnv_pci_cfg_read(pdn
, PCI_STATUS
, 2, &status
);
295 if (!(status
& PCI_STATUS_CAP_LIST
))
299 pnv_pci_cfg_read(pdn
, pos
, 1, &pos
);
304 pnv_pci_cfg_read(pdn
, pos
+ PCI_CAP_LIST_ID
, 1, &id
);
313 pos
+= PCI_CAP_LIST_NEXT
;
319 static int pnv_eeh_find_ecap(struct pci_dn
*pdn
, int cap
)
321 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
323 int pos
= 256, ttl
= (4096 - 256) / 8;
325 if (!edev
|| !edev
->pcie_cap
)
327 if (pnv_pci_cfg_read(pdn
, pos
, 4, &header
) != PCIBIOS_SUCCESSFUL
)
333 if (PCI_EXT_CAP_ID(header
) == cap
&& pos
)
336 pos
= PCI_EXT_CAP_NEXT(header
);
340 if (pnv_pci_cfg_read(pdn
, pos
, 4, &header
) != PCIBIOS_SUCCESSFUL
)
348 * pnv_eeh_probe - Do probe on PCI device
349 * @pdn: PCI device node
352 * When EEH module is installed during system boot, all PCI devices
353 * are checked one by one to see if it supports EEH. The function
354 * is introduced for the purpose. By default, EEH has been enabled
355 * on all PCI devices. That's to say, we only need do necessary
356 * initialization on the corresponding eeh device and create PE
359 * It's notable that's unsafe to retrieve the EEH device through
360 * the corresponding PCI device. During the PCI device hotplug, which
361 * was possiblly triggered by EEH core, the binding between EEH device
362 * and the PCI device isn't built yet.
364 static void *pnv_eeh_probe(struct pci_dn
*pdn
, void *data
)
366 struct pci_controller
*hose
= pdn
->phb
;
367 struct pnv_phb
*phb
= hose
->private_data
;
368 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
373 * When probing the root bridge, which doesn't have any
374 * subordinate PCI devices. We don't have OF node for
375 * the root bridge. So it's not reasonable to continue
378 if (!edev
|| edev
->pe
)
381 /* Skip for PCI-ISA bridge */
382 if ((pdn
->class_code
>> 8) == PCI_CLASS_BRIDGE_ISA
)
385 /* Initialize eeh device */
386 edev
->class_code
= pdn
->class_code
;
387 edev
->mode
&= 0xFFFFFF00;
388 edev
->pcix_cap
= pnv_eeh_find_cap(pdn
, PCI_CAP_ID_PCIX
);
389 edev
->pcie_cap
= pnv_eeh_find_cap(pdn
, PCI_CAP_ID_EXP
);
390 edev
->aer_cap
= pnv_eeh_find_ecap(pdn
, PCI_EXT_CAP_ID_ERR
);
391 if ((edev
->class_code
>> 8) == PCI_CLASS_BRIDGE_PCI
) {
392 edev
->mode
|= EEH_DEV_BRIDGE
;
393 if (edev
->pcie_cap
) {
394 pnv_pci_cfg_read(pdn
, edev
->pcie_cap
+ PCI_EXP_FLAGS
,
396 pcie_flags
= (pcie_flags
& PCI_EXP_FLAGS_TYPE
) >> 4;
397 if (pcie_flags
== PCI_EXP_TYPE_ROOT_PORT
)
398 edev
->mode
|= EEH_DEV_ROOT_PORT
;
399 else if (pcie_flags
== PCI_EXP_TYPE_DOWNSTREAM
)
400 edev
->mode
|= EEH_DEV_DS_PORT
;
404 edev
->config_addr
= (pdn
->busno
<< 8) | (pdn
->devfn
);
405 edev
->pe_config_addr
= phb
->ioda
.pe_rmap
[edev
->config_addr
];
408 ret
= eeh_add_to_parent_pe(edev
);
410 pr_warn("%s: Can't add PCI dev %04x:%02x:%02x.%01x to parent PE (%d)\n",
411 __func__
, hose
->global_number
, pdn
->busno
,
412 PCI_SLOT(pdn
->devfn
), PCI_FUNC(pdn
->devfn
), ret
);
417 * If the PE contains any one of following adapters, the
418 * PCI config space can't be accessed when dumping EEH log.
419 * Otherwise, we will run into fenced PHB caused by shortage
420 * of outbound credits in the adapter. The PCI config access
421 * should be blocked until PE reset. MMIO access is dropped
422 * by hardware certainly. In order to drop PCI config requests,
423 * one more flag (EEH_PE_CFG_RESTRICTED) is introduced, which
424 * will be checked in the backend for PE state retrival. If
425 * the PE becomes frozen for the first time and the flag has
426 * been set for the PE, we will set EEH_PE_CFG_BLOCKED for
427 * that PE to block its config space.
429 * Broadcom Austin 4-ports NICs (14e4:1657)
430 * Broadcom Shiner 4-ports 1G NICs (14e4:168a)
431 * Broadcom Shiner 2-ports 10G NICs (14e4:168e)
433 if ((pdn
->vendor_id
== PCI_VENDOR_ID_BROADCOM
&&
434 pdn
->device_id
== 0x1657) ||
435 (pdn
->vendor_id
== PCI_VENDOR_ID_BROADCOM
&&
436 pdn
->device_id
== 0x168a) ||
437 (pdn
->vendor_id
== PCI_VENDOR_ID_BROADCOM
&&
438 pdn
->device_id
== 0x168e))
439 edev
->pe
->state
|= EEH_PE_CFG_RESTRICTED
;
442 * Cache the PE primary bus, which can't be fetched when
443 * full hotplug is in progress. In that case, all child
444 * PCI devices of the PE are expected to be removed prior
448 edev
->pe
->bus
= pci_find_bus(hose
->global_number
,
452 * Enable EEH explicitly so that we will do EEH check
453 * while accessing I/O stuff
455 eeh_add_flag(EEH_ENABLED
);
457 /* Save memory bars */
464 * pnv_eeh_set_option - Initialize EEH or MMIO/DMA reenable
466 * @option: operation to be issued
468 * The function is used to control the EEH functionality globally.
469 * Currently, following options are support according to PAPR:
470 * Enable EEH, Disable EEH, Enable MMIO and Enable DMA
472 static int pnv_eeh_set_option(struct eeh_pe
*pe
, int option
)
474 struct pci_controller
*hose
= pe
->phb
;
475 struct pnv_phb
*phb
= hose
->private_data
;
476 bool freeze_pe
= false;
481 case EEH_OPT_DISABLE
:
485 case EEH_OPT_THAW_MMIO
:
486 opt
= OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO
;
488 case EEH_OPT_THAW_DMA
:
489 opt
= OPAL_EEH_ACTION_CLEAR_FREEZE_DMA
;
491 case EEH_OPT_FREEZE_PE
:
493 opt
= OPAL_EEH_ACTION_SET_FREEZE_ALL
;
496 pr_warn("%s: Invalid option %d\n", __func__
, option
);
500 /* Freeze master and slave PEs if PHB supports compound PEs */
502 if (phb
->freeze_pe
) {
503 phb
->freeze_pe(phb
, pe
->addr
);
507 rc
= opal_pci_eeh_freeze_set(phb
->opal_id
, pe
->addr
, opt
);
508 if (rc
!= OPAL_SUCCESS
) {
509 pr_warn("%s: Failure %lld freezing PHB#%x-PE#%x\n",
510 __func__
, rc
, phb
->hose
->global_number
,
518 /* Unfreeze master and slave PEs if PHB supports */
519 if (phb
->unfreeze_pe
)
520 return phb
->unfreeze_pe(phb
, pe
->addr
, opt
);
522 rc
= opal_pci_eeh_freeze_clear(phb
->opal_id
, pe
->addr
, opt
);
523 if (rc
!= OPAL_SUCCESS
) {
524 pr_warn("%s: Failure %lld enable %d for PHB#%x-PE#%x\n",
525 __func__
, rc
, option
, phb
->hose
->global_number
,
534 * pnv_eeh_get_pe_addr - Retrieve PE address
537 * Retrieve the PE address according to the given tranditional
538 * PCI BDF (Bus/Device/Function) address.
540 static int pnv_eeh_get_pe_addr(struct eeh_pe
*pe
)
545 static void pnv_eeh_get_phb_diag(struct eeh_pe
*pe
)
547 struct pnv_phb
*phb
= pe
->phb
->private_data
;
550 rc
= opal_pci_get_phb_diag_data2(phb
->opal_id
, pe
->data
,
551 PNV_PCI_DIAG_BUF_SIZE
);
552 if (rc
!= OPAL_SUCCESS
)
553 pr_warn("%s: Failure %lld getting PHB#%x diag-data\n",
554 __func__
, rc
, pe
->phb
->global_number
);
557 static int pnv_eeh_get_phb_state(struct eeh_pe
*pe
)
559 struct pnv_phb
*phb
= pe
->phb
->private_data
;
565 rc
= opal_pci_eeh_freeze_status(phb
->opal_id
,
570 if (rc
!= OPAL_SUCCESS
) {
571 pr_warn("%s: Failure %lld getting PHB#%x state\n",
572 __func__
, rc
, phb
->hose
->global_number
);
573 return EEH_STATE_NOT_SUPPORT
;
577 * Check PHB state. If the PHB is frozen for the
578 * first time, to dump the PHB diag-data.
580 if (be16_to_cpu(pcierr
) != OPAL_EEH_PHB_ERROR
) {
581 result
= (EEH_STATE_MMIO_ACTIVE
|
582 EEH_STATE_DMA_ACTIVE
|
583 EEH_STATE_MMIO_ENABLED
|
584 EEH_STATE_DMA_ENABLED
);
585 } else if (!(pe
->state
& EEH_PE_ISOLATED
)) {
586 eeh_pe_state_mark(pe
, EEH_PE_ISOLATED
);
587 pnv_eeh_get_phb_diag(pe
);
589 if (eeh_has_flag(EEH_EARLY_DUMP_LOG
))
590 pnv_pci_dump_phb_diag_data(pe
->phb
, pe
->data
);
596 static int pnv_eeh_get_pe_state(struct eeh_pe
*pe
)
598 struct pnv_phb
*phb
= pe
->phb
->private_data
;
605 * We don't clobber hardware frozen state until PE
606 * reset is completed. In order to keep EEH core
607 * moving forward, we have to return operational
608 * state during PE reset.
610 if (pe
->state
& EEH_PE_RESET
) {
611 result
= (EEH_STATE_MMIO_ACTIVE
|
612 EEH_STATE_DMA_ACTIVE
|
613 EEH_STATE_MMIO_ENABLED
|
614 EEH_STATE_DMA_ENABLED
);
619 * Fetch PE state from hardware. If the PHB
620 * supports compound PE, let it handle that.
622 if (phb
->get_pe_state
) {
623 fstate
= phb
->get_pe_state(phb
, pe
->addr
);
625 rc
= opal_pci_eeh_freeze_status(phb
->opal_id
,
630 if (rc
!= OPAL_SUCCESS
) {
631 pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
632 __func__
, rc
, phb
->hose
->global_number
,
634 return EEH_STATE_NOT_SUPPORT
;
638 /* Figure out state */
640 case OPAL_EEH_STOPPED_NOT_FROZEN
:
641 result
= (EEH_STATE_MMIO_ACTIVE
|
642 EEH_STATE_DMA_ACTIVE
|
643 EEH_STATE_MMIO_ENABLED
|
644 EEH_STATE_DMA_ENABLED
);
646 case OPAL_EEH_STOPPED_MMIO_FREEZE
:
647 result
= (EEH_STATE_DMA_ACTIVE
|
648 EEH_STATE_DMA_ENABLED
);
650 case OPAL_EEH_STOPPED_DMA_FREEZE
:
651 result
= (EEH_STATE_MMIO_ACTIVE
|
652 EEH_STATE_MMIO_ENABLED
);
654 case OPAL_EEH_STOPPED_MMIO_DMA_FREEZE
:
657 case OPAL_EEH_STOPPED_RESET
:
658 result
= EEH_STATE_RESET_ACTIVE
;
660 case OPAL_EEH_STOPPED_TEMP_UNAVAIL
:
661 result
= EEH_STATE_UNAVAILABLE
;
663 case OPAL_EEH_STOPPED_PERM_UNAVAIL
:
664 result
= EEH_STATE_NOT_SUPPORT
;
667 result
= EEH_STATE_NOT_SUPPORT
;
668 pr_warn("%s: Invalid PHB#%x-PE#%x state %x\n",
669 __func__
, phb
->hose
->global_number
,
674 * If PHB supports compound PE, to freeze all
675 * slave PEs for consistency.
677 * If the PE is switching to frozen state for the
678 * first time, to dump the PHB diag-data.
680 if (!(result
& EEH_STATE_NOT_SUPPORT
) &&
681 !(result
& EEH_STATE_UNAVAILABLE
) &&
682 !(result
& EEH_STATE_MMIO_ACTIVE
) &&
683 !(result
& EEH_STATE_DMA_ACTIVE
) &&
684 !(pe
->state
& EEH_PE_ISOLATED
)) {
686 phb
->freeze_pe(phb
, pe
->addr
);
688 eeh_pe_state_mark(pe
, EEH_PE_ISOLATED
);
689 pnv_eeh_get_phb_diag(pe
);
691 if (eeh_has_flag(EEH_EARLY_DUMP_LOG
))
692 pnv_pci_dump_phb_diag_data(pe
->phb
, pe
->data
);
699 * pnv_eeh_get_state - Retrieve PE state
701 * @delay: delay while PE state is temporarily unavailable
703 * Retrieve the state of the specified PE. For IODA-compitable
704 * platform, it should be retrieved from IODA table. Therefore,
705 * we prefer passing down to hardware implementation to handle
708 static int pnv_eeh_get_state(struct eeh_pe
*pe
, int *delay
)
712 if (pe
->type
& EEH_PE_PHB
)
713 ret
= pnv_eeh_get_phb_state(pe
);
715 ret
= pnv_eeh_get_pe_state(pe
);
721 * If the PE state is temporarily unavailable,
722 * to inform the EEH core delay for default
726 if (ret
& EEH_STATE_UNAVAILABLE
)
732 static s64
pnv_eeh_phb_poll(struct pnv_phb
*phb
)
734 s64 rc
= OPAL_HARDWARE
;
737 rc
= opal_pci_poll(phb
->opal_id
);
741 if (system_state
< SYSTEM_RUNNING
)
750 int pnv_eeh_phb_reset(struct pci_controller
*hose
, int option
)
752 struct pnv_phb
*phb
= hose
->private_data
;
753 s64 rc
= OPAL_HARDWARE
;
755 pr_debug("%s: Reset PHB#%x, option=%d\n",
756 __func__
, hose
->global_number
, option
);
758 /* Issue PHB complete reset request */
759 if (option
== EEH_RESET_FUNDAMENTAL
||
760 option
== EEH_RESET_HOT
)
761 rc
= opal_pci_reset(phb
->opal_id
,
762 OPAL_RESET_PHB_COMPLETE
,
764 else if (option
== EEH_RESET_DEACTIVATE
)
765 rc
= opal_pci_reset(phb
->opal_id
,
766 OPAL_RESET_PHB_COMPLETE
,
767 OPAL_DEASSERT_RESET
);
772 * Poll state of the PHB until the request is done
773 * successfully. The PHB reset is usually PHB complete
774 * reset followed by hot reset on root bus. So we also
775 * need the PCI bus settlement delay.
777 rc
= pnv_eeh_phb_poll(phb
);
778 if (option
== EEH_RESET_DEACTIVATE
) {
779 if (system_state
< SYSTEM_RUNNING
)
780 udelay(1000 * EEH_PE_RST_SETTLE_TIME
);
782 msleep(EEH_PE_RST_SETTLE_TIME
);
785 if (rc
!= OPAL_SUCCESS
)
791 static int pnv_eeh_root_reset(struct pci_controller
*hose
, int option
)
793 struct pnv_phb
*phb
= hose
->private_data
;
794 s64 rc
= OPAL_HARDWARE
;
796 pr_debug("%s: Reset PHB#%x, option=%d\n",
797 __func__
, hose
->global_number
, option
);
800 * During the reset deassert time, we needn't care
801 * the reset scope because the firmware does nothing
802 * for fundamental or hot reset during deassert phase.
804 if (option
== EEH_RESET_FUNDAMENTAL
)
805 rc
= opal_pci_reset(phb
->opal_id
,
806 OPAL_RESET_PCI_FUNDAMENTAL
,
808 else if (option
== EEH_RESET_HOT
)
809 rc
= opal_pci_reset(phb
->opal_id
,
812 else if (option
== EEH_RESET_DEACTIVATE
)
813 rc
= opal_pci_reset(phb
->opal_id
,
815 OPAL_DEASSERT_RESET
);
819 /* Poll state of the PHB until the request is done */
820 rc
= pnv_eeh_phb_poll(phb
);
821 if (option
== EEH_RESET_DEACTIVATE
)
822 msleep(EEH_PE_RST_SETTLE_TIME
);
824 if (rc
!= OPAL_SUCCESS
)
830 static int pnv_eeh_bridge_reset(struct pci_dev
*dev
, int option
)
832 struct pci_dn
*pdn
= pci_get_pdn_by_devfn(dev
->bus
, dev
->devfn
);
833 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
834 int aer
= edev
? edev
->aer_cap
: 0;
837 pr_debug("%s: Reset PCI bus %04x:%02x with option %d\n",
838 __func__
, pci_domain_nr(dev
->bus
),
839 dev
->bus
->number
, option
);
842 case EEH_RESET_FUNDAMENTAL
:
844 /* Don't report linkDown event */
846 eeh_ops
->read_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
848 ctrl
|= PCI_ERR_UNC_SURPDN
;
849 eeh_ops
->write_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
853 eeh_ops
->read_config(pdn
, PCI_BRIDGE_CONTROL
, 2, &ctrl
);
854 ctrl
|= PCI_BRIDGE_CTL_BUS_RESET
;
855 eeh_ops
->write_config(pdn
, PCI_BRIDGE_CONTROL
, 2, ctrl
);
857 msleep(EEH_PE_RST_HOLD_TIME
);
859 case EEH_RESET_DEACTIVATE
:
860 eeh_ops
->read_config(pdn
, PCI_BRIDGE_CONTROL
, 2, &ctrl
);
861 ctrl
&= ~PCI_BRIDGE_CTL_BUS_RESET
;
862 eeh_ops
->write_config(pdn
, PCI_BRIDGE_CONTROL
, 2, ctrl
);
864 msleep(EEH_PE_RST_SETTLE_TIME
);
866 /* Continue reporting linkDown event */
868 eeh_ops
->read_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
870 ctrl
&= ~PCI_ERR_UNC_SURPDN
;
871 eeh_ops
->write_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
881 void pnv_pci_reset_secondary_bus(struct pci_dev
*dev
)
883 struct pci_controller
*hose
;
885 if (pci_is_root_bus(dev
->bus
)) {
886 hose
= pci_bus_to_host(dev
->bus
);
887 pnv_eeh_root_reset(hose
, EEH_RESET_HOT
);
888 pnv_eeh_root_reset(hose
, EEH_RESET_DEACTIVATE
);
890 pnv_eeh_bridge_reset(dev
, EEH_RESET_HOT
);
891 pnv_eeh_bridge_reset(dev
, EEH_RESET_DEACTIVATE
);
896 * pnv_eeh_reset - Reset the specified PE
898 * @option: reset option
900 * Do reset on the indicated PE. For PCI bus sensitive PE,
901 * we need to reset the parent p2p bridge. The PHB has to
902 * be reinitialized if the p2p bridge is root bridge. For
903 * PCI device sensitive PE, we will try to reset the device
904 * through FLR. For now, we don't have OPAL APIs to do HARD
905 * reset yet, so all reset would be SOFT (HOT) reset.
907 static int pnv_eeh_reset(struct eeh_pe
*pe
, int option
)
909 struct pci_controller
*hose
= pe
->phb
;
914 * For PHB reset, we always have complete reset. For those PEs whose
915 * primary bus derived from root complex (root bus) or root port
916 * (usually bus#1), we apply hot or fundamental reset on the root port.
917 * For other PEs, we always have hot reset on the PE primary bus.
919 * Here, we have different design to pHyp, which always clear the
920 * frozen state during PE reset. However, the good idea here from
921 * benh is to keep frozen state before we get PE reset done completely
922 * (until BAR restore). With the frozen state, HW drops illegal IO
923 * or MMIO access, which can incur recrusive frozen PE during PE
924 * reset. The side effect is that EEH core has to clear the frozen
925 * state explicitly after BAR restore.
927 if (pe
->type
& EEH_PE_PHB
) {
928 ret
= pnv_eeh_phb_reset(hose
, option
);
934 * The frozen PE might be caused by PAPR error injection
935 * registers, which are expected to be cleared after hitting
936 * frozen PE as stated in the hardware spec. Unfortunately,
937 * that's not true on P7IOC. So we have to clear it manually
938 * to avoid recursive EEH errors during recovery.
940 phb
= hose
->private_data
;
941 if (phb
->model
== PNV_PHB_MODEL_P7IOC
&&
942 (option
== EEH_RESET_HOT
||
943 option
== EEH_RESET_FUNDAMENTAL
)) {
944 rc
= opal_pci_reset(phb
->opal_id
,
945 OPAL_RESET_PHB_ERROR
,
947 if (rc
!= OPAL_SUCCESS
) {
948 pr_warn("%s: Failure %lld clearing "
949 "error injection registers\n",
955 bus
= eeh_pe_bus_get(pe
);
956 if (pci_is_root_bus(bus
) ||
957 pci_is_root_bus(bus
->parent
))
958 ret
= pnv_eeh_root_reset(hose
, option
);
960 ret
= pnv_eeh_bridge_reset(bus
->self
, option
);
967 * pnv_eeh_wait_state - Wait for PE state
969 * @max_wait: maximal period in millisecond
971 * Wait for the state of associated PE. It might take some time
972 * to retrieve the PE's state.
974 static int pnv_eeh_wait_state(struct eeh_pe
*pe
, int max_wait
)
980 ret
= pnv_eeh_get_state(pe
, &mwait
);
983 * If the PE's state is temporarily unavailable,
984 * we have to wait for the specified time. Otherwise,
985 * the PE's state will be returned immediately.
987 if (ret
!= EEH_STATE_UNAVAILABLE
)
991 pr_warn("%s: Timeout getting PE#%x's state (%d)\n",
992 __func__
, pe
->addr
, max_wait
);
993 return EEH_STATE_NOT_SUPPORT
;
1000 return EEH_STATE_NOT_SUPPORT
;
1004 * pnv_eeh_get_log - Retrieve error log
1006 * @severity: temporary or permanent error log
1007 * @drv_log: driver log to be combined with retrieved error log
1008 * @len: length of driver log
1010 * Retrieve the temporary or permanent error from the PE.
1012 static int pnv_eeh_get_log(struct eeh_pe
*pe
, int severity
,
1013 char *drv_log
, unsigned long len
)
1015 if (!eeh_has_flag(EEH_EARLY_DUMP_LOG
))
1016 pnv_pci_dump_phb_diag_data(pe
->phb
, pe
->data
);
1022 * pnv_eeh_configure_bridge - Configure PCI bridges in the indicated PE
1025 * The function will be called to reconfigure the bridges included
1026 * in the specified PE so that the mulfunctional PE would be recovered
1029 static int pnv_eeh_configure_bridge(struct eeh_pe
*pe
)
1035 * pnv_pe_err_inject - Inject specified error to the indicated PE
1036 * @pe: the indicated PE
1038 * @func: specific error type
1040 * @mask: address mask
1042 * The routine is called to inject specified error, which is
1043 * determined by @type and @func, to the indicated PE for
1046 static int pnv_eeh_err_inject(struct eeh_pe
*pe
, int type
, int func
,
1047 unsigned long addr
, unsigned long mask
)
1049 struct pci_controller
*hose
= pe
->phb
;
1050 struct pnv_phb
*phb
= hose
->private_data
;
1053 if (type
!= OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR
&&
1054 type
!= OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64
) {
1055 pr_warn("%s: Invalid error type %d\n",
1060 if (func
< OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR
||
1061 func
> OPAL_ERR_INJECT_FUNC_IOA_DMA_WR_TARGET
) {
1062 pr_warn("%s: Invalid error function %d\n",
1067 /* Firmware supports error injection ? */
1068 if (!opal_check_token(OPAL_PCI_ERR_INJECT
)) {
1069 pr_warn("%s: Firmware doesn't support error injection\n",
1074 /* Do error injection */
1075 rc
= opal_pci_err_inject(phb
->opal_id
, pe
->addr
,
1076 type
, func
, addr
, mask
);
1077 if (rc
!= OPAL_SUCCESS
) {
1078 pr_warn("%s: Failure %lld injecting error "
1079 "%d-%d to PHB#%x-PE#%x\n",
1080 __func__
, rc
, type
, func
,
1081 hose
->global_number
, pe
->addr
);
1088 static inline bool pnv_eeh_cfg_blocked(struct pci_dn
*pdn
)
1090 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
1092 if (!edev
|| !edev
->pe
)
1095 if (edev
->pe
->state
& EEH_PE_CFG_BLOCKED
)
1101 static int pnv_eeh_read_config(struct pci_dn
*pdn
,
1102 int where
, int size
, u32
*val
)
1105 return PCIBIOS_DEVICE_NOT_FOUND
;
1107 if (pnv_eeh_cfg_blocked(pdn
)) {
1109 return PCIBIOS_SET_FAILED
;
1112 return pnv_pci_cfg_read(pdn
, where
, size
, val
);
1115 static int pnv_eeh_write_config(struct pci_dn
*pdn
,
1116 int where
, int size
, u32 val
)
1119 return PCIBIOS_DEVICE_NOT_FOUND
;
1121 if (pnv_eeh_cfg_blocked(pdn
))
1122 return PCIBIOS_SET_FAILED
;
1124 return pnv_pci_cfg_write(pdn
, where
, size
, val
);
1127 static void pnv_eeh_dump_hub_diag_common(struct OpalIoP7IOCErrorData
*data
)
1130 if (data
->gemXfir
|| data
->gemRfir
||
1131 data
->gemRirqfir
|| data
->gemMask
|| data
->gemRwof
)
1132 pr_info(" GEM: %016llx %016llx %016llx %016llx %016llx\n",
1133 be64_to_cpu(data
->gemXfir
),
1134 be64_to_cpu(data
->gemRfir
),
1135 be64_to_cpu(data
->gemRirqfir
),
1136 be64_to_cpu(data
->gemMask
),
1137 be64_to_cpu(data
->gemRwof
));
1140 if (data
->lemFir
|| data
->lemErrMask
||
1141 data
->lemAction0
|| data
->lemAction1
|| data
->lemWof
)
1142 pr_info(" LEM: %016llx %016llx %016llx %016llx %016llx\n",
1143 be64_to_cpu(data
->lemFir
),
1144 be64_to_cpu(data
->lemErrMask
),
1145 be64_to_cpu(data
->lemAction0
),
1146 be64_to_cpu(data
->lemAction1
),
1147 be64_to_cpu(data
->lemWof
));
1150 static void pnv_eeh_get_and_dump_hub_diag(struct pci_controller
*hose
)
1152 struct pnv_phb
*phb
= hose
->private_data
;
1153 struct OpalIoP7IOCErrorData
*data
= &phb
->diag
.hub_diag
;
1156 rc
= opal_pci_get_hub_diag_data(phb
->hub_id
, data
, sizeof(*data
));
1157 if (rc
!= OPAL_SUCCESS
) {
1158 pr_warn("%s: Failed to get HUB#%llx diag-data (%ld)\n",
1159 __func__
, phb
->hub_id
, rc
);
1163 switch (data
->type
) {
1164 case OPAL_P7IOC_DIAG_TYPE_RGC
:
1165 pr_info("P7IOC diag-data for RGC\n\n");
1166 pnv_eeh_dump_hub_diag_common(data
);
1167 if (data
->rgc
.rgcStatus
|| data
->rgc
.rgcLdcp
)
1168 pr_info(" RGC: %016llx %016llx\n",
1169 be64_to_cpu(data
->rgc
.rgcStatus
),
1170 be64_to_cpu(data
->rgc
.rgcLdcp
));
1172 case OPAL_P7IOC_DIAG_TYPE_BI
:
1173 pr_info("P7IOC diag-data for BI %s\n\n",
1174 data
->bi
.biDownbound
? "Downbound" : "Upbound");
1175 pnv_eeh_dump_hub_diag_common(data
);
1176 if (data
->bi
.biLdcp0
|| data
->bi
.biLdcp1
||
1177 data
->bi
.biLdcp2
|| data
->bi
.biFenceStatus
)
1178 pr_info(" BI: %016llx %016llx %016llx %016llx\n",
1179 be64_to_cpu(data
->bi
.biLdcp0
),
1180 be64_to_cpu(data
->bi
.biLdcp1
),
1181 be64_to_cpu(data
->bi
.biLdcp2
),
1182 be64_to_cpu(data
->bi
.biFenceStatus
));
1184 case OPAL_P7IOC_DIAG_TYPE_CI
:
1185 pr_info("P7IOC diag-data for CI Port %d\n\n",
1187 pnv_eeh_dump_hub_diag_common(data
);
1188 if (data
->ci
.ciPortStatus
|| data
->ci
.ciPortLdcp
)
1189 pr_info(" CI: %016llx %016llx\n",
1190 be64_to_cpu(data
->ci
.ciPortStatus
),
1191 be64_to_cpu(data
->ci
.ciPortLdcp
));
1193 case OPAL_P7IOC_DIAG_TYPE_MISC
:
1194 pr_info("P7IOC diag-data for MISC\n\n");
1195 pnv_eeh_dump_hub_diag_common(data
);
1197 case OPAL_P7IOC_DIAG_TYPE_I2C
:
1198 pr_info("P7IOC diag-data for I2C\n\n");
1199 pnv_eeh_dump_hub_diag_common(data
);
1202 pr_warn("%s: Invalid type of HUB#%llx diag-data (%d)\n",
1203 __func__
, phb
->hub_id
, data
->type
);
1207 static int pnv_eeh_get_pe(struct pci_controller
*hose
,
1208 u16 pe_no
, struct eeh_pe
**pe
)
1210 struct pnv_phb
*phb
= hose
->private_data
;
1211 struct pnv_ioda_pe
*pnv_pe
;
1212 struct eeh_pe
*dev_pe
;
1213 struct eeh_dev edev
;
1216 * If PHB supports compound PE, to fetch
1217 * the master PE because slave PE is invisible
1220 pnv_pe
= &phb
->ioda
.pe_array
[pe_no
];
1221 if (pnv_pe
->flags
& PNV_IODA_PE_SLAVE
) {
1222 pnv_pe
= pnv_pe
->master
;
1224 !(pnv_pe
->flags
& PNV_IODA_PE_MASTER
));
1225 pe_no
= pnv_pe
->pe_number
;
1228 /* Find the PE according to PE# */
1229 memset(&edev
, 0, sizeof(struct eeh_dev
));
1231 edev
.pe_config_addr
= pe_no
;
1232 dev_pe
= eeh_pe_get(&edev
);
1236 /* Freeze the (compound) PE */
1238 if (!(dev_pe
->state
& EEH_PE_ISOLATED
))
1239 phb
->freeze_pe(phb
, pe_no
);
1242 * At this point, we're sure the (compound) PE should
1243 * have been frozen. However, we still need poke until
1244 * hitting the frozen PE on top level.
1246 dev_pe
= dev_pe
->parent
;
1247 while (dev_pe
&& !(dev_pe
->type
& EEH_PE_PHB
)) {
1249 int active_flags
= (EEH_STATE_MMIO_ACTIVE
|
1250 EEH_STATE_DMA_ACTIVE
);
1252 ret
= eeh_ops
->get_state(dev_pe
, NULL
);
1253 if (ret
<= 0 || (ret
& active_flags
) == active_flags
) {
1254 dev_pe
= dev_pe
->parent
;
1258 /* Frozen parent PE */
1260 if (!(dev_pe
->state
& EEH_PE_ISOLATED
))
1261 phb
->freeze_pe(phb
, dev_pe
->addr
);
1264 dev_pe
= dev_pe
->parent
;
1271 * pnv_eeh_next_error - Retrieve next EEH error to handle
1274 * The function is expected to be called by EEH core while it gets
1275 * special EEH event (without binding PE). The function calls to
1276 * OPAL APIs for next error to handle. The informational error is
1277 * handled internally by platform. However, the dead IOC, dead PHB,
1278 * fenced PHB and frozen PE should be handled by EEH core eventually.
1280 static int pnv_eeh_next_error(struct eeh_pe
**pe
)
1282 struct pci_controller
*hose
;
1283 struct pnv_phb
*phb
;
1284 struct eeh_pe
*phb_pe
, *parent_pe
;
1285 __be64 frozen_pe_no
;
1286 __be16 err_type
, severity
;
1287 int active_flags
= (EEH_STATE_MMIO_ACTIVE
| EEH_STATE_DMA_ACTIVE
);
1289 int state
, ret
= EEH_NEXT_ERR_NONE
;
1292 * While running here, it's safe to purge the event queue. The
1293 * event should still be masked.
1295 eeh_remove_event(NULL
, false);
1297 list_for_each_entry(hose
, &hose_list
, list_node
) {
1299 * If the subordinate PCI buses of the PHB has been
1300 * removed or is exactly under error recovery, we
1301 * needn't take care of it any more.
1303 phb
= hose
->private_data
;
1304 phb_pe
= eeh_phb_pe_get(hose
);
1305 if (!phb_pe
|| (phb_pe
->state
& EEH_PE_ISOLATED
))
1308 rc
= opal_pci_next_error(phb
->opal_id
,
1309 &frozen_pe_no
, &err_type
, &severity
);
1310 if (rc
!= OPAL_SUCCESS
) {
1311 pr_devel("%s: Invalid return value on "
1312 "PHB#%x (0x%lx) from opal_pci_next_error",
1313 __func__
, hose
->global_number
, rc
);
1317 /* If the PHB doesn't have error, stop processing */
1318 if (be16_to_cpu(err_type
) == OPAL_EEH_NO_ERROR
||
1319 be16_to_cpu(severity
) == OPAL_EEH_SEV_NO_ERROR
) {
1320 pr_devel("%s: No error found on PHB#%x\n",
1321 __func__
, hose
->global_number
);
1326 * Processing the error. We're expecting the error with
1327 * highest priority reported upon multiple errors on the
1330 pr_devel("%s: Error (%d, %d, %llu) on PHB#%x\n",
1331 __func__
, be16_to_cpu(err_type
),
1332 be16_to_cpu(severity
), be64_to_cpu(frozen_pe_no
),
1333 hose
->global_number
);
1334 switch (be16_to_cpu(err_type
)) {
1335 case OPAL_EEH_IOC_ERROR
:
1336 if (be16_to_cpu(severity
) == OPAL_EEH_SEV_IOC_DEAD
) {
1337 pr_err("EEH: dead IOC detected\n");
1338 ret
= EEH_NEXT_ERR_DEAD_IOC
;
1339 } else if (be16_to_cpu(severity
) == OPAL_EEH_SEV_INF
) {
1340 pr_info("EEH: IOC informative error "
1342 pnv_eeh_get_and_dump_hub_diag(hose
);
1343 ret
= EEH_NEXT_ERR_NONE
;
1347 case OPAL_EEH_PHB_ERROR
:
1348 if (be16_to_cpu(severity
) == OPAL_EEH_SEV_PHB_DEAD
) {
1350 pr_err("EEH: dead PHB#%x detected, "
1352 hose
->global_number
,
1353 eeh_pe_loc_get(phb_pe
));
1354 ret
= EEH_NEXT_ERR_DEAD_PHB
;
1355 } else if (be16_to_cpu(severity
) ==
1356 OPAL_EEH_SEV_PHB_FENCED
) {
1358 pr_err("EEH: Fenced PHB#%x detected, "
1360 hose
->global_number
,
1361 eeh_pe_loc_get(phb_pe
));
1362 ret
= EEH_NEXT_ERR_FENCED_PHB
;
1363 } else if (be16_to_cpu(severity
) == OPAL_EEH_SEV_INF
) {
1364 pr_info("EEH: PHB#%x informative error "
1365 "detected, location: %s\n",
1366 hose
->global_number
,
1367 eeh_pe_loc_get(phb_pe
));
1368 pnv_eeh_get_phb_diag(phb_pe
);
1369 pnv_pci_dump_phb_diag_data(hose
, phb_pe
->data
);
1370 ret
= EEH_NEXT_ERR_NONE
;
1374 case OPAL_EEH_PE_ERROR
:
1376 * If we can't find the corresponding PE, we
1377 * just try to unfreeze.
1379 if (pnv_eeh_get_pe(hose
,
1380 be64_to_cpu(frozen_pe_no
), pe
)) {
1381 pr_info("EEH: Clear non-existing PHB#%x-PE#%llx\n",
1382 hose
->global_number
, be64_to_cpu(frozen_pe_no
));
1383 pr_info("EEH: PHB location: %s\n",
1384 eeh_pe_loc_get(phb_pe
));
1386 /* Dump PHB diag-data */
1387 rc
= opal_pci_get_phb_diag_data2(phb
->opal_id
,
1388 phb
->diag
.blob
, PNV_PCI_DIAG_BUF_SIZE
);
1389 if (rc
== OPAL_SUCCESS
)
1390 pnv_pci_dump_phb_diag_data(hose
,
1393 /* Try best to clear it */
1394 opal_pci_eeh_freeze_clear(phb
->opal_id
,
1396 OPAL_EEH_ACTION_CLEAR_FREEZE_ALL
);
1397 ret
= EEH_NEXT_ERR_NONE
;
1398 } else if ((*pe
)->state
& EEH_PE_ISOLATED
||
1399 eeh_pe_passed(*pe
)) {
1400 ret
= EEH_NEXT_ERR_NONE
;
1402 pr_err("EEH: Frozen PE#%x "
1403 "on PHB#%x detected\n",
1405 (*pe
)->phb
->global_number
);
1406 pr_err("EEH: PE location: %s, "
1407 "PHB location: %s\n",
1408 eeh_pe_loc_get(*pe
),
1409 eeh_pe_loc_get(phb_pe
));
1410 ret
= EEH_NEXT_ERR_FROZEN_PE
;
1415 pr_warn("%s: Unexpected error type %d\n",
1416 __func__
, be16_to_cpu(err_type
));
1420 * EEH core will try recover from fenced PHB or
1421 * frozen PE. In the time for frozen PE, EEH core
1422 * enable IO path for that before collecting logs,
1423 * but it ruins the site. So we have to dump the
1424 * log in advance here.
1426 if ((ret
== EEH_NEXT_ERR_FROZEN_PE
||
1427 ret
== EEH_NEXT_ERR_FENCED_PHB
) &&
1428 !((*pe
)->state
& EEH_PE_ISOLATED
)) {
1429 eeh_pe_state_mark(*pe
, EEH_PE_ISOLATED
);
1430 pnv_eeh_get_phb_diag(*pe
);
1432 if (eeh_has_flag(EEH_EARLY_DUMP_LOG
))
1433 pnv_pci_dump_phb_diag_data((*pe
)->phb
,
1438 * We probably have the frozen parent PE out there and
1439 * we need have to handle frozen parent PE firstly.
1441 if (ret
== EEH_NEXT_ERR_FROZEN_PE
) {
1442 parent_pe
= (*pe
)->parent
;
1444 /* Hit the ceiling ? */
1445 if (parent_pe
->type
& EEH_PE_PHB
)
1448 /* Frozen parent PE ? */
1449 state
= eeh_ops
->get_state(parent_pe
, NULL
);
1451 (state
& active_flags
) != active_flags
)
1454 /* Next parent level */
1455 parent_pe
= parent_pe
->parent
;
1458 /* We possibly migrate to another PE */
1459 eeh_pe_state_mark(*pe
, EEH_PE_ISOLATED
);
1463 * If we have no errors on the specific PHB or only
1464 * informative error there, we continue poking it.
1465 * Otherwise, we need actions to be taken by upper
1468 if (ret
> EEH_NEXT_ERR_INF
)
1472 /* Unmask the event */
1473 if (ret
== EEH_NEXT_ERR_NONE
&& eeh_enabled())
1474 enable_irq(eeh_event_irq
);
1479 static int pnv_eeh_restore_config(struct pci_dn
*pdn
)
1481 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
1482 struct pnv_phb
*phb
;
1488 phb
= edev
->phb
->private_data
;
1489 ret
= opal_pci_reinit(phb
->opal_id
,
1490 OPAL_REINIT_PCI_DEV
, edev
->config_addr
);
1492 pr_warn("%s: Can't reinit PCI dev 0x%x (%lld)\n",
1493 __func__
, edev
->config_addr
, ret
);
1500 static struct eeh_ops pnv_eeh_ops
= {
1502 .init
= pnv_eeh_init
,
1503 .post_init
= pnv_eeh_post_init
,
1504 .probe
= pnv_eeh_probe
,
1505 .set_option
= pnv_eeh_set_option
,
1506 .get_pe_addr
= pnv_eeh_get_pe_addr
,
1507 .get_state
= pnv_eeh_get_state
,
1508 .reset
= pnv_eeh_reset
,
1509 .wait_state
= pnv_eeh_wait_state
,
1510 .get_log
= pnv_eeh_get_log
,
1511 .configure_bridge
= pnv_eeh_configure_bridge
,
1512 .err_inject
= pnv_eeh_err_inject
,
1513 .read_config
= pnv_eeh_read_config
,
1514 .write_config
= pnv_eeh_write_config
,
1515 .next_error
= pnv_eeh_next_error
,
1516 .restore_config
= pnv_eeh_restore_config
1520 * eeh_powernv_init - Register platform dependent EEH operations
1522 * EEH initialization on powernv platform. This function should be
1523 * called before any EEH related functions.
1525 static int __init
eeh_powernv_init(void)
1529 eeh_set_pe_aux_size(PNV_PCI_DIAG_BUF_SIZE
);
1530 ret
= eeh_ops_register(&pnv_eeh_ops
);
1532 pr_info("EEH: PowerNV platform initialized\n");
1534 pr_info("EEH: Failed to initialize PowerNV platform (%d)\n", ret
);
1538 machine_early_initcall(powernv
, eeh_powernv_init
);