Skip to content

Commit 54048cf

Browse files
sambltcmpe
authored andcommitted
powerpc/eeh: Factor out common code eeh_reset_device()
The caller will always pass NULL for 'rmv_data' when 'eeh_aware_driver' is true, so the first two calls to eeh_pe_dev_traverse() can be combined without changing behaviour as can the two arms of the final 'if' block. This should not change behaviour. Signed-off-by: Sam Bobroff <[email protected]> Reviewed-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent d3136d7 commit 54048cf

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

arch/powerpc/kernel/eeh_driver.c

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -647,16 +647,12 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
647647
* into pci_hp_add_devices().
648648
*/
649649
eeh_pe_state_mark(pe, EEH_PE_KEEP);
650-
if (!driver_eeh_aware) {
651-
if (pe->type & EEH_PE_VF) {
652-
eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);
653-
} else {
654-
pci_lock_rescan_remove();
655-
pci_hp_remove_devices(bus);
656-
pci_unlock_rescan_remove();
657-
}
658-
} else {
650+
if (driver_eeh_aware || (pe->type & EEH_PE_VF)) {
659651
eeh_pe_dev_traverse(pe, eeh_rmv_device, rmv_data);
652+
} else {
653+
pci_lock_rescan_remove();
654+
pci_hp_remove_devices(bus);
655+
pci_unlock_rescan_remove();
660656
}
661657

662658
/*
@@ -691,8 +687,9 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
691687
* the device up before the scripts have taken it down,
692688
* potentially weird things happen.
693689
*/
694-
if (!driver_eeh_aware) {
695-
pr_info("EEH: Sleep 5s ahead of complete hotplug\n");
690+
if (!driver_eeh_aware || rmv_data->removed) {
691+
pr_info("EEH: Sleep 5s ahead of %s hotplug\n",
692+
(driver_eeh_aware ? "partial" : "complete"));
696693
ssleep(5);
697694

698695
/*
@@ -705,19 +702,10 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
705702
if (pe->type & EEH_PE_VF) {
706703
eeh_add_virt_device(edev, NULL);
707704
} else {
708-
eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
705+
if (!driver_eeh_aware)
706+
eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
709707
pci_hp_add_devices(bus);
710708
}
711-
} else if (rmv_data->removed) {
712-
pr_info("EEH: Sleep 5s ahead of partial hotplug\n");
713-
ssleep(5);
714-
715-
edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
716-
eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
717-
if (pe->type & EEH_PE_VF)
718-
eeh_add_virt_device(edev, NULL);
719-
else
720-
pci_hp_add_devices(bus);
721709
}
722710
eeh_pe_state_clear(pe, EEH_PE_KEEP);
723711

0 commit comments

Comments
 (0)