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

Revert "PCI: pciehp: Add runtime PM support for PCIe hotplug ports"

This reverts commit 68db9bc814362e7f24371c27d12a4f34477d9356.

Yinghai reported that the following manual hotplug sequence:

# echo 0 > /sys/bus/pci/slots/8/power
# echo 1 > /sys/bus/pci/slots/8/power

worked in v4.9, but fails in v4.10-rc1, and that reverting 68db9bc81436
("PCI: pciehp: Add runtime PM support for PCIe hotplug ports") makes it
work again.

Fixes: 68db9bc81436 ("PCI: pciehp: Add runtime PM support for PCIe hotplug ports")
Link: https://lkml.kernel.org/r/CAE9FiQVCMCa7iVyuwp9z6VrY0cE7V_xghuXip28Ft52=8QmTWw@mail.gmail.com
Link: https://bugzilla.kernel.org/show_bug.cgi?id=193951
Reported-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

+6 -12
-6
drivers/pci/hotplug/pciehp_ctrl.c
··· 31 31 #include <linux/kernel.h> 32 32 #include <linux/types.h> 33 33 #include <linux/slab.h> 34 - #include <linux/pm_runtime.h> 35 34 #include <linux/pci.h> 36 35 #include "../pci.h" 37 36 #include "pciehp.h" ··· 98 99 pciehp_green_led_blink(p_slot); 99 100 100 101 /* Check link training status */ 101 - pm_runtime_get_sync(&ctrl->pcie->port->dev); 102 102 retval = pciehp_check_link_status(ctrl); 103 103 if (retval) { 104 104 ctrl_err(ctrl, "Failed to check link status\n"); ··· 118 120 if (retval != -EEXIST) 119 121 goto err_exit; 120 122 } 121 - pm_runtime_put(&ctrl->pcie->port->dev); 122 123 123 124 pciehp_green_led_on(p_slot); 124 125 pciehp_set_attention_status(p_slot, 0); 125 126 return 0; 126 127 127 128 err_exit: 128 - pm_runtime_put(&ctrl->pcie->port->dev); 129 129 set_slot_off(ctrl, p_slot); 130 130 return retval; 131 131 } ··· 137 141 int retval; 138 142 struct controller *ctrl = p_slot->ctrl; 139 143 140 - pm_runtime_get_sync(&ctrl->pcie->port->dev); 141 144 retval = pciehp_unconfigure_device(p_slot); 142 - pm_runtime_put(&ctrl->pcie->port->dev); 143 145 if (retval) 144 146 return retval; 145 147
+6 -6
drivers/pci/pci.c
··· 2241 2241 return false; 2242 2242 2243 2243 /* 2244 - * Hotplug ports handled by firmware in System Management Mode 2244 + * Hotplug interrupts cannot be delivered if the link is down, 2245 + * so parents of a hotplug port must stay awake. In addition, 2246 + * hotplug ports handled by firmware in System Management Mode 2245 2247 * may not be put into D3 by the OS (Thunderbolt on non-Macs). 2248 + * For simplicity, disallow in general for now. 2246 2249 */ 2247 - if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge)) 2250 + if (bridge->is_hotplug_bridge) 2248 2251 return false; 2249 2252 2250 2253 if (pci_bridge_d3_force) ··· 2279 2276 !pci_pme_capable(dev, PCI_D3cold)) || 2280 2277 2281 2278 /* If it is a bridge it must be allowed to go to D3. */ 2282 - !pci_power_manageable(dev) || 2283 - 2284 - /* Hotplug interrupts cannot be delivered if the link is down. */ 2285 - dev->is_hotplug_bridge) 2279 + !pci_power_manageable(dev)) 2286 2280 2287 2281 *d3cold_ok = false; 2288 2282