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/list.h>
20 #include <linux/msi.h>
22 #include <linux/pci.h>
23 #include <linux/proc_fs.h>
24 #include <linux/rbtree.h>
25 #include <linux/sched.h>
26 #include <linux/seq_file.h>
27 #include <linux/spinlock.h>
30 #include <asm/eeh_event.h>
31 #include <asm/firmware.h>
33 #include <asm/iommu.h>
34 #include <asm/machdep.h>
35 #include <asm/msi_bitmap.h>
37 #include <asm/ppc-pci.h>
42 static bool pnv_eeh_nb_init
= false;
45 * pnv_eeh_init - EEH platform dependent initialization
47 * EEH platform dependent initialization on powernv
49 static int pnv_eeh_init(void)
51 struct pci_controller
*hose
;
54 /* We require OPALv3 */
55 if (!firmware_has_feature(FW_FEATURE_OPALv3
)) {
56 pr_warn("%s: OPALv3 is required !\n",
62 eeh_add_flag(EEH_PROBE_MODE_DEV
);
65 * P7IOC blocks PCI config access to frozen PE, but PHB3
66 * doesn't do that. So we have to selectively enable I/O
67 * prior to collecting error log.
69 list_for_each_entry(hose
, &hose_list
, list_node
) {
70 phb
= hose
->private_data
;
72 if (phb
->model
== PNV_PHB_MODEL_P7IOC
)
73 eeh_add_flag(EEH_ENABLE_IO_FOR_LOG
);
76 * PE#0 should be regarded as valid by EEH core
77 * if it's not the reserved one. Currently, we
78 * have the reserved PE#0 and PE#127 for PHB3
79 * and P7IOC separately. So we should regard
80 * PE#0 as valid for P7IOC.
82 if (phb
->ioda
.reserved_pe
!= 0)
83 eeh_add_flag(EEH_VALID_PE_ZERO
);
91 static int pnv_eeh_event(struct notifier_block
*nb
,
92 unsigned long events
, void *change
)
94 uint64_t changed_evts
= (uint64_t)change
;
97 * We simply send special EEH event if EEH has
98 * been enabled, or clear pending events in
99 * case that we enable EEH soon
101 if (!(changed_evts
& OPAL_EVENT_PCI_ERROR
) ||
102 !(events
& OPAL_EVENT_PCI_ERROR
))
106 eeh_send_failure_event(NULL
);
108 opal_notifier_update_evt(OPAL_EVENT_PCI_ERROR
, 0x0ul
);
113 static struct notifier_block pnv_eeh_nb
= {
114 .notifier_call
= pnv_eeh_event
,
119 #ifdef CONFIG_DEBUG_FS
120 static ssize_t
pnv_eeh_ei_write(struct file
*filp
,
121 const char __user
*user_buf
,
122 size_t count
, loff_t
*ppos
)
124 struct pci_controller
*hose
= filp
->private_data
;
125 struct eeh_dev
*edev
;
127 int pe_no
, type
, func
;
128 unsigned long addr
, mask
;
132 if (!eeh_ops
|| !eeh_ops
->err_inject
)
135 /* Copy over argument buffer */
136 ret
= simple_write_to_buffer(buf
, sizeof(buf
), ppos
, user_buf
, count
);
140 /* Retrieve parameters */
141 ret
= sscanf(buf
, "%x:%x:%x:%lx:%lx",
142 &pe_no
, &type
, &func
, &addr
, &mask
);
147 edev
= kzalloc(sizeof(*edev
), GFP_KERNEL
);
151 edev
->pe_config_addr
= pe_no
;
152 pe
= eeh_pe_get(edev
);
157 /* Do error injection */
158 ret
= eeh_ops
->err_inject(pe
, type
, func
, addr
, mask
);
159 return ret
< 0 ? ret
: count
;
162 static const struct file_operations pnv_eeh_ei_fops
= {
165 .write
= pnv_eeh_ei_write
,
168 static int pnv_eeh_dbgfs_set(void *data
, int offset
, u64 val
)
170 struct pci_controller
*hose
= data
;
171 struct pnv_phb
*phb
= hose
->private_data
;
173 out_be64(phb
->regs
+ offset
, val
);
177 static int pnv_eeh_dbgfs_get(void *data
, int offset
, u64
*val
)
179 struct pci_controller
*hose
= data
;
180 struct pnv_phb
*phb
= hose
->private_data
;
182 *val
= in_be64(phb
->regs
+ offset
);
186 static int pnv_eeh_outb_dbgfs_set(void *data
, u64 val
)
188 return pnv_eeh_dbgfs_set(data
, 0xD10, val
);
191 static int pnv_eeh_outb_dbgfs_get(void *data
, u64
*val
)
193 return pnv_eeh_dbgfs_get(data
, 0xD10, val
);
196 static int pnv_eeh_inbA_dbgfs_set(void *data
, u64 val
)
198 return pnv_eeh_dbgfs_set(data
, 0xD90, val
);
201 static int pnv_eeh_inbA_dbgfs_get(void *data
, u64
*val
)
203 return pnv_eeh_dbgfs_get(data
, 0xD90, val
);
206 static int pnv_eeh_inbB_dbgfs_set(void *data
, u64 val
)
208 return pnv_eeh_dbgfs_set(data
, 0xE10, val
);
211 static int pnv_eeh_inbB_dbgfs_get(void *data
, u64
*val
)
213 return pnv_eeh_dbgfs_get(data
, 0xE10, val
);
216 DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_outb_dbgfs_ops
, pnv_eeh_outb_dbgfs_get
,
217 pnv_eeh_outb_dbgfs_set
, "0x%llx\n");
218 DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_inbA_dbgfs_ops
, pnv_eeh_inbA_dbgfs_get
,
219 pnv_eeh_inbA_dbgfs_set
, "0x%llx\n");
220 DEFINE_SIMPLE_ATTRIBUTE(pnv_eeh_inbB_dbgfs_ops
, pnv_eeh_inbB_dbgfs_get
,
221 pnv_eeh_inbB_dbgfs_set
, "0x%llx\n");
222 #endif /* CONFIG_DEBUG_FS */
225 * pnv_eeh_post_init - EEH platform dependent post initialization
227 * EEH platform dependent post initialization on powernv. When
228 * the function is called, the EEH PEs and devices should have
229 * been built. If the I/O cache staff has been built, EEH is
230 * ready to supply service.
232 static int pnv_eeh_post_init(void)
234 struct pci_controller
*hose
;
238 /* Register OPAL event notifier */
239 if (!pnv_eeh_nb_init
) {
240 ret
= opal_notifier_register(&pnv_eeh_nb
);
242 pr_warn("%s: Can't register OPAL event notifier (%d)\n",
247 pnv_eeh_nb_init
= true;
250 list_for_each_entry(hose
, &hose_list
, list_node
) {
251 phb
= hose
->private_data
;
254 * If EEH is enabled, we're going to rely on that.
255 * Otherwise, we restore to conventional mechanism
256 * to clear frozen PE during PCI config access.
259 phb
->flags
|= PNV_PHB_FLAG_EEH
;
261 phb
->flags
&= ~PNV_PHB_FLAG_EEH
;
263 /* Create debugfs entries */
264 #ifdef CONFIG_DEBUG_FS
265 if (phb
->has_dbgfs
|| !phb
->dbgfs
)
269 debugfs_create_file("err_injct", 0200,
273 debugfs_create_file("err_injct_outbound", 0600,
275 &pnv_eeh_outb_dbgfs_ops
);
276 debugfs_create_file("err_injct_inboundA", 0600,
278 &pnv_eeh_inbA_dbgfs_ops
);
279 debugfs_create_file("err_injct_inboundB", 0600,
281 &pnv_eeh_inbB_dbgfs_ops
);
282 #endif /* CONFIG_DEBUG_FS */
289 static int pnv_eeh_cap_start(struct pci_dn
*pdn
)
296 pnv_pci_cfg_read(pdn
, PCI_STATUS
, 2, &status
);
297 if (!(status
& PCI_STATUS_CAP_LIST
))
300 return PCI_CAPABILITY_LIST
;
303 static int pnv_eeh_find_cap(struct pci_dn
*pdn
, int cap
)
305 int pos
= pnv_eeh_cap_start(pdn
);
306 int cnt
= 48; /* Maximal number of capabilities */
313 pnv_pci_cfg_read(pdn
, pos
, 1, &pos
);
318 pnv_pci_cfg_read(pdn
, pos
+ PCI_CAP_LIST_ID
, 1, &id
);
327 pos
+= PCI_CAP_LIST_NEXT
;
333 static int pnv_eeh_find_ecap(struct pci_dn
*pdn
, int cap
)
335 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
337 int pos
= 256, ttl
= (4096 - 256) / 8;
339 if (!edev
|| !edev
->pcie_cap
)
341 if (pnv_pci_cfg_read(pdn
, pos
, 4, &header
) != PCIBIOS_SUCCESSFUL
)
347 if (PCI_EXT_CAP_ID(header
) == cap
&& pos
)
350 pos
= PCI_EXT_CAP_NEXT(header
);
354 if (pnv_pci_cfg_read(pdn
, pos
, 4, &header
) != PCIBIOS_SUCCESSFUL
)
362 * pnv_eeh_probe - Do probe on PCI device
363 * @pdn: PCI device node
366 * When EEH module is installed during system boot, all PCI devices
367 * are checked one by one to see if it supports EEH. The function
368 * is introduced for the purpose. By default, EEH has been enabled
369 * on all PCI devices. That's to say, we only need do necessary
370 * initialization on the corresponding eeh device and create PE
373 * It's notable that's unsafe to retrieve the EEH device through
374 * the corresponding PCI device. During the PCI device hotplug, which
375 * was possiblly triggered by EEH core, the binding between EEH device
376 * and the PCI device isn't built yet.
378 static void *pnv_eeh_probe(struct pci_dn
*pdn
, void *data
)
380 struct pci_controller
*hose
= pdn
->phb
;
381 struct pnv_phb
*phb
= hose
->private_data
;
382 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
387 * When probing the root bridge, which doesn't have any
388 * subordinate PCI devices. We don't have OF node for
389 * the root bridge. So it's not reasonable to continue
392 if (!edev
|| edev
->pe
)
395 /* Skip for PCI-ISA bridge */
396 if ((pdn
->class_code
>> 8) == PCI_CLASS_BRIDGE_ISA
)
399 /* Initialize eeh device */
400 edev
->class_code
= pdn
->class_code
;
401 edev
->mode
&= 0xFFFFFF00;
402 edev
->pcix_cap
= pnv_eeh_find_cap(pdn
, PCI_CAP_ID_PCIX
);
403 edev
->pcie_cap
= pnv_eeh_find_cap(pdn
, PCI_CAP_ID_EXP
);
404 edev
->aer_cap
= pnv_eeh_find_ecap(pdn
, PCI_EXT_CAP_ID_ERR
);
405 if ((edev
->class_code
>> 8) == PCI_CLASS_BRIDGE_PCI
) {
406 edev
->mode
|= EEH_DEV_BRIDGE
;
407 if (edev
->pcie_cap
) {
408 pnv_pci_cfg_read(pdn
, edev
->pcie_cap
+ PCI_EXP_FLAGS
,
410 pcie_flags
= (pcie_flags
& PCI_EXP_FLAGS_TYPE
) >> 4;
411 if (pcie_flags
== PCI_EXP_TYPE_ROOT_PORT
)
412 edev
->mode
|= EEH_DEV_ROOT_PORT
;
413 else if (pcie_flags
== PCI_EXP_TYPE_DOWNSTREAM
)
414 edev
->mode
|= EEH_DEV_DS_PORT
;
418 edev
->config_addr
= (pdn
->busno
<< 8) | (pdn
->devfn
);
419 edev
->pe_config_addr
= phb
->ioda
.pe_rmap
[edev
->config_addr
];
422 ret
= eeh_add_to_parent_pe(edev
);
424 pr_warn("%s: Can't add PCI dev %04x:%02x:%02x.%01x to parent PE (%d)\n",
425 __func__
, hose
->global_number
, pdn
->busno
,
426 PCI_SLOT(pdn
->devfn
), PCI_FUNC(pdn
->devfn
), ret
);
431 * If the PE contains any one of following adapters, the
432 * PCI config space can't be accessed when dumping EEH log.
433 * Otherwise, we will run into fenced PHB caused by shortage
434 * of outbound credits in the adapter. The PCI config access
435 * should be blocked until PE reset. MMIO access is dropped
436 * by hardware certainly. In order to drop PCI config requests,
437 * one more flag (EEH_PE_CFG_RESTRICTED) is introduced, which
438 * will be checked in the backend for PE state retrival. If
439 * the PE becomes frozen for the first time and the flag has
440 * been set for the PE, we will set EEH_PE_CFG_BLOCKED for
441 * that PE to block its config space.
443 * Broadcom Austin 4-ports NICs (14e4:1657)
444 * Broadcom Shiner 2-ports 10G NICs (14e4:168e)
446 if ((pdn
->vendor_id
== PCI_VENDOR_ID_BROADCOM
&&
447 pdn
->device_id
== 0x1657) ||
448 (pdn
->vendor_id
== PCI_VENDOR_ID_BROADCOM
&&
449 pdn
->device_id
== 0x168e))
450 edev
->pe
->state
|= EEH_PE_CFG_RESTRICTED
;
453 * Cache the PE primary bus, which can't be fetched when
454 * full hotplug is in progress. In that case, all child
455 * PCI devices of the PE are expected to be removed prior
459 edev
->pe
->bus
= pci_find_bus(hose
->global_number
,
463 * Enable EEH explicitly so that we will do EEH check
464 * while accessing I/O stuff
466 eeh_add_flag(EEH_ENABLED
);
468 /* Save memory bars */
475 * pnv_eeh_set_option - Initialize EEH or MMIO/DMA reenable
477 * @option: operation to be issued
479 * The function is used to control the EEH functionality globally.
480 * Currently, following options are support according to PAPR:
481 * Enable EEH, Disable EEH, Enable MMIO and Enable DMA
483 static int pnv_eeh_set_option(struct eeh_pe
*pe
, int option
)
485 struct pci_controller
*hose
= pe
->phb
;
486 struct pnv_phb
*phb
= hose
->private_data
;
487 bool freeze_pe
= false;
491 /* Sanity check on option */
493 case EEH_OPT_DISABLE
:
497 case EEH_OPT_THAW_MMIO
:
498 opt
= OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO
;
500 case EEH_OPT_THAW_DMA
:
501 opt
= OPAL_EEH_ACTION_CLEAR_FREEZE_DMA
;
503 case EEH_OPT_FREEZE_PE
:
505 opt
= OPAL_EEH_ACTION_SET_FREEZE_ALL
;
508 pr_warn("%s: Invalid option %d\n", __func__
, option
);
512 /* If PHB supports compound PE, to handle it */
514 if (phb
->freeze_pe
) {
515 phb
->freeze_pe(phb
, pe
->addr
);
517 rc
= opal_pci_eeh_freeze_set(phb
->opal_id
,
519 if (rc
!= OPAL_SUCCESS
) {
520 pr_warn("%s: Failure %lld freezing "
523 phb
->hose
->global_number
, pe
->addr
);
528 if (phb
->unfreeze_pe
) {
529 ret
= phb
->unfreeze_pe(phb
, pe
->addr
, opt
);
531 rc
= opal_pci_eeh_freeze_clear(phb
->opal_id
,
533 if (rc
!= OPAL_SUCCESS
) {
534 pr_warn("%s: Failure %lld enable %d "
535 "for PHB#%x-PE#%x\n",
536 __func__
, rc
, option
,
537 phb
->hose
->global_number
, pe
->addr
);
547 * pnv_eeh_get_pe_addr - Retrieve PE address
550 * Retrieve the PE address according to the given tranditional
551 * PCI BDF (Bus/Device/Function) address.
553 static int pnv_eeh_get_pe_addr(struct eeh_pe
*pe
)
558 static void pnv_eeh_get_phb_diag(struct eeh_pe
*pe
)
560 struct pnv_phb
*phb
= pe
->phb
->private_data
;
563 rc
= opal_pci_get_phb_diag_data2(phb
->opal_id
, pe
->data
,
564 PNV_PCI_DIAG_BUF_SIZE
);
565 if (rc
!= OPAL_SUCCESS
)
566 pr_warn("%s: Failure %lld getting PHB#%x diag-data\n",
567 __func__
, rc
, pe
->phb
->global_number
);
570 static int pnv_eeh_get_phb_state(struct eeh_pe
*pe
)
572 struct pnv_phb
*phb
= pe
->phb
->private_data
;
578 rc
= opal_pci_eeh_freeze_status(phb
->opal_id
,
583 if (rc
!= OPAL_SUCCESS
) {
584 pr_warn("%s: Failure %lld getting PHB#%x state\n",
585 __func__
, rc
, phb
->hose
->global_number
);
586 return EEH_STATE_NOT_SUPPORT
;
590 * Check PHB state. If the PHB is frozen for the
591 * first time, to dump the PHB diag-data.
593 if (be16_to_cpu(pcierr
) != OPAL_EEH_PHB_ERROR
) {
594 result
= (EEH_STATE_MMIO_ACTIVE
|
595 EEH_STATE_DMA_ACTIVE
|
596 EEH_STATE_MMIO_ENABLED
|
597 EEH_STATE_DMA_ENABLED
);
598 } else if (!(pe
->state
& EEH_PE_ISOLATED
)) {
599 eeh_pe_state_mark(pe
, EEH_PE_ISOLATED
);
600 pnv_eeh_get_phb_diag(pe
);
602 if (eeh_has_flag(EEH_EARLY_DUMP_LOG
))
603 pnv_pci_dump_phb_diag_data(pe
->phb
, pe
->data
);
609 static int pnv_eeh_get_pe_state(struct eeh_pe
*pe
)
611 struct pnv_phb
*phb
= pe
->phb
->private_data
;
618 * We don't clobber hardware frozen state until PE
619 * reset is completed. In order to keep EEH core
620 * moving forward, we have to return operational
621 * state during PE reset.
623 if (pe
->state
& EEH_PE_RESET
) {
624 result
= (EEH_STATE_MMIO_ACTIVE
|
625 EEH_STATE_DMA_ACTIVE
|
626 EEH_STATE_MMIO_ENABLED
|
627 EEH_STATE_DMA_ENABLED
);
632 * Fetch PE state from hardware. If the PHB
633 * supports compound PE, let it handle that.
635 if (phb
->get_pe_state
) {
636 fstate
= phb
->get_pe_state(phb
, pe
->addr
);
638 rc
= opal_pci_eeh_freeze_status(phb
->opal_id
,
643 if (rc
!= OPAL_SUCCESS
) {
644 pr_warn("%s: Failure %lld getting PHB#%x-PE%x state\n",
645 __func__
, rc
, phb
->hose
->global_number
,
647 return EEH_STATE_NOT_SUPPORT
;
651 /* Figure out state */
653 case OPAL_EEH_STOPPED_NOT_FROZEN
:
654 result
= (EEH_STATE_MMIO_ACTIVE
|
655 EEH_STATE_DMA_ACTIVE
|
656 EEH_STATE_MMIO_ENABLED
|
657 EEH_STATE_DMA_ENABLED
);
659 case OPAL_EEH_STOPPED_MMIO_FREEZE
:
660 result
= (EEH_STATE_DMA_ACTIVE
|
661 EEH_STATE_DMA_ENABLED
);
663 case OPAL_EEH_STOPPED_DMA_FREEZE
:
664 result
= (EEH_STATE_MMIO_ACTIVE
|
665 EEH_STATE_MMIO_ENABLED
);
667 case OPAL_EEH_STOPPED_MMIO_DMA_FREEZE
:
670 case OPAL_EEH_STOPPED_RESET
:
671 result
= EEH_STATE_RESET_ACTIVE
;
673 case OPAL_EEH_STOPPED_TEMP_UNAVAIL
:
674 result
= EEH_STATE_UNAVAILABLE
;
676 case OPAL_EEH_STOPPED_PERM_UNAVAIL
:
677 result
= EEH_STATE_NOT_SUPPORT
;
680 result
= EEH_STATE_NOT_SUPPORT
;
681 pr_warn("%s: Invalid PHB#%x-PE#%x state %x\n",
682 __func__
, phb
->hose
->global_number
,
687 * If PHB supports compound PE, to freeze all
688 * slave PEs for consistency.
690 * If the PE is switching to frozen state for the
691 * first time, to dump the PHB diag-data.
693 if (!(result
& EEH_STATE_NOT_SUPPORT
) &&
694 !(result
& EEH_STATE_UNAVAILABLE
) &&
695 !(result
& EEH_STATE_MMIO_ACTIVE
) &&
696 !(result
& EEH_STATE_DMA_ACTIVE
) &&
697 !(pe
->state
& EEH_PE_ISOLATED
)) {
699 phb
->freeze_pe(phb
, pe
->addr
);
701 eeh_pe_state_mark(pe
, EEH_PE_ISOLATED
);
702 pnv_eeh_get_phb_diag(pe
);
704 if (eeh_has_flag(EEH_EARLY_DUMP_LOG
))
705 pnv_pci_dump_phb_diag_data(pe
->phb
, pe
->data
);
712 * pnv_eeh_get_state - Retrieve PE state
714 * @delay: delay while PE state is temporarily unavailable
716 * Retrieve the state of the specified PE. For IODA-compitable
717 * platform, it should be retrieved from IODA table. Therefore,
718 * we prefer passing down to hardware implementation to handle
721 static int pnv_eeh_get_state(struct eeh_pe
*pe
, int *delay
)
725 if (pe
->type
& EEH_PE_PHB
)
726 ret
= pnv_eeh_get_phb_state(pe
);
728 ret
= pnv_eeh_get_pe_state(pe
);
734 * If the PE state is temporarily unavailable,
735 * to inform the EEH core delay for default
739 if (ret
& EEH_STATE_UNAVAILABLE
)
745 static s64
pnv_eeh_phb_poll(struct pnv_phb
*phb
)
747 s64 rc
= OPAL_HARDWARE
;
750 rc
= opal_pci_poll(phb
->opal_id
);
754 if (system_state
< SYSTEM_RUNNING
)
763 int pnv_eeh_phb_reset(struct pci_controller
*hose
, int option
)
765 struct pnv_phb
*phb
= hose
->private_data
;
766 s64 rc
= OPAL_HARDWARE
;
768 pr_debug("%s: Reset PHB#%x, option=%d\n",
769 __func__
, hose
->global_number
, option
);
771 /* Issue PHB complete reset request */
772 if (option
== EEH_RESET_FUNDAMENTAL
||
773 option
== EEH_RESET_HOT
)
774 rc
= opal_pci_reset(phb
->opal_id
,
775 OPAL_RESET_PHB_COMPLETE
,
777 else if (option
== EEH_RESET_DEACTIVATE
)
778 rc
= opal_pci_reset(phb
->opal_id
,
779 OPAL_RESET_PHB_COMPLETE
,
780 OPAL_DEASSERT_RESET
);
785 * Poll state of the PHB until the request is done
786 * successfully. The PHB reset is usually PHB complete
787 * reset followed by hot reset on root bus. So we also
788 * need the PCI bus settlement delay.
790 rc
= pnv_eeh_phb_poll(phb
);
791 if (option
== EEH_RESET_DEACTIVATE
) {
792 if (system_state
< SYSTEM_RUNNING
)
793 udelay(1000 * EEH_PE_RST_SETTLE_TIME
);
795 msleep(EEH_PE_RST_SETTLE_TIME
);
798 if (rc
!= OPAL_SUCCESS
)
804 static int pnv_eeh_root_reset(struct pci_controller
*hose
, int option
)
806 struct pnv_phb
*phb
= hose
->private_data
;
807 s64 rc
= OPAL_HARDWARE
;
809 pr_debug("%s: Reset PHB#%x, option=%d\n",
810 __func__
, hose
->global_number
, option
);
813 * During the reset deassert time, we needn't care
814 * the reset scope because the firmware does nothing
815 * for fundamental or hot reset during deassert phase.
817 if (option
== EEH_RESET_FUNDAMENTAL
)
818 rc
= opal_pci_reset(phb
->opal_id
,
819 OPAL_RESET_PCI_FUNDAMENTAL
,
821 else if (option
== EEH_RESET_HOT
)
822 rc
= opal_pci_reset(phb
->opal_id
,
825 else if (option
== EEH_RESET_DEACTIVATE
)
826 rc
= opal_pci_reset(phb
->opal_id
,
828 OPAL_DEASSERT_RESET
);
832 /* Poll state of the PHB until the request is done */
833 rc
= pnv_eeh_phb_poll(phb
);
834 if (option
== EEH_RESET_DEACTIVATE
)
835 msleep(EEH_PE_RST_SETTLE_TIME
);
837 if (rc
!= OPAL_SUCCESS
)
843 static int pnv_eeh_bridge_reset(struct pci_dev
*dev
, int option
)
845 struct pci_dn
*pdn
= pci_get_pdn_by_devfn(dev
->bus
, dev
->devfn
);
846 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
847 int aer
= edev
? edev
->aer_cap
: 0;
850 pr_debug("%s: Reset PCI bus %04x:%02x with option %d\n",
851 __func__
, pci_domain_nr(dev
->bus
),
852 dev
->bus
->number
, option
);
855 case EEH_RESET_FUNDAMENTAL
:
857 /* Don't report linkDown event */
859 eeh_ops
->read_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
861 ctrl
|= PCI_ERR_UNC_SURPDN
;
862 eeh_ops
->write_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
866 eeh_ops
->read_config(pdn
, PCI_BRIDGE_CONTROL
, 2, &ctrl
);
867 ctrl
|= PCI_BRIDGE_CTL_BUS_RESET
;
868 eeh_ops
->write_config(pdn
, PCI_BRIDGE_CONTROL
, 2, ctrl
);
870 msleep(EEH_PE_RST_HOLD_TIME
);
872 case EEH_RESET_DEACTIVATE
:
873 eeh_ops
->read_config(pdn
, PCI_BRIDGE_CONTROL
, 2, &ctrl
);
874 ctrl
&= ~PCI_BRIDGE_CTL_BUS_RESET
;
875 eeh_ops
->write_config(pdn
, PCI_BRIDGE_CONTROL
, 2, ctrl
);
877 msleep(EEH_PE_RST_SETTLE_TIME
);
879 /* Continue reporting linkDown event */
881 eeh_ops
->read_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
883 ctrl
&= ~PCI_ERR_UNC_SURPDN
;
884 eeh_ops
->write_config(pdn
, aer
+ PCI_ERR_UNCOR_MASK
,
894 void pnv_pci_reset_secondary_bus(struct pci_dev
*dev
)
896 struct pci_controller
*hose
;
898 if (pci_is_root_bus(dev
->bus
)) {
899 hose
= pci_bus_to_host(dev
->bus
);
900 pnv_eeh_root_reset(hose
, EEH_RESET_HOT
);
901 pnv_eeh_root_reset(hose
, EEH_RESET_DEACTIVATE
);
903 pnv_eeh_bridge_reset(dev
, EEH_RESET_HOT
);
904 pnv_eeh_bridge_reset(dev
, EEH_RESET_DEACTIVATE
);
909 * pnv_eeh_reset - Reset the specified PE
911 * @option: reset option
913 * Do reset on the indicated PE. For PCI bus sensitive PE,
914 * we need to reset the parent p2p bridge. The PHB has to
915 * be reinitialized if the p2p bridge is root bridge. For
916 * PCI device sensitive PE, we will try to reset the device
917 * through FLR. For now, we don't have OPAL APIs to do HARD
918 * reset yet, so all reset would be SOFT (HOT) reset.
920 static int pnv_eeh_reset(struct eeh_pe
*pe
, int option
)
922 struct pci_controller
*hose
= pe
->phb
;
927 * For PHB reset, we always have complete reset. For those PEs whose
928 * primary bus derived from root complex (root bus) or root port
929 * (usually bus#1), we apply hot or fundamental reset on the root port.
930 * For other PEs, we always have hot reset on the PE primary bus.
932 * Here, we have different design to pHyp, which always clear the
933 * frozen state during PE reset. However, the good idea here from
934 * benh is to keep frozen state before we get PE reset done completely
935 * (until BAR restore). With the frozen state, HW drops illegal IO
936 * or MMIO access, which can incur recrusive frozen PE during PE
937 * reset. The side effect is that EEH core has to clear the frozen
938 * state explicitly after BAR restore.
940 if (pe
->type
& EEH_PE_PHB
) {
941 ret
= pnv_eeh_phb_reset(hose
, option
);
947 * The frozen PE might be caused by PAPR error injection
948 * registers, which are expected to be cleared after hitting
949 * frozen PE as stated in the hardware spec. Unfortunately,
950 * that's not true on P7IOC. So we have to clear it manually
951 * to avoid recursive EEH errors during recovery.
953 phb
= hose
->private_data
;
954 if (phb
->model
== PNV_PHB_MODEL_P7IOC
&&
955 (option
== EEH_RESET_HOT
||
956 option
== EEH_RESET_FUNDAMENTAL
)) {
957 rc
= opal_pci_reset(phb
->opal_id
,
958 OPAL_RESET_PHB_ERROR
,
960 if (rc
!= OPAL_SUCCESS
) {
961 pr_warn("%s: Failure %lld clearing "
962 "error injection registers\n",
968 bus
= eeh_pe_bus_get(pe
);
969 if (pci_is_root_bus(bus
) ||
970 pci_is_root_bus(bus
->parent
))
971 ret
= pnv_eeh_root_reset(hose
, option
);
973 ret
= pnv_eeh_bridge_reset(bus
->self
, option
);
980 * pnv_eeh_wait_state - Wait for PE state
982 * @max_wait: maximal period in microsecond
984 * Wait for the state of associated PE. It might take some time
985 * to retrieve the PE's state.
987 static int pnv_eeh_wait_state(struct eeh_pe
*pe
, int max_wait
)
993 ret
= pnv_eeh_get_state(pe
, &mwait
);
996 * If the PE's state is temporarily unavailable,
997 * we have to wait for the specified time. Otherwise,
998 * the PE's state will be returned immediately.
1000 if (ret
!= EEH_STATE_UNAVAILABLE
)
1004 if (max_wait
<= 0) {
1005 pr_warn("%s: Timeout getting PE#%x's state (%d)\n",
1006 __func__
, pe
->addr
, max_wait
);
1007 return EEH_STATE_NOT_SUPPORT
;
1013 return EEH_STATE_NOT_SUPPORT
;
1017 * pnv_eeh_get_log - Retrieve error log
1019 * @severity: temporary or permanent error log
1020 * @drv_log: driver log to be combined with retrieved error log
1021 * @len: length of driver log
1023 * Retrieve the temporary or permanent error from the PE.
1025 static int pnv_eeh_get_log(struct eeh_pe
*pe
, int severity
,
1026 char *drv_log
, unsigned long len
)
1028 if (!eeh_has_flag(EEH_EARLY_DUMP_LOG
))
1029 pnv_pci_dump_phb_diag_data(pe
->phb
, pe
->data
);
1035 * pnv_eeh_configure_bridge - Configure PCI bridges in the indicated PE
1038 * The function will be called to reconfigure the bridges included
1039 * in the specified PE so that the mulfunctional PE would be recovered
1042 static int pnv_eeh_configure_bridge(struct eeh_pe
*pe
)
1048 * pnv_pe_err_inject - Inject specified error to the indicated PE
1049 * @pe: the indicated PE
1051 * @func: specific error type
1053 * @mask: address mask
1055 * The routine is called to inject specified error, which is
1056 * determined by @type and @func, to the indicated PE for
1059 static int pnv_eeh_err_inject(struct eeh_pe
*pe
, int type
, int func
,
1060 unsigned long addr
, unsigned long mask
)
1062 struct pci_controller
*hose
= pe
->phb
;
1063 struct pnv_phb
*phb
= hose
->private_data
;
1066 /* Sanity check on error type */
1067 if (type
!= OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR
&&
1068 type
!= OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64
) {
1069 pr_warn("%s: Invalid error type %d\n",
1074 if (func
< OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR
||
1075 func
> OPAL_ERR_INJECT_FUNC_IOA_DMA_WR_TARGET
) {
1076 pr_warn("%s: Invalid error function %d\n",
1081 /* Firmware supports error injection ? */
1082 if (!opal_check_token(OPAL_PCI_ERR_INJECT
)) {
1083 pr_warn("%s: Firmware doesn't support error injection\n",
1088 /* Do error injection */
1089 rc
= opal_pci_err_inject(phb
->opal_id
, pe
->addr
,
1090 type
, func
, addr
, mask
);
1091 if (rc
!= OPAL_SUCCESS
) {
1092 pr_warn("%s: Failure %lld injecting error "
1093 "%d-%d to PHB#%x-PE#%x\n",
1094 __func__
, rc
, type
, func
,
1095 hose
->global_number
, pe
->addr
);
1102 static inline bool pnv_eeh_cfg_blocked(struct pci_dn
*pdn
)
1104 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
1106 if (!edev
|| !edev
->pe
)
1109 if (edev
->pe
->state
& EEH_PE_CFG_BLOCKED
)
1115 static int pnv_eeh_read_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
)) {
1123 return PCIBIOS_SET_FAILED
;
1126 return pnv_pci_cfg_read(pdn
, where
, size
, val
);
1129 static int pnv_eeh_write_config(struct pci_dn
*pdn
,
1130 int where
, int size
, u32 val
)
1133 return PCIBIOS_DEVICE_NOT_FOUND
;
1135 if (pnv_eeh_cfg_blocked(pdn
))
1136 return PCIBIOS_SET_FAILED
;
1138 return pnv_pci_cfg_write(pdn
, where
, size
, val
);
1141 static void pnv_eeh_dump_hub_diag_common(struct OpalIoP7IOCErrorData
*data
)
1144 if (data
->gemXfir
|| data
->gemRfir
||
1145 data
->gemRirqfir
|| data
->gemMask
|| data
->gemRwof
)
1146 pr_info(" GEM: %016llx %016llx %016llx %016llx %016llx\n",
1147 be64_to_cpu(data
->gemXfir
),
1148 be64_to_cpu(data
->gemRfir
),
1149 be64_to_cpu(data
->gemRirqfir
),
1150 be64_to_cpu(data
->gemMask
),
1151 be64_to_cpu(data
->gemRwof
));
1154 if (data
->lemFir
|| data
->lemErrMask
||
1155 data
->lemAction0
|| data
->lemAction1
|| data
->lemWof
)
1156 pr_info(" LEM: %016llx %016llx %016llx %016llx %016llx\n",
1157 be64_to_cpu(data
->lemFir
),
1158 be64_to_cpu(data
->lemErrMask
),
1159 be64_to_cpu(data
->lemAction0
),
1160 be64_to_cpu(data
->lemAction1
),
1161 be64_to_cpu(data
->lemWof
));
1164 static void pnv_eeh_get_and_dump_hub_diag(struct pci_controller
*hose
)
1166 struct pnv_phb
*phb
= hose
->private_data
;
1167 struct OpalIoP7IOCErrorData
*data
= &phb
->diag
.hub_diag
;
1170 rc
= opal_pci_get_hub_diag_data(phb
->hub_id
, data
, sizeof(*data
));
1171 if (rc
!= OPAL_SUCCESS
) {
1172 pr_warn("%s: Failed to get HUB#%llx diag-data (%ld)\n",
1173 __func__
, phb
->hub_id
, rc
);
1177 switch (data
->type
) {
1178 case OPAL_P7IOC_DIAG_TYPE_RGC
:
1179 pr_info("P7IOC diag-data for RGC\n\n");
1180 pnv_eeh_dump_hub_diag_common(data
);
1181 if (data
->rgc
.rgcStatus
|| data
->rgc
.rgcLdcp
)
1182 pr_info(" RGC: %016llx %016llx\n",
1183 be64_to_cpu(data
->rgc
.rgcStatus
),
1184 be64_to_cpu(data
->rgc
.rgcLdcp
));
1186 case OPAL_P7IOC_DIAG_TYPE_BI
:
1187 pr_info("P7IOC diag-data for BI %s\n\n",
1188 data
->bi
.biDownbound
? "Downbound" : "Upbound");
1189 pnv_eeh_dump_hub_diag_common(data
);
1190 if (data
->bi
.biLdcp0
|| data
->bi
.biLdcp1
||
1191 data
->bi
.biLdcp2
|| data
->bi
.biFenceStatus
)
1192 pr_info(" BI: %016llx %016llx %016llx %016llx\n",
1193 be64_to_cpu(data
->bi
.biLdcp0
),
1194 be64_to_cpu(data
->bi
.biLdcp1
),
1195 be64_to_cpu(data
->bi
.biLdcp2
),
1196 be64_to_cpu(data
->bi
.biFenceStatus
));
1198 case OPAL_P7IOC_DIAG_TYPE_CI
:
1199 pr_info("P7IOC diag-data for CI Port %d\n\n",
1201 pnv_eeh_dump_hub_diag_common(data
);
1202 if (data
->ci
.ciPortStatus
|| data
->ci
.ciPortLdcp
)
1203 pr_info(" CI: %016llx %016llx\n",
1204 be64_to_cpu(data
->ci
.ciPortStatus
),
1205 be64_to_cpu(data
->ci
.ciPortLdcp
));
1207 case OPAL_P7IOC_DIAG_TYPE_MISC
:
1208 pr_info("P7IOC diag-data for MISC\n\n");
1209 pnv_eeh_dump_hub_diag_common(data
);
1211 case OPAL_P7IOC_DIAG_TYPE_I2C
:
1212 pr_info("P7IOC diag-data for I2C\n\n");
1213 pnv_eeh_dump_hub_diag_common(data
);
1216 pr_warn("%s: Invalid type of HUB#%llx diag-data (%d)\n",
1217 __func__
, phb
->hub_id
, data
->type
);
1221 static int pnv_eeh_get_pe(struct pci_controller
*hose
,
1222 u16 pe_no
, struct eeh_pe
**pe
)
1224 struct pnv_phb
*phb
= hose
->private_data
;
1225 struct pnv_ioda_pe
*pnv_pe
;
1226 struct eeh_pe
*dev_pe
;
1227 struct eeh_dev edev
;
1230 * If PHB supports compound PE, to fetch
1231 * the master PE because slave PE is invisible
1234 pnv_pe
= &phb
->ioda
.pe_array
[pe_no
];
1235 if (pnv_pe
->flags
& PNV_IODA_PE_SLAVE
) {
1236 pnv_pe
= pnv_pe
->master
;
1238 !(pnv_pe
->flags
& PNV_IODA_PE_MASTER
));
1239 pe_no
= pnv_pe
->pe_number
;
1242 /* Find the PE according to PE# */
1243 memset(&edev
, 0, sizeof(struct eeh_dev
));
1245 edev
.pe_config_addr
= pe_no
;
1246 dev_pe
= eeh_pe_get(&edev
);
1250 /* Freeze the (compound) PE */
1252 if (!(dev_pe
->state
& EEH_PE_ISOLATED
))
1253 phb
->freeze_pe(phb
, pe_no
);
1256 * At this point, we're sure the (compound) PE should
1257 * have been frozen. However, we still need poke until
1258 * hitting the frozen PE on top level.
1260 dev_pe
= dev_pe
->parent
;
1261 while (dev_pe
&& !(dev_pe
->type
& EEH_PE_PHB
)) {
1263 int active_flags
= (EEH_STATE_MMIO_ACTIVE
|
1264 EEH_STATE_DMA_ACTIVE
);
1266 ret
= eeh_ops
->get_state(dev_pe
, NULL
);
1267 if (ret
<= 0 || (ret
& active_flags
) == active_flags
) {
1268 dev_pe
= dev_pe
->parent
;
1272 /* Frozen parent PE */
1274 if (!(dev_pe
->state
& EEH_PE_ISOLATED
))
1275 phb
->freeze_pe(phb
, dev_pe
->addr
);
1278 dev_pe
= dev_pe
->parent
;
1285 * pnv_eeh_next_error - Retrieve next EEH error to handle
1288 * The function is expected to be called by EEH core while it gets
1289 * special EEH event (without binding PE). The function calls to
1290 * OPAL APIs for next error to handle. The informational error is
1291 * handled internally by platform. However, the dead IOC, dead PHB,
1292 * fenced PHB and frozen PE should be handled by EEH core eventually.
1294 static int pnv_eeh_next_error(struct eeh_pe
**pe
)
1296 struct pci_controller
*hose
;
1297 struct pnv_phb
*phb
;
1298 struct eeh_pe
*phb_pe
, *parent_pe
;
1299 __be64 frozen_pe_no
;
1300 __be16 err_type
, severity
;
1301 int active_flags
= (EEH_STATE_MMIO_ACTIVE
| EEH_STATE_DMA_ACTIVE
);
1303 int state
, ret
= EEH_NEXT_ERR_NONE
;
1306 * While running here, it's safe to purge the event queue.
1307 * And we should keep the cached OPAL notifier event sychronized
1308 * between the kernel and firmware.
1310 eeh_remove_event(NULL
, false);
1311 opal_notifier_update_evt(OPAL_EVENT_PCI_ERROR
, 0x0ul
);
1313 list_for_each_entry(hose
, &hose_list
, list_node
) {
1315 * If the subordinate PCI buses of the PHB has been
1316 * removed or is exactly under error recovery, we
1317 * needn't take care of it any more.
1319 phb
= hose
->private_data
;
1320 phb_pe
= eeh_phb_pe_get(hose
);
1321 if (!phb_pe
|| (phb_pe
->state
& EEH_PE_ISOLATED
))
1324 rc
= opal_pci_next_error(phb
->opal_id
,
1325 &frozen_pe_no
, &err_type
, &severity
);
1326 if (rc
!= OPAL_SUCCESS
) {
1327 pr_devel("%s: Invalid return value on "
1328 "PHB#%x (0x%lx) from opal_pci_next_error",
1329 __func__
, hose
->global_number
, rc
);
1333 /* If the PHB doesn't have error, stop processing */
1334 if (be16_to_cpu(err_type
) == OPAL_EEH_NO_ERROR
||
1335 be16_to_cpu(severity
) == OPAL_EEH_SEV_NO_ERROR
) {
1336 pr_devel("%s: No error found on PHB#%x\n",
1337 __func__
, hose
->global_number
);
1342 * Processing the error. We're expecting the error with
1343 * highest priority reported upon multiple errors on the
1346 pr_devel("%s: Error (%d, %d, %llu) on PHB#%x\n",
1347 __func__
, be16_to_cpu(err_type
),
1348 be16_to_cpu(severity
), be64_to_cpu(frozen_pe_no
),
1349 hose
->global_number
);
1350 switch (be16_to_cpu(err_type
)) {
1351 case OPAL_EEH_IOC_ERROR
:
1352 if (be16_to_cpu(severity
) == OPAL_EEH_SEV_IOC_DEAD
) {
1353 pr_err("EEH: dead IOC detected\n");
1354 ret
= EEH_NEXT_ERR_DEAD_IOC
;
1355 } else if (be16_to_cpu(severity
) == OPAL_EEH_SEV_INF
) {
1356 pr_info("EEH: IOC informative error "
1358 pnv_eeh_get_and_dump_hub_diag(hose
);
1359 ret
= EEH_NEXT_ERR_NONE
;
1363 case OPAL_EEH_PHB_ERROR
:
1364 if (be16_to_cpu(severity
) == OPAL_EEH_SEV_PHB_DEAD
) {
1366 pr_err("EEH: dead PHB#%x detected, "
1368 hose
->global_number
,
1369 eeh_pe_loc_get(phb_pe
));
1370 ret
= EEH_NEXT_ERR_DEAD_PHB
;
1371 } else if (be16_to_cpu(severity
) ==
1372 OPAL_EEH_SEV_PHB_FENCED
) {
1374 pr_err("EEH: Fenced PHB#%x detected, "
1376 hose
->global_number
,
1377 eeh_pe_loc_get(phb_pe
));
1378 ret
= EEH_NEXT_ERR_FENCED_PHB
;
1379 } else if (be16_to_cpu(severity
) == OPAL_EEH_SEV_INF
) {
1380 pr_info("EEH: PHB#%x informative error "
1381 "detected, location: %s\n",
1382 hose
->global_number
,
1383 eeh_pe_loc_get(phb_pe
));
1384 pnv_eeh_get_phb_diag(phb_pe
);
1385 pnv_pci_dump_phb_diag_data(hose
, phb_pe
->data
);
1386 ret
= EEH_NEXT_ERR_NONE
;
1390 case OPAL_EEH_PE_ERROR
:
1392 * If we can't find the corresponding PE, we
1393 * just try to unfreeze.
1395 if (pnv_eeh_get_pe(hose
,
1396 be64_to_cpu(frozen_pe_no
), pe
)) {
1397 /* Try best to clear it */
1398 pr_info("EEH: Clear non-existing PHB#%x-PE#%llx\n",
1399 hose
->global_number
, frozen_pe_no
);
1400 pr_info("EEH: PHB location: %s\n",
1401 eeh_pe_loc_get(phb_pe
));
1402 opal_pci_eeh_freeze_clear(phb
->opal_id
,
1404 OPAL_EEH_ACTION_CLEAR_FREEZE_ALL
);
1405 ret
= EEH_NEXT_ERR_NONE
;
1406 } else if ((*pe
)->state
& EEH_PE_ISOLATED
||
1407 eeh_pe_passed(*pe
)) {
1408 ret
= EEH_NEXT_ERR_NONE
;
1410 pr_err("EEH: Frozen PE#%x "
1411 "on PHB#%x detected\n",
1413 (*pe
)->phb
->global_number
);
1414 pr_err("EEH: PE location: %s, "
1415 "PHB location: %s\n",
1416 eeh_pe_loc_get(*pe
),
1417 eeh_pe_loc_get(phb_pe
));
1418 ret
= EEH_NEXT_ERR_FROZEN_PE
;
1423 pr_warn("%s: Unexpected error type %d\n",
1424 __func__
, be16_to_cpu(err_type
));
1428 * EEH core will try recover from fenced PHB or
1429 * frozen PE. In the time for frozen PE, EEH core
1430 * enable IO path for that before collecting logs,
1431 * but it ruins the site. So we have to dump the
1432 * log in advance here.
1434 if ((ret
== EEH_NEXT_ERR_FROZEN_PE
||
1435 ret
== EEH_NEXT_ERR_FENCED_PHB
) &&
1436 !((*pe
)->state
& EEH_PE_ISOLATED
)) {
1437 eeh_pe_state_mark(*pe
, EEH_PE_ISOLATED
);
1438 pnv_eeh_get_phb_diag(*pe
);
1440 if (eeh_has_flag(EEH_EARLY_DUMP_LOG
))
1441 pnv_pci_dump_phb_diag_data((*pe
)->phb
,
1446 * We probably have the frozen parent PE out there and
1447 * we need have to handle frozen parent PE firstly.
1449 if (ret
== EEH_NEXT_ERR_FROZEN_PE
) {
1450 parent_pe
= (*pe
)->parent
;
1452 /* Hit the ceiling ? */
1453 if (parent_pe
->type
& EEH_PE_PHB
)
1456 /* Frozen parent PE ? */
1457 state
= eeh_ops
->get_state(parent_pe
, NULL
);
1459 (state
& active_flags
) != active_flags
)
1462 /* Next parent level */
1463 parent_pe
= parent_pe
->parent
;
1466 /* We possibly migrate to another PE */
1467 eeh_pe_state_mark(*pe
, EEH_PE_ISOLATED
);
1471 * If we have no errors on the specific PHB or only
1472 * informative error there, we continue poking it.
1473 * Otherwise, we need actions to be taken by upper
1476 if (ret
> EEH_NEXT_ERR_INF
)
1483 static int pnv_eeh_restore_config(struct pci_dn
*pdn
)
1485 struct eeh_dev
*edev
= pdn_to_eeh_dev(pdn
);
1486 struct pnv_phb
*phb
;
1492 phb
= edev
->phb
->private_data
;
1493 ret
= opal_pci_reinit(phb
->opal_id
,
1494 OPAL_REINIT_PCI_DEV
, edev
->config_addr
);
1496 pr_warn("%s: Can't reinit PCI dev 0x%x (%lld)\n",
1497 __func__
, edev
->config_addr
, ret
);
1504 static struct eeh_ops pnv_eeh_ops
= {
1506 .init
= pnv_eeh_init
,
1507 .post_init
= pnv_eeh_post_init
,
1508 .probe
= pnv_eeh_probe
,
1509 .set_option
= pnv_eeh_set_option
,
1510 .get_pe_addr
= pnv_eeh_get_pe_addr
,
1511 .get_state
= pnv_eeh_get_state
,
1512 .reset
= pnv_eeh_reset
,
1513 .wait_state
= pnv_eeh_wait_state
,
1514 .get_log
= pnv_eeh_get_log
,
1515 .configure_bridge
= pnv_eeh_configure_bridge
,
1516 .err_inject
= pnv_eeh_err_inject
,
1517 .read_config
= pnv_eeh_read_config
,
1518 .write_config
= pnv_eeh_write_config
,
1519 .next_error
= pnv_eeh_next_error
,
1520 .restore_config
= pnv_eeh_restore_config
1524 * eeh_powernv_init - Register platform dependent EEH operations
1526 * EEH initialization on powernv platform. This function should be
1527 * called before any EEH related functions.
1529 static int __init
eeh_powernv_init(void)
1533 eeh_set_pe_aux_size(PNV_PCI_DIAG_BUF_SIZE
);
1534 ret
= eeh_ops_register(&pnv_eeh_ops
);
1536 pr_info("EEH: PowerNV platform initialized\n");
1538 pr_info("EEH: Failed to initialize PowerNV platform (%d)\n", ret
);
1542 machine_early_initcall(powernv
, eeh_powernv_init
);