Skip to contentSkip to conversation

usb: CPU 100% hog upon device removal

PATCH Mathias Nyman 1 participant 1 message Dec 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 31 lines · Mathias Nyman
Quoted 9 lines · Ju Hyung Park

Hi,

I've just tried out Ubuntu's kernel PPA and this issue is still there. At least I didn't screw something up on my personal builds.

I've used the following for activating USB dynamic debug:
echo "file drivers/usb/* +p" > /sys/kernel/debug/dynamic_debug/control Let me know if I should have done something else.

Quoted 10 lines

Kernel log stays quiet until I do echo 1 > remove, and it goes nuts.
http://www.arter97.com/usblog.txt.xz
(uncompressed size 27M)

Please have a look.

Thanks.

Quoted 2 lines · Alan Stern

On Thu, 13 Dec 2018, Ju Hyung Park wrote:

Bus suspend tries to suspend bus after last device is removed, but for some reason port status still shows as polling/USB3 link training. you end up in busyloop trying to autosuspend the bus, and bus_suspend returning -EBUSY

this is due to 4.19.8 commit:

commit cc8b329fef53c74a4abf98b0755b3832d572d6ce
Author: Mathias Nyman <[email protected]> Date:   Thu Nov 15 11:38:41 2018 +0200

Quoted 5 lines

    usb: xhci: Prevent bus suspend if a port connect change or polling state is detected commit 2f31a67f01a8beb22cae754c53522cb61a005750 upstream.

-Mathias

Looks like it's a USB2 device, seems that the above patch reacts to USB2 polling state as well, which is a different case.

Does the below change help?

drivers/usb/host/xhci-hub.c +2 -1
index 94aca1b..01b5818 100644
@@ -1507,7 +1507,8 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
                 portsc_buf[port_index] = 0;
  
                 /* Bail out if a USB3 port has a new device in link training */
-               if ((t1 & PORT_PLS_MASK) == XDEV_POLLING) {
+               if ((hcd->speed >= HCD_USB3) &&
+                   (t1 & PORT_PLS_MASK) == XDEV_POLLING) {
                         bus_state->bus_suspended = 0;
                         spin_unlock_irqrestore(&xhci->lock, flags);
                         xhci_dbg(xhci, "Bus suspend bailout, port in polling\n");