Skip to content

Commit e762bb8

Browse files
Sam Bobroffmpe
authored andcommitted
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>
1 parent eed4bdb commit e762bb8

6 files changed

Lines changed: 46 additions & 53 deletions

File tree

‎arch/powerpc/include/asm/ppc-pci.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void eeh_save_bars(struct eeh_dev *edev);
5858
int rtas_write_config(struct pci_dn *, int where, int size, u32 val);
5959
int rtas_read_config(struct pci_dn *, int where, int size, u32 *val);
6060
void eeh_pe_state_mark(struct eeh_pe *pe, int state);
61+
void eeh_pe_mark_isolated(struct eeh_pe *pe);
6162
void eeh_pe_state_clear(struct eeh_pe *pe, int state);
6263
void eeh_pe_state_mark_with_cfg(struct eeh_pe *pe, int state);
6364
void eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode);

‎arch/powerpc/kernel/eeh.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int eeh_phb_check_failure(struct eeh_pe *pe)
404404
}
405405

406406
/* Isolate the PHB and send event */
407-
eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED);
407+
eeh_pe_mark_isolated(phb_pe);
408408
eeh_serialize_unlock(flags);
409409

410410
pr_err("EEH: PHB#%x failure detected, location: %s\n",
@@ -563,7 +563,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
563563
* with other functions on this device, and functions under
564564
* bridges.
565565
*/
566-
eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
566+
eeh_pe_mark_isolated(pe);
567567
eeh_serialize_unlock(flags);
568568

569569
/* Most EEH events are due to device driver bugs. Having
@@ -830,7 +830,7 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state stat
830830
eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
831831
break;
832832
case pcie_hot_reset:
833-
eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
833+
eeh_pe_mark_isolated(pe);
834834
eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED);
835835
eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE);
836836
eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev);
@@ -839,7 +839,7 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state stat
839839
eeh_ops->reset(pe, EEH_RESET_HOT);
840840
break;
841841
case pcie_warm_reset:
842-
eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
842+
eeh_pe_mark_isolated(pe);
843843
eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED);
844844
eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE);
845845
eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev);

‎arch/powerpc/kernel/eeh_driver.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ void eeh_handle_special_event(void)
10291029
phb_pe = eeh_phb_pe_get(hose);
10301030
if (!phb_pe) continue;
10311031

1032-
eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED);
1032+
eeh_pe_mark_isolated(phb_pe);
10331033
}
10341034

10351035
eeh_serialize_unlock(flags);
@@ -1044,11 +1044,9 @@ void eeh_handle_special_event(void)
10441044
/* Purge all events of the PHB */
10451045
eeh_remove_event(pe, true);
10461046

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);
10521050

10531051
eeh_serialize_unlock(flags);
10541052

‎arch/powerpc/kernel/eeh_pe.c‎

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -540,56 +540,50 @@ void eeh_pe_update_time_stamp(struct eeh_pe *pe)
540540
}
541541

542542
/**
543-
* __eeh_pe_state_mark - Mark the state for the PE
544-
* @data: EEH PE
545-
* @flag: state
543+
* eeh_pe_state_mark - Mark specified state for PE and its associated device
544+
* @pe: EEH PE
546545
*
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.
546+
* EEH error affects the current PE and its child PEs. The function
547+
* is used to mark appropriate state for the affected PEs and the
548+
* associated devices.
550549
*/
551-
static void *__eeh_pe_state_mark(struct eeh_pe *pe, void *flag)
550+
void eeh_pe_state_mark(struct eeh_pe *root, int state)
552551
{
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;
552+
struct eeh_pe *pe;
576553

577-
return NULL;
554+
eeh_for_each_pe(root, pe)
555+
if (!(pe->state & EEH_PE_REMOVED))
556+
pe->state |= state;
578557
}
558+
EXPORT_SYMBOL_GPL(eeh_pe_state_mark);
579559

580560
/**
581-
* eeh_pe_state_mark - Mark specified state for PE and its associated device
561+
* eeh_pe_mark_isolated
582562
* @pe: EEH PE
583563
*
584-
* EEH error affects the current PE and its child PEs. The function
585-
* is used to mark appropriate state for the affected PEs and the
586-
* associated devices.
564+
* Record that a PE has been isolated by marking the PE and it's children as
565+
* EEH_PE_ISOLATED (and EEH_PE_CFG_BLOCKED, if required) and their PCI devices
566+
* as pci_channel_io_frozen.
587567
*/
588-
void eeh_pe_state_mark(struct eeh_pe *pe, int state)
568+
void eeh_pe_mark_isolated(struct eeh_pe *root)
589569
{
590-
eeh_pe_traverse(pe, __eeh_pe_state_mark, &state);
570+
struct eeh_pe *pe;
571+
struct eeh_dev *edev;
572+
struct pci_dev *pdev;
573+
574+
eeh_pe_state_mark(root, EEH_PE_ISOLATED);
575+
eeh_for_each_pe(root, pe) {
576+
list_for_each_entry(edev, &pe->edevs, entry) {
577+
pdev = eeh_dev_to_pci_dev(edev);
578+
if (pdev)
579+
pdev->error_state = pci_channel_io_frozen;
580+
}
581+
/* Block PCI config access if required */
582+
if (pe->state & EEH_PE_CFG_RESTRICTED)
583+
pe->state |= EEH_PE_CFG_BLOCKED;
584+
}
591585
}
592-
EXPORT_SYMBOL_GPL(eeh_pe_state_mark);
586+
EXPORT_SYMBOL_GPL(eeh_pe_mark_isolated);
593587

594588
static void *__eeh_pe_dev_mode_mark(struct eeh_dev *edev, void *flag)
595589
{

‎arch/powerpc/platforms/powernv/eeh-powernv.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ static int pnv_eeh_get_phb_state(struct eeh_pe *pe)
590590
EEH_STATE_MMIO_ENABLED |
591591
EEH_STATE_DMA_ENABLED);
592592
} else if (!(pe->state & EEH_PE_ISOLATED)) {
593-
eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
593+
eeh_pe_mark_isolated(pe);
594594
pnv_eeh_get_phb_diag(pe);
595595

596596
if (eeh_has_flag(EEH_EARLY_DUMP_LOG))
@@ -692,7 +692,7 @@ static int pnv_eeh_get_pe_state(struct eeh_pe *pe)
692692
if (phb->freeze_pe)
693693
phb->freeze_pe(phb, pe->addr);
694694

695-
eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
695+
eeh_pe_mark_isolated(pe);
696696
pnv_eeh_get_phb_diag(pe);
697697

698698
if (eeh_has_flag(EEH_EARLY_DUMP_LOG))
@@ -1597,7 +1597,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe)
15971597
if ((ret == EEH_NEXT_ERR_FROZEN_PE ||
15981598
ret == EEH_NEXT_ERR_FENCED_PHB) &&
15991599
!((*pe)->state & EEH_PE_ISOLATED)) {
1600-
eeh_pe_state_mark(*pe, EEH_PE_ISOLATED);
1600+
eeh_pe_mark_isolated(*pe);
16011601
pnv_eeh_get_phb_diag(*pe);
16021602

16031603
if (eeh_has_flag(EEH_EARLY_DUMP_LOG))
@@ -1626,7 +1626,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe)
16261626
}
16271627

16281628
/* We possibly migrate to another PE */
1629-
eeh_pe_state_mark(*pe, EEH_PE_ISOLATED);
1629+
eeh_pe_mark_isolated(*pe);
16301630
}
16311631

16321632
/*

‎drivers/pci/hotplug/pnv_php.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
736736
pe = edev ? edev->pe : NULL;
737737
if (pe) {
738738
eeh_serialize_lock(&flags);
739-
eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
739+
eeh_pe_mark_isolated(pe);
740740
eeh_serialize_unlock(flags);
741741
eeh_pe_set_option(pe, EEH_OPT_FREEZE_PE);
742742
}

0 commit comments

Comments
 (0)