Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/eeh: Cleanup eeh_pe_state_mark()

Currently, eeh_pe_state_mark() marks a PE (and it's children) with a
state and then performs additional processing if that state included
EEH_PE_ISOLATED.

The state parameter is always a constant at the call site, so
rearrange eeh_pe_state_mark() into two functions and just call the
appropriate one at each site.

Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Sam Bobroff and committed by
Michael Ellerman
e762bb89 eed4bdbe

+48 -55
+1
arch/powerpc/include/asm/ppc-pci.h
··· 58 58 int rtas_write_config(struct pci_dn *, int where, int size, u32 val); 59 59 int rtas_read_config(struct pci_dn *, int where, int size, u32 *val); 60 60 void eeh_pe_state_mark(struct eeh_pe *pe, int state); 61 + void eeh_pe_mark_isolated(struct eeh_pe *pe); 61 62 void eeh_pe_state_clear(struct eeh_pe *pe, int state); 62 63 void eeh_pe_state_mark_with_cfg(struct eeh_pe *pe, int state); 63 64 void eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode);
+4 -4
arch/powerpc/kernel/eeh.c
··· 404 404 } 405 405 406 406 /* Isolate the PHB and send event */ 407 - eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED); 407 + eeh_pe_mark_isolated(phb_pe); 408 408 eeh_serialize_unlock(flags); 409 409 410 410 pr_err("EEH: PHB#%x failure detected, location: %s\n", ··· 563 563 * with other functions on this device, and functions under 564 564 * bridges. 565 565 */ 566 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 566 + eeh_pe_mark_isolated(pe); 567 567 eeh_serialize_unlock(flags); 568 568 569 569 /* Most EEH events are due to device driver bugs. Having ··· 830 830 eeh_pe_state_clear(pe, EEH_PE_ISOLATED); 831 831 break; 832 832 case pcie_hot_reset: 833 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 833 + eeh_pe_mark_isolated(pe); 834 834 eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED); 835 835 eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE); 836 836 eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev); ··· 839 839 eeh_ops->reset(pe, EEH_RESET_HOT); 840 840 break; 841 841 case pcie_warm_reset: 842 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 842 + eeh_pe_mark_isolated(pe); 843 843 eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED); 844 844 eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE); 845 845 eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev);
+4 -6
arch/powerpc/kernel/eeh_driver.c
··· 1029 1029 phb_pe = eeh_phb_pe_get(hose); 1030 1030 if (!phb_pe) continue; 1031 1031 1032 - eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED); 1032 + eeh_pe_mark_isolated(phb_pe); 1033 1033 } 1034 1034 1035 1035 eeh_serialize_unlock(flags); ··· 1044 1044 /* Purge all events of the PHB */ 1045 1045 eeh_remove_event(pe, true); 1046 1046 1047 - if (rc == EEH_NEXT_ERR_DEAD_PHB) 1048 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 1049 - else 1050 - eeh_pe_state_mark(pe, 1051 - EEH_PE_ISOLATED | EEH_PE_RECOVERING); 1047 + if (rc != EEH_NEXT_ERR_DEAD_PHB) 1048 + eeh_pe_state_mark(pe, EEH_PE_RECOVERING); 1049 + eeh_pe_mark_isolated(pe); 1052 1050 1053 1051 eeh_serialize_unlock(flags); 1054 1052
+34 -40
arch/powerpc/kernel/eeh_pe.c
··· 540 540 } 541 541 542 542 /** 543 - * __eeh_pe_state_mark - Mark the state for the PE 544 - * @data: EEH PE 545 - * @flag: state 546 - * 547 - * The function is used to mark the indicated state for the given 548 - * PE. Also, the associated PCI devices will be put into IO frozen 549 - * state as well. 550 - */ 551 - static void *__eeh_pe_state_mark(struct eeh_pe *pe, void *flag) 552 - { 553 - int state = *((int *)flag); 554 - struct eeh_dev *edev, *tmp; 555 - struct pci_dev *pdev; 556 - 557 - /* Keep the state of permanently removed PE intact */ 558 - if (pe->state & EEH_PE_REMOVED) 559 - return NULL; 560 - 561 - pe->state |= state; 562 - 563 - /* Offline PCI devices if applicable */ 564 - if (!(state & EEH_PE_ISOLATED)) 565 - return NULL; 566 - 567 - eeh_pe_for_each_dev(pe, edev, tmp) { 568 - pdev = eeh_dev_to_pci_dev(edev); 569 - if (pdev) 570 - pdev->error_state = pci_channel_io_frozen; 571 - } 572 - 573 - /* Block PCI config access if required */ 574 - if (pe->state & EEH_PE_CFG_RESTRICTED) 575 - pe->state |= EEH_PE_CFG_BLOCKED; 576 - 577 - return NULL; 578 - } 579 - 580 - /** 581 543 * eeh_pe_state_mark - Mark specified state for PE and its associated device 582 544 * @pe: EEH PE 583 545 * ··· 547 585 * is used to mark appropriate state for the affected PEs and the 548 586 * associated devices. 549 587 */ 550 - void eeh_pe_state_mark(struct eeh_pe *pe, int state) 588 + void eeh_pe_state_mark(struct eeh_pe *root, int state) 551 589 { 552 - eeh_pe_traverse(pe, __eeh_pe_state_mark, &state); 590 + struct eeh_pe *pe; 591 + 592 + eeh_for_each_pe(root, pe) 593 + if (!(pe->state & EEH_PE_REMOVED)) 594 + pe->state |= state; 553 595 } 554 596 EXPORT_SYMBOL_GPL(eeh_pe_state_mark); 597 + 598 + /** 599 + * eeh_pe_mark_isolated 600 + * @pe: EEH PE 601 + * 602 + * Record that a PE has been isolated by marking the PE and it's children as 603 + * EEH_PE_ISOLATED (and EEH_PE_CFG_BLOCKED, if required) and their PCI devices 604 + * as pci_channel_io_frozen. 605 + */ 606 + void eeh_pe_mark_isolated(struct eeh_pe *root) 607 + { 608 + struct eeh_pe *pe; 609 + struct eeh_dev *edev; 610 + struct pci_dev *pdev; 611 + 612 + eeh_pe_state_mark(root, EEH_PE_ISOLATED); 613 + eeh_for_each_pe(root, pe) { 614 + list_for_each_entry(edev, &pe->edevs, entry) { 615 + pdev = eeh_dev_to_pci_dev(edev); 616 + if (pdev) 617 + pdev->error_state = pci_channel_io_frozen; 618 + } 619 + /* Block PCI config access if required */ 620 + if (pe->state & EEH_PE_CFG_RESTRICTED) 621 + pe->state |= EEH_PE_CFG_BLOCKED; 622 + } 623 + } 624 + EXPORT_SYMBOL_GPL(eeh_pe_mark_isolated); 555 625 556 626 static void *__eeh_pe_dev_mode_mark(struct eeh_dev *edev, void *flag) 557 627 {
+4 -4
arch/powerpc/platforms/powernv/eeh-powernv.c
··· 590 590 EEH_STATE_MMIO_ENABLED | 591 591 EEH_STATE_DMA_ENABLED); 592 592 } else if (!(pe->state & EEH_PE_ISOLATED)) { 593 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 593 + eeh_pe_mark_isolated(pe); 594 594 pnv_eeh_get_phb_diag(pe); 595 595 596 596 if (eeh_has_flag(EEH_EARLY_DUMP_LOG)) ··· 692 692 if (phb->freeze_pe) 693 693 phb->freeze_pe(phb, pe->addr); 694 694 695 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 695 + eeh_pe_mark_isolated(pe); 696 696 pnv_eeh_get_phb_diag(pe); 697 697 698 698 if (eeh_has_flag(EEH_EARLY_DUMP_LOG)) ··· 1597 1597 if ((ret == EEH_NEXT_ERR_FROZEN_PE || 1598 1598 ret == EEH_NEXT_ERR_FENCED_PHB) && 1599 1599 !((*pe)->state & EEH_PE_ISOLATED)) { 1600 - eeh_pe_state_mark(*pe, EEH_PE_ISOLATED); 1600 + eeh_pe_mark_isolated(*pe); 1601 1601 pnv_eeh_get_phb_diag(*pe); 1602 1602 1603 1603 if (eeh_has_flag(EEH_EARLY_DUMP_LOG)) ··· 1626 1626 } 1627 1627 1628 1628 /* We possibly migrate to another PE */ 1629 - eeh_pe_state_mark(*pe, EEH_PE_ISOLATED); 1629 + eeh_pe_mark_isolated(*pe); 1630 1630 } 1631 1631 1632 1632 /*
+1 -1
drivers/pci/hotplug/pnv_php.c
··· 736 736 pe = edev ? edev->pe : NULL; 737 737 if (pe) { 738 738 eeh_serialize_lock(&flags); 739 - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 739 + eeh_pe_mark_isolated(pe); 740 740 eeh_serialize_unlock(flags); 741 741 eeh_pe_set_option(pe, EEH_OPT_FREEZE_PE); 742 742 }