summaryrefslogtreecommitdiffstats
path: root/src/drivers/bus
diff options
context:
space:
mode:
authorMichael Brown2015-05-13 15:45:21 +0200
committerMichael Brown2015-05-13 16:01:07 +0200
commit5ecd16af04b29555a25074300ec9a0b995dfe407 (patch)
tree335ea24433db238288716a444985c444d8b245b9 /src/drivers/bus
parent[usb] Do not call usb_hotplug() when registering a new hub (diff)
downloadipxe-5ecd16af04b29555a25074300ec9a0b995dfe407.tar.gz
ipxe-5ecd16af04b29555a25074300ec9a0b995dfe407.tar.xz
ipxe-5ecd16af04b29555a25074300ec9a0b995dfe407.zip
[usb] Always clear recorded disconnections after performing hotplug actions
The recorded disconnections (in port->disconnected) will currently be left uncleared if usb_attached() returns an error (e.g. because there are no drivers for a particular USB device). This is incorrect behaviour: the disconnection has been handled and the record should be cleared until the next physical disconnection is detected (via the CSC bit). The problem is masked for EHCI, UHCI, and USB hubs, since these will report a changed port (via usb_port_changed()) only when the underlying hardware reports a change. xHCI will call usb_port_changed() in response to any port status event, at which point the stale value of port->disconnected will be erroneously acted upon. This can lead to an endless loop of repeatedly enumerating the same device when a driverless device is attached to an xHCI root hub port. Fix by unconditionally clearing port->disconnected in usb_hotplugged(). Reported-by: Robin Smidsrød <robin@smidsrod.no> Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/bus')
-rw-r--r--src/drivers/bus/usb.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c
index 7574aaa1..2019e334 100644
--- a/src/drivers/bus/usb.c
+++ b/src/drivers/bus/usb.c
@@ -1591,7 +1591,7 @@ static int usb_hotplugged ( struct usb_port *port ) {
if ( ( rc = hub->driver->speed ( hub, port ) ) != 0 ) {
DBGC ( hub, "USB hub %s port %d could not get speed: %s\n",
hub->name, port->address, strerror ( rc ) );
- return rc;
+ goto err_speed;
}
/* Detach device, if applicable */
@@ -1599,15 +1599,15 @@ static int usb_hotplugged ( struct usb_port *port ) {
usb_detached ( port );
/* Attach device, if applicable */
- if ( port->speed && ! port->attached ) {
- if ( ( rc = usb_attached ( port ) ) != 0 )
- return rc;
- }
+ if ( port->speed && ( ! port->attached ) &&
+ ( ( rc = usb_attached ( port ) ) != 0 ) )
+ goto err_attached;
+ err_attached:
+ err_speed:
/* Clear any recorded disconnections */
port->disconnected = 0;
-
- return 0;
+ return rc;
}
/******************************************************************************