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

powerpc/eeh: Permanently disable the removed device

When a device is hot removed on powernv, the hotplug driver clears
the device's state. However, on pseries, if a device is removed by
phyp after reaching the error threshold, the kernel remains unaware,
leading to the device not being torn down. This prevents necessary
remediation actions like failover.

Permanently disable the device if the presence check fails.

Also, in eeh_dev_check_failure in we may consider the error as false
positive if the device is hotpluged out as the get_state call returns
EEH_STATE_NOT_SUPPORT and we may end up not clearing the device state,
so log the event if the state is not moved to permanent failure state.

Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240422075737.1405551-1-ganeshgr@linux.ibm.com

authored by

Ganesh Goudar and committed by
Michael Ellerman
d1679b4f 57e67001

+21 -3
+10 -1
arch/powerpc/kernel/eeh.c
··· 506 506 * We will punt with the following conditions: Failure to get 507 507 * PE's state, EEH not support and Permanently unavailable 508 508 * state, PE is in good state. 509 + * 510 + * On the pSeries, after reaching the threshold, get_state might 511 + * return EEH_STATE_NOT_SUPPORT. However, it's possible that the 512 + * device state remains uncleared if the device is not marked 513 + * pci_channel_io_perm_failure. Therefore, consider logging the 514 + * event to let device removal happen. 515 + * 509 516 */ 510 517 if ((ret < 0) || 511 - (ret == EEH_STATE_NOT_SUPPORT) || eeh_state_active(ret)) { 518 + (ret == EEH_STATE_NOT_SUPPORT && 519 + dev->error_state == pci_channel_io_perm_failure) || 520 + eeh_state_active(ret)) { 512 521 eeh_stats.false_positives++; 513 522 pe->false_positives++; 514 523 rc = 0;
+11 -2
arch/powerpc/kernel/eeh_driver.c
··· 865 865 devices++; 866 866 867 867 if (!devices) { 868 - pr_debug("EEH: Frozen PHB#%x-PE#%x is empty!\n", 868 + pr_warn("EEH: Frozen PHB#%x-PE#%x is empty!\n", 869 869 pe->phb->global_number, pe->addr); 870 - goto out; /* nothing to recover */ 870 + /* 871 + * The device is removed, tear down its state, on powernv 872 + * hotplug driver would take care of it but not on pseries, 873 + * permanently disable the card as it is hot removed. 874 + * 875 + * In the case of powernv, note that the removal of device 876 + * is covered by pci rescan lock, so no problem even if hotplug 877 + * driver attempts to remove the device. 878 + */ 879 + goto recover_failed; 871 880 } 872 881 873 882 /* Log the event */