Lines Matching full:pe
89 * PE would be created there.
95 * EEH allowed maximal frozen times. If one particular PE's
96 * frozen count in last hour exceeds this limit, the PE will
137 u64 slot_resets; /* PE reset */
176 edev->pe->phb->global_number, edev->bdfn >> 8, in eeh_dump_dev_log()
179 edev->pe->phb->global_number, edev->bdfn >> 8, in eeh_dump_dev_log()
269 static void *eeh_dump_pe_log(struct eeh_pe *pe, void *flag) in eeh_dump_pe_log() argument
274 eeh_pe_for_each_dev(pe, edev, tmp) in eeh_dump_pe_log()
283 * @pe: EEH PE
291 void eeh_slot_error_detail(struct eeh_pe *pe, int severity) in eeh_slot_error_detail() argument
304 * When the @severity is EEH_LOG_PERM, the PE is going to be in eeh_slot_error_detail()
306 * the PE will be closed. The drivers rely on working IO path in eeh_slot_error_detail()
311 if (!(pe->type & EEH_PE_PHB)) { in eeh_slot_error_detail()
314 eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); in eeh_slot_error_detail()
321 * is set automatically when the PE is put to EEH_PE_ISOLATED. in eeh_slot_error_detail()
328 eeh_ops->configure_bridge(pe); in eeh_slot_error_detail()
329 if (!(pe->state & EEH_PE_CFG_BLOCKED)) { in eeh_slot_error_detail()
330 eeh_pe_restore_bars(pe); in eeh_slot_error_detail()
333 eeh_pe_traverse(pe, eeh_dump_pe_log, &loglen); in eeh_slot_error_detail()
337 eeh_ops->get_log(pe, severity, pci_regs_buf, loglen); in eeh_slot_error_detail()
354 * For that case, it's meaningless to recover frozen PE. Intead,
357 static int eeh_phb_check_failure(struct eeh_pe *pe) in eeh_phb_check_failure() argument
366 /* Find the PHB PE */ in eeh_phb_check_failure()
367 phb_pe = eeh_phb_pe_get(pe->phb); in eeh_phb_check_failure()
369 pr_warn("%s Can't find PE for PHB#%x\n", in eeh_phb_check_failure()
370 __func__, pe->phb->global_number); in eeh_phb_check_failure()
430 struct eeh_pe *pe, *parent_pe; in eeh_dev_check_failure() local
444 pe = eeh_dev_to_pe(edev); in eeh_dev_check_failure()
447 if (!pe) { in eeh_dev_check_failure()
457 ret = eeh_phb_check_failure(pe); in eeh_dev_check_failure()
462 * If the PE isn't owned by us, we shouldn't check the in eeh_dev_check_failure()
463 * state. Instead, let the owner handle it if the PE has in eeh_dev_check_failure()
466 if (eeh_pe_passed(pe)) in eeh_dev_check_failure()
477 if (pe->state & EEH_PE_ISOLATED) { in eeh_dev_check_failure()
478 pe->check_count++; in eeh_dev_check_failure()
479 if (pe->check_count == EEH_MAX_FAILS) { in eeh_dev_check_failure()
485 pe->check_count, in eeh_dev_check_failure()
502 ret = eeh_ops->get_state(pe, NULL); in eeh_dev_check_failure()
507 * PE's state, EEH not support and Permanently unavailable in eeh_dev_check_failure()
508 * state, PE is in good state. in eeh_dev_check_failure()
522 pe->false_positives++; in eeh_dev_check_failure()
528 * It should be corner case that the parent PE has been in eeh_dev_check_failure()
532 parent_pe = pe->parent; in eeh_dev_check_failure()
538 /* Frozen parent PE ? */ in eeh_dev_check_failure()
541 pe = parent_pe; in eeh_dev_check_failure()
542 pr_err("EEH: Failure of PHB#%x-PE#%x will be handled at parent PHB#%x-PE#%x.\n", in eeh_dev_check_failure()
543 pe->phb->global_number, pe->addr, in eeh_dev_check_failure()
544 pe->phb->global_number, parent_pe->addr); in eeh_dev_check_failure()
557 eeh_pe_mark_isolated(pe); in eeh_dev_check_failure()
564 pr_debug("EEH: %s: Frozen PHB#%x-PE#%x detected\n", in eeh_dev_check_failure()
565 __func__, pe->phb->global_number, pe->addr); in eeh_dev_check_failure()
566 eeh_send_failure_event(pe); in eeh_dev_check_failure()
608 * @pe: EEH PE
615 int eeh_pci_enable(struct eeh_pe *pe, int function) in eeh_pci_enable() argument
620 * pHyp doesn't allow to enable IO or DMA on unfrozen PE. in eeh_pci_enable()
621 * Also, it's pointless to enable them on unfrozen PE. So in eeh_pci_enable()
647 rc = eeh_ops->get_state(pe, NULL); in eeh_pci_enable()
662 rc = eeh_ops->set_option(pe, function); in eeh_pci_enable()
665 "PHB#%x-PE#%x, err=%d\n", in eeh_pci_enable()
666 __func__, function, pe->phb->global_number, in eeh_pci_enable()
667 pe->addr, rc); in eeh_pci_enable()
671 rc = eeh_wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); in eeh_pci_enable()
738 struct eeh_pe *pe = eeh_dev_to_pe(edev); in pcibios_set_pcie_reset_state() local
740 if (!pe) { in pcibios_set_pcie_reset_state()
741 pr_err("%s: No PE found on PCI device %s\n", in pcibios_set_pcie_reset_state()
748 eeh_ops->reset(pe, EEH_RESET_DEACTIVATE); in pcibios_set_pcie_reset_state()
749 eeh_unfreeze_pe(pe); in pcibios_set_pcie_reset_state()
750 if (!(pe->type & EEH_PE_VF)) in pcibios_set_pcie_reset_state()
751 eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED, true); in pcibios_set_pcie_reset_state()
752 eeh_pe_dev_traverse(pe, eeh_restore_dev_state, dev); in pcibios_set_pcie_reset_state()
753 eeh_pe_state_clear(pe, EEH_PE_ISOLATED, true); in pcibios_set_pcie_reset_state()
756 eeh_pe_mark_isolated(pe); in pcibios_set_pcie_reset_state()
757 eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED, true); in pcibios_set_pcie_reset_state()
758 eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE); in pcibios_set_pcie_reset_state()
759 eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev); in pcibios_set_pcie_reset_state()
760 if (!(pe->type & EEH_PE_VF)) in pcibios_set_pcie_reset_state()
761 eeh_pe_state_mark(pe, EEH_PE_CFG_BLOCKED); in pcibios_set_pcie_reset_state()
762 eeh_ops->reset(pe, EEH_RESET_HOT); in pcibios_set_pcie_reset_state()
765 eeh_pe_mark_isolated(pe); in pcibios_set_pcie_reset_state()
766 eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED, true); in pcibios_set_pcie_reset_state()
767 eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE); in pcibios_set_pcie_reset_state()
768 eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev); in pcibios_set_pcie_reset_state()
769 if (!(pe->type & EEH_PE_VF)) in pcibios_set_pcie_reset_state()
770 eeh_pe_state_mark(pe, EEH_PE_CFG_BLOCKED); in pcibios_set_pcie_reset_state()
771 eeh_ops->reset(pe, EEH_RESET_FUNDAMENTAL); in pcibios_set_pcie_reset_state()
774 eeh_pe_state_clear(pe, EEH_PE_ISOLATED | EEH_PE_CFG_BLOCKED, true); in pcibios_set_pcie_reset_state()
803 struct eeh_pe *pe; in eeh_pe_refreeze_passed() local
806 eeh_for_each_pe(root, pe) { in eeh_pe_refreeze_passed()
807 if (eeh_pe_passed(pe)) { in eeh_pe_refreeze_passed()
808 state = eeh_ops->get_state(pe, NULL); in eeh_pe_refreeze_passed()
811 pr_info("EEH: Passed-through PE PHB#%x-PE#%x was thawed by reset, re-freezing for safety.\n", in eeh_pe_refreeze_passed()
812 pe->phb->global_number, pe->addr); in eeh_pe_refreeze_passed()
813 eeh_pe_set_option(pe, EEH_OPT_FREEZE_PE); in eeh_pe_refreeze_passed()
820 * eeh_pe_reset_full - Complete a full reset process on the indicated PE
821 * @pe: EEH PE
824 * This function executes a full reset procedure on a PE, including setting
830 * This function will attempt to reset a PE three times before failing.
832 int eeh_pe_reset_full(struct eeh_pe *pe, bool include_passed) in eeh_pe_reset_full() argument
842 * PE requires a fundamental reset. in eeh_pe_reset_full()
844 eeh_pe_dev_traverse(pe, eeh_set_dev_freset, &freset); in eeh_pe_reset_full()
849 /* Mark the PE as in reset state and block config space accesses */ in eeh_pe_reset_full()
850 eeh_pe_state_mark(pe, reset_state); in eeh_pe_reset_full()
854 ret = eeh_pe_reset(pe, type, include_passed); in eeh_pe_reset_full()
856 ret = eeh_pe_reset(pe, EEH_RESET_DEACTIVATE, in eeh_pe_reset_full()
860 pr_warn("EEH: Failure %d resetting PHB#%x-PE#%x (attempt %d)\n\n", in eeh_pe_reset_full()
861 state, pe->phb->global_number, pe->addr, i + 1); in eeh_pe_reset_full()
865 pr_warn("EEH: PHB#%x-PE#%x: Successful reset (attempt %d)\n", in eeh_pe_reset_full()
866 pe->phb->global_number, pe->addr, i + 1); in eeh_pe_reset_full()
868 /* Wait until the PE is in a functioning state */ in eeh_pe_reset_full()
869 state = eeh_wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); in eeh_pe_reset_full()
871 pr_warn("EEH: Unrecoverable slot failure on PHB#%x-PE#%x", in eeh_pe_reset_full()
872 pe->phb->global_number, pe->addr); in eeh_pe_reset_full()
879 pr_warn("EEH: PHB#%x-PE#%x: Slot inactive after reset: 0x%x (attempt %d)\n", in eeh_pe_reset_full()
880 pe->phb->global_number, pe->addr, state, i + 1); in eeh_pe_reset_full()
883 /* Resetting the PE may have unfrozen child PEs. If those PEs have been in eeh_pe_reset_full()
887 eeh_pe_refreeze_passed(pe); in eeh_pe_reset_full()
889 eeh_pe_state_clear(pe, reset_state, true); in eeh_pe_reset_full()
916 * we can restore it after reset, either PHB range or PE range. in eeh_save_bars()
1078 if (!edev || !edev->pdev || !edev->pe) { in eeh_remove_device()
1085 * device attached to the parent PE in order for BAR restore in eeh_remove_device()
1087 * from the parent PE during the BAR resotre. in eeh_remove_device()
1116 if (!(edev->pe->state & EEH_PE_KEEP)) in eeh_remove_device()
1122 int eeh_unfreeze_pe(struct eeh_pe *pe) in eeh_unfreeze_pe() argument
1126 ret = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); in eeh_unfreeze_pe()
1128 pr_warn("%s: Failure %d enabling IO on PHB#%x-PE#%x\n", in eeh_unfreeze_pe()
1129 __func__, ret, pe->phb->global_number, pe->addr); in eeh_unfreeze_pe()
1133 ret = eeh_pci_enable(pe, EEH_OPT_THAW_DMA); in eeh_unfreeze_pe()
1135 pr_warn("%s: Failure %d enabling DMA on PHB#%x-PE#%x\n", in eeh_unfreeze_pe()
1136 __func__, ret, pe->phb->global_number, pe->addr); in eeh_unfreeze_pe()
1151 static int eeh_pe_change_owner(struct eeh_pe *pe) in eeh_pe_change_owner() argument
1158 /* Check PE state */ in eeh_pe_change_owner()
1159 ret = eeh_ops->get_state(pe, NULL); in eeh_pe_change_owner()
1163 /* Unfrozen PE, nothing to do */ in eeh_pe_change_owner()
1167 /* Frozen PE, check if it needs PE level reset */ in eeh_pe_change_owner()
1168 eeh_pe_for_each_dev(pe, edev, tmp) { in eeh_pe_change_owner()
1187 return eeh_pe_reset_and_recover(pe); in eeh_pe_change_owner()
1191 ret = eeh_unfreeze_pe(pe); in eeh_pe_change_owner()
1193 eeh_pe_state_clear(pe, EEH_PE_ISOLATED, true); in eeh_pe_change_owner()
1198 * eeh_dev_open - Increase count of pass through devices for PE
1202 * PE. In the result, the EEH errors detected on the PE won't be
1203 * reported. The PE owner will be responsible for detection
1217 /* No EEH device or PE ? */ in eeh_dev_open()
1219 if (!edev || !edev->pe) in eeh_dev_open()
1223 * The PE might have been put into frozen state, but we in eeh_dev_open()
1225 * in frozen PE won't work properly. Clear the frozen state in eeh_dev_open()
1228 ret = eeh_pe_change_owner(edev->pe); in eeh_dev_open()
1232 /* Increase PE's pass through count */ in eeh_dev_open()
1233 atomic_inc(&edev->pe->pass_dev_cnt); in eeh_dev_open()
1244 * eeh_dev_release - Decrease count of pass through devices for PE
1247 * Decrease count of pass through devices for the indicated PE. If
1248 * there is no passed through device in PE, the EEH errors detected
1249 * on the PE will be reported and handled as usual.
1263 if (!edev || !edev->pe || !eeh_pe_passed(edev->pe)) in eeh_dev_release()
1266 /* Decrease PE's pass through count */ in eeh_dev_release()
1267 WARN_ON(atomic_dec_if_positive(&edev->pe->pass_dev_cnt) < 0); in eeh_dev_release()
1268 eeh_pe_change_owner(edev->pe); in eeh_dev_release()
1277 * eeh_iommu_group_to_pe - Convert IOMMU group to EEH PE
1280 * The routine is called to convert IOMMU group to EEH PE.
1296 /* No EEH device or PE ? */ in eeh_iommu_group_to_pe()
1298 if (!edev || !edev->pe) in eeh_iommu_group_to_pe()
1301 return edev->pe; in eeh_iommu_group_to_pe()
1308 * eeh_pe_set_option - Set options for the indicated PE
1309 * @pe: EEH PE
1313 * on the indicated PE, to enable IO or DMA for the frozen PE.
1315 int eeh_pe_set_option(struct eeh_pe *pe, int option) in eeh_pe_set_option() argument
1319 /* Invalid PE ? */ in eeh_pe_set_option()
1320 if (!pe) in eeh_pe_set_option()
1326 * isn't expected to be disabled on one specific PE. in eeh_pe_set_option()
1331 ret = eeh_pe_change_owner(pe); in eeh_pe_set_option()
1346 ret = eeh_pci_enable(pe, option); in eeh_pe_set_option()
1359 * eeh_pe_get_state - Retrieve PE's state
1360 * @pe: EEH PE
1362 * Retrieve the PE's state, which includes 3 aspects: enabled
1365 int eeh_pe_get_state(struct eeh_pe *pe) in eeh_pe_get_state() argument
1370 /* Existing PE ? */ in eeh_pe_get_state()
1371 if (!pe) in eeh_pe_get_state()
1378 * If the parent PE is owned by the host kernel and is undergoing in eeh_pe_get_state()
1379 * error recovery, we should return the PE state as temporarily in eeh_pe_get_state()
1383 if (pe->parent && in eeh_pe_get_state()
1384 !(pe->state & EEH_PE_REMOVED) && in eeh_pe_get_state()
1385 (pe->parent->state & (EEH_PE_ISOLATED | EEH_PE_RECOVERING))) in eeh_pe_get_state()
1388 result = eeh_ops->get_state(pe, NULL); in eeh_pe_get_state()
1408 static int eeh_pe_reenable_devices(struct eeh_pe *pe, bool include_passed) in eeh_pe_reenable_devices() argument
1414 eeh_pe_restore_bars(pe); in eeh_pe_reenable_devices()
1420 eeh_pe_for_each_dev(pe, edev, tmp) { in eeh_pe_reenable_devices()
1433 /* The PE is still in frozen state */ in eeh_pe_reenable_devices()
1434 if (include_passed || !eeh_pe_passed(pe)) { in eeh_pe_reenable_devices()
1435 ret = eeh_unfreeze_pe(pe); in eeh_pe_reenable_devices()
1437 pr_info("EEH: Note: Leaving passthrough PHB#%x-PE#%x frozen.\n", in eeh_pe_reenable_devices()
1438 pe->phb->global_number, pe->addr); in eeh_pe_reenable_devices()
1440 eeh_pe_state_clear(pe, EEH_PE_ISOLATED, include_passed); in eeh_pe_reenable_devices()
1446 * eeh_pe_reset - Issue PE reset according to specified type
1447 * @pe: EEH PE
1451 * The routine is called to reset the specified PE with the
1453 * PE reset is the most important part for error recovery.
1455 int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed) in eeh_pe_reset() argument
1459 /* Invalid PE ? */ in eeh_pe_reset()
1460 if (!pe) in eeh_pe_reset()
1468 ret = eeh_ops->reset(pe, option); in eeh_pe_reset()
1469 eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED, include_passed); in eeh_pe_reset()
1473 ret = eeh_pe_reenable_devices(pe, include_passed); in eeh_pe_reset()
1478 * Proactively freeze the PE to drop all MMIO access in eeh_pe_reset()
1482 eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE); in eeh_pe_reset()
1484 eeh_pe_state_mark(pe, EEH_PE_CFG_BLOCKED); in eeh_pe_reset()
1485 ret = eeh_ops->reset(pe, option); in eeh_pe_reset()
1498 * eeh_pe_configure - Configure PCI bridges after PE reset
1499 * @pe: EEH PE
1502 * those PCI devices, especially PCI bridges affected by PE
1505 int eeh_pe_configure(struct eeh_pe *pe) in eeh_pe_configure() argument
1509 /* Invalid PE ? */ in eeh_pe_configure()
1510 if (!pe) in eeh_pe_configure()
1518 * eeh_pe_inject_err - Injecting the specified PCI error to the indicated PE
1519 * @pe: the indicated PE
1526 * is determined by @type and @func, to the indicated PE for
1529 int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func, in eeh_pe_inject_err() argument
1532 /* Invalid PE ? */ in eeh_pe_inject_err()
1533 if (!pe) in eeh_pe_inject_err()
1544 return eeh_ops->err_inject(pe, type, func, addr, mask); in eeh_pe_inject_err()
1640 * PE freeze. Using the in_8() accessor skips the eeh detection hook in eeh_break_device()
1643 * where the HW will asynchronously freeze a PE and it's up to in eeh_break_device()
1733 struct eeh_pe *pe; in eeh_force_recover_write() local
1742 * When PE is NULL the event is a "special" event. Rather than in eeh_force_recover_write()
1743 * recovering a specific PE it forces the EEH core to scan for failed in eeh_force_recover_write()
1760 /* Retrieve PE */ in eeh_force_recover_write()
1761 pe = eeh_pe_get(hose, pe_no); in eeh_force_recover_write()
1762 if (!pe) in eeh_force_recover_write()
1769 * from an odd state (e.g. PE removed, or recovery of a in eeh_force_recover_write()
1770 * non-isolated PE) in eeh_force_recover_write()
1772 __eeh_send_failure_event(pe); in eeh_force_recover_write()