Skip to contentSkip to conversation

usb hub driver bug in overcurrent handling?

DISCUSSION Bin Liu 1 participant 1 message Jul 18, 2018 USB

lore
Share & tools
lore

Bin Liu

author
#0 lore raw
Quoted 24 lines · Alan Stern
Quoted 22 lines · Bin Liu

Hi,

I got a report saying that when overcurrent happens in one of the hub downstream ports, USB_PORT_STAT_OVERCURRENT is not set in portstatus, instead USB_PORT_STAT_C_OVERCURRENT is set in portchange, then the overcurrent condition is not handled in hub_event().

The following patch solves the issue.

t a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 442be7f312f6..118557acc74b 100644

drivers/usb/core/hub.c +2 -1
@@ -1144,7 +1144,8 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
                         * check for a new connection
                         */
                        if (udev || (portstatus & USB_PORT_STAT_CONNECTION) ||
-                           (portstatus & USB_PORT_STAT_OVERCURRENT))
+                           (portstatus & USB_PORT_STAT_OVERCURRENT) ||
+                           (portchange & USB_PORT_STAT_C_OVERCURRENT))
                                set_bit(port1, hub->change_bits);
 
Quoted 3 lines

drivers/usb/core/hub.c static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) · line 1151

Quoted 1 line
drivers/usb/core/hub.c +0 -0
                } else if (portstatus & USB_PORT_STAT_ENABLE) {

Please also update the immediately preceding comment.

Sure.

Quoted 8 lines
Quoted 8 lines

The usb2.0 spec section 11.12.5 states
"If a hub has per-port power switching and per-port current limiting, an
over-current on one port may still cause the power on another port to fall below specific minimums. In this case, the affected port is placed in the Power-Off state and C_PORT_OVER_CURRENT is set for the port, but PORT_OVER_CURRENT is not set."

Quoted 4 lines
Quoted 1 line

So is the patch above a proper fix? or something else might be missing?

It certainly seems like a reasonable thing to do. If you say it fixes the problem, we can add it in.

Will send the patch.

Thanks,
-Bin.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html