PCI: pnv_php: Fix surprise plug detection and recovery
authorTimothy Pearson <tpearson@raptorengineering.com>
Tue, 15 Jul 2025 21:39:06 +0000 (16:39 -0500)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Sat, 26 Jul 2025 07:39:15 +0000 (13:09 +0530)
commita2a2a6fc2469524caa713036297c542746d148dc
treeb6638734376f56b17947d7fb830908455499ae88
parent1010b4c012b0d78dfb9d3132b49aa2ef024a07a7
PCI: pnv_php: Fix surprise plug detection and recovery

The existing PowerNV hotplug code did not handle surprise plug events
correctly, leading to a complete failure of the hotplug system after device
removal and a required reboot to detect new devices.

This comes down to two issues:

 1) When a device is surprise removed, often the bridge upstream
    port will cause a PE freeze on the PHB.  If this freeze is not
    cleared, the MSI interrupts from the bridge hotplug notification
    logic will not be received by the kernel, stalling all plug events
    on all slots associated with the PE.

 2) When a device is removed from a slot, regardless of surprise or
    programmatic removal, the associated PHB/PE ls left frozen.
    If this freeze is not cleared via a fundamental reset, skiboot
    is unable to clear the freeze and cannot retrain / rescan the
    slot.  This also requires a reboot to clear the freeze and redetect
    the device in the slot.

Issue the appropriate unfreeze and rescan commands on hotplug events,
and don't oops on hotplug if pci_bus_to_OF_node() returns NULL.

Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
[bhelgaas: tidy comments]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/171044224.1359864.1752615546988.JavaMail.zimbra@raptorengineeringinc.com
arch/powerpc/kernel/pci-hotplug.c
drivers/pci/hotplug/pnv_php.c