From acc27b9005fcef1f51c0dd7226faa5c101aa96df Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 18 Mar 2015 16:43:18 +0000 Subject: [usb] Fix USB timeouts to match specification Several of the USB timeouts were chosen on the principle of "pick an arbitrary but ridiculously large value, just to be safe". It turns out that some of the timeouts permitted by the USB specification are even larger: for example, control transactions are allowed to take up to five seconds to complete. Fix up these USB timeout values to match those found in the USB2 specification. Debugged-by: Robin Smidsrød Tested-by: Robin Smidsrød Signed-off-by: Michael Brown --- src/drivers/bus/usb.c | 6 ++++++ src/drivers/usb/xhci.h | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c index 548aa7b08..54a115efc 100644 --- a/src/drivers/bus/usb.c +++ b/src/drivers/bus/usb.c @@ -1281,6 +1281,9 @@ static int register_usb ( struct usb_device *usb ) { goto err_enable; } + /* Allow recovery interval since port may have been reset */ + mdelay ( USB_RESET_RECOVER_DELAY_MS ); + /* Get device speed */ if ( ( rc = hub->driver->speed ( hub, port ) ) != 0 ) { DBGC ( hub, "USB hub %s port %d could not get speed: %s\n", @@ -1316,6 +1319,9 @@ static int register_usb ( struct usb_device *usb ) { } DBGC2 ( usb, "USB %s assigned address %d\n", usb->name, usb->address ); + /* Allow recovery interval after Set Address command */ + mdelay ( USB_SET_ADDRESS_RECOVER_DELAY_MS ); + /* Read first part of device descriptor to get EP0 MTU */ if ( ( rc = usb_get_mtu ( usb, &usb->device ) ) != 0 ) { DBGC ( usb, "USB %s could not get MTU: %s\n", diff --git a/src/drivers/usb/xhci.h b/src/drivers/usb/xhci.h index 303208071..5abb5caaf 100644 --- a/src/drivers/usb/xhci.h +++ b/src/drivers/usb/xhci.h @@ -991,9 +991,11 @@ xhci_ring_consumed ( struct xhci_trb_ring *ring ) { /** Maximum time to wait for a command to complete * - * This is a policy decision. + * The "address device" command involves waiting for a response to a + * USB control transaction, and so we must wait for up to the 5000ms + * that USB allows for devices to respond to control transactions. */ -#define XHCI_COMMAND_MAX_WAIT_MS 500 +#define XHCI_COMMAND_MAX_WAIT_MS USB_CONTROL_MAX_WAIT_MS /** Time to delay after aborting a command * -- cgit v1.2.3-55-g7522