Skip to content

Commit 5fd1346

Browse files
sambltcmpe
authored andcommitted
powerpc/eeh: Clarify arguments to eeh_reset_device()
It is currently difficult to understand the behaviour of eeh_reset_device() due to the way it's parameters are used. In particular, when 'bus' is NULL, it's value is still necessary so the same value is looked up again locally under a different name ('frozen_bus') but behaviour is changed. To clarify this, add a new parameter 'driver_eeh_aware', and have the caller set it when it would have passed NULL for 'bus' and always pass a value for 'bus'. Then change any test that was on 'bus' to one on '!driver_eeh_aware' and replace uses of 'frozen_bus' with 'bus'. Also update the function's comment. 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 cd95f80 commit 5fd1346

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

arch/powerpc/kernel/eeh_driver.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -619,17 +619,19 @@ int eeh_pe_reset_and_recover(struct eeh_pe *pe)
619619

620620
/**
621621
* eeh_reset_device - Perform actual reset of a pci slot
622+
* @driver_eeh_aware: Does the device's driver provide EEH support?
622623
* @pe: EEH PE
623624
* @bus: PCI bus corresponding to the isolcated slot
625+
* @rmv_data: Optional, list to record removed devices
624626
*
625627
* This routine must be called to do reset on the indicated PE.
626628
* During the reset, udev might be invoked because those affected
627629
* PCI devices will be removed and then added.
628630
*/
629631
static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
630-
struct eeh_rmv_data *rmv_data)
632+
struct eeh_rmv_data *rmv_data,
633+
bool driver_eeh_aware)
631634
{
632-
struct pci_bus *frozen_bus = eeh_pe_bus_get(pe);
633635
time64_t tstamp;
634636
int cnt, rc;
635637
struct eeh_dev *edev;
@@ -645,15 +647,15 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
645647
* into pci_hp_add_devices().
646648
*/
647649
eeh_pe_state_mark(pe, EEH_PE_KEEP);
648-
if (bus) {
650+
if (!driver_eeh_aware) {
649651
if (pe->type & EEH_PE_VF) {
650652
eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);
651653
} else {
652654
pci_lock_rescan_remove();
653655
pci_hp_remove_devices(bus);
654656
pci_unlock_rescan_remove();
655657
}
656-
} else if (frozen_bus) {
658+
} else if (bus) {
657659
eeh_pe_dev_traverse(pe, eeh_rmv_device, rmv_data);
658660
}
659661

@@ -689,7 +691,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
689691
* the device up before the scripts have taken it down,
690692
* potentially weird things happen.
691693
*/
692-
if (bus) {
694+
if (!driver_eeh_aware) {
693695
pr_info("EEH: Sleep 5s ahead of complete hotplug\n");
694696
ssleep(5);
695697

@@ -706,7 +708,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
706708
eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
707709
pci_hp_add_devices(bus);
708710
}
709-
} else if (frozen_bus && rmv_data->removed) {
711+
} else if (bus && rmv_data->removed) {
710712
pr_info("EEH: Sleep 5s ahead of partial hotplug\n");
711713
ssleep(5);
712714

@@ -715,7 +717,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
715717
if (pe->type & EEH_PE_VF)
716718
eeh_add_virt_device(edev, NULL);
717719
else
718-
pci_hp_add_devices(frozen_bus);
720+
pci_hp_add_devices(bus);
719721
}
720722
eeh_pe_state_clear(pe, EEH_PE_KEEP);
721723

@@ -820,7 +822,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)
820822
*/
821823
if (result == PCI_ERS_RESULT_NONE) {
822824
pr_info("EEH: Reset with hotplug activity\n");
823-
rc = eeh_reset_device(pe, bus, NULL);
825+
rc = eeh_reset_device(pe, bus, NULL, false);
824826
if (rc) {
825827
pr_warn("%s: Unable to reset, err=%d\n",
826828
__func__, rc);
@@ -872,7 +874,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)
872874
/* If any device called out for a reset, then reset the slot */
873875
if (result == PCI_ERS_RESULT_NEED_RESET) {
874876
pr_info("EEH: Reset without hotplug activity\n");
875-
rc = eeh_reset_device(pe, NULL, &rmv_data);
877+
rc = eeh_reset_device(pe, bus, &rmv_data, true);
876878
if (rc) {
877879
pr_warn("%s: Cannot reset, err=%d\n",
878880
__func__, rc);

0 commit comments

Comments
 (0)