USB: hcd-pci: Do not disable an already disabled device on remove
PATCH 1/1 USB: hcd-pci: Do not disable an already disabled device on remove
suspend_common() calls pci_disable_device() and resume_common() re-enables the device. If the host controller is hot-removed during system resume before its ->resume() callback ran (for example pciehp handling a Thunderbolt/USB4 dock or host router that did not come back), usb_hcd_pci_remove() drops the enable count a second time:
xhci_hcd 0000:b2:00.0: disabling already-disabled device
WARNING: drivers/pci/pci.c:2198 at pci_disable_device+0xac/0xc0, CPU#9: irq/128-pciehp/225 Call Trace: xhci_pci_remove+0x89/0xd0 pci_device_remove+0x4a/0xb0 device_release_driver_internal+0x19e/0x200 pci_stop_bus_device+0x63/0x70 pci_stop_and_remove_bus_device+0x16/0x30 pciehp_unconfigure_device+0x96/0x170 pciehp_disable_slot+0x66/0x100 pciehp_handle_presence_or_link_change+0x62/0x190 pciehp_ist+0x14f/0x1d0
(usb_hcd_pci_remove() tail-calls pci_disable_device(), hence it is not in the trace.)
Only disable the device if it is still enabled.
---
Notes:
Tested on a Lenovo ThinkPad P16 Gen 3 (Core Ultra 9 275HX, JHL9580 Barlow Ridge host, I226 Ethernet), in daily use since 2026-09-17.
drivers/usb/core/hcd-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/core/hcd-pci.c +7 -1
@@ -348,7 +348,13 @@ void usb_hcd_pci_remove(struct pci_dev *dev)usb_put_hcd (hcd);if ((hcd_driver_flags &HCD_MASK ) <HCD_USB3 )pci_free_irq_vectors (dev); -pci_disable_device (dev); +/* +* suspend_common() disables the device. If the controller is +* hot-removed during system resume before resume_common() had a +* chance to re-enable it, there is nothing left to disable. +*/ +if (pci_is_enabled (dev)) +pci_disable_device (dev); }EXPORT_SYMBOL_GPL (usb_hcd_pci_remove);
base-commit: 32c52ec87d6245ee2d12ed5dd509e40062939b50
Signature · 1 line
2.54.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 19 lines
suspend_common()callspci_disable_device()andresume_common()re-enables the device. If the host controller is hot-removed during system resume before its ->resume() callback ran (for example pciehp handling a Thunderbolt/USB4 dock or host router that did not come back),usb_hcd_pci_remove()drops the enable count a second time:
xhci_hcd0000:b2:00.0: disabling already-disabled deviceWARNING: drivers/pci/pci.c:2198 at pci_disable_device+0xac/0xc0, CPU#9: irq/128-pciehp/225 Call Trace: xhci_pci_remove+0x89/0xd0 pci_device_remove+0x4a/0xb0 device_release_driver_internal+0x19e/0x200 pci_stop_bus_device+0x63/0x70 pci_stop_and_remove_bus_device+0x16/0x30 pciehp_unconfigure_device+0x96/0x170 pciehp_disable_slot+0x66/0x100 pciehp_handle_presence_or_link_change+0x62/0x190 pciehp_ist+0x14f/0x1d0
Quoted 7 lines
(
usb_hcd_pci_remove()tail-callspci_disable_device(), hence it is not in the trace.)Only disable the device if it is still enabled.
Fixes a0d4922da2e4 ("USB: fix up suspend and resume for PCI host controllers")Signed-off-by Cole Leavitt <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 24 lines · Cole Leavitt
suspend_common()callspci_disable_device()andresume_common()re-enables the device. If the host controller is hot-removed during system resume before its ->resume() callback ran (for example pciehp handling a Thunderbolt/USB4 dock or host router that did not come back),usb_hcd_pci_remove()drops the enable count a second time:
xhci_hcd0000:b2:00.0: disabling already-disabled deviceWARNING: drivers/pci/pci.c:2198 at pci_disable_device+0xac/0xc0, CPU#9: irq/128-pciehp/225 Call Trace: xhci_pci_remove+0x89/0xd0 pci_device_remove+0x4a/0xb0 device_release_driver_internal+0x19e/0x200 pci_stop_bus_device+0x63/0x70 pci_stop_and_remove_bus_device+0x16/0x30 pciehp_unconfigure_device+0x96/0x170 pciehp_disable_slot+0x66/0x100 pciehp_handle_presence_or_link_change+0x62/0x190 pciehp_ist+0x14f/0x1d0(
usb_hcd_pci_remove()tail-callspci_disable_device(), hence it is not in the trace.)Only disable the device if it is still enabled.
Quoted 7 lines
Fixes a0d4922da2e4 ("USB: fix up suspend and resume for PCI host controllers")Signed-off-by Cole Leavitt <[email protected]>---
Notes:
Tested on a Lenovo ThinkPad P16 Gen 3 (Core Ultra 9 275HX, JHL9580 Barlow Ridge host, I226 Ethernet), in daily use since 2026-09-17.
Quoted 27 lines
drivers/usb/core/hcd-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/usb/core/hcd-pci.c +7
-1@@ -348,7 +348,13 @@ void usb_hcd_pci_remove(struct pci_dev *dev)usb_put_hcd (hcd);if ((hcd_driver_flags &HCD_MASK ) <HCD_USB3 )pci_free_irq_vectors (dev); -pci_disable_device (dev); +/* +* suspend_common() disables the device. If the controller is +* hot-removed during system resume before resume_common() had a +* chance to re-enable it, there is nothing left to disable. +*/ +if (pci_is_enabled (dev)) +pci_disable_device (dev); }EXPORT_SYMBOL_GPL (usb_hcd_pci_remove);base-commit:
32c52ec87d6245ee2d12ed5dd509e40062939b50Signature · 1 line
2.54.0