mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb: increase USB_CNTL_TIMEOUT to match linux
@ 2015-04-28 10:51 Steffen Trumtrar
  2015-05-04  7:23 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Steffen Trumtrar @ 2015-04-28 10:51 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

USB requests should be processed within a timeframe of 5s.
The linux kernel also uses this timeout value for the control packets.

For the musb the increase in timeout helps successfully probing USB devices
(at least on one test hardware), but on the other hand doesn't slow down the
system, if there are no devices, i.e. the timeout never hits. That means,
that the USB core correctly aborts instead of timing out.
Why and how the 100ms was chosen in the first place, can not be deduced from
the git history, just that it seems to work fine for most boards.

Change USB_CNTL_TIMEOUT to 5000ms and replace all occurences of
	`USB_CNTL_TIMEOUT * x`
with just
	`USB_CNTL_TIMEOUT`,
as the timeout is now large enough without it.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/usb/core/usb.c | 4 ++--
 include/usb/usb.h      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index d1c3e0394d44..9073fff4be72 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -663,7 +663,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
 
 	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
 				 USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0,
-				 endp, NULL, 0, USB_CNTL_TIMEOUT * 3);
+				 endp, NULL, 0, USB_CNTL_TIMEOUT);
 
 	/* don't clear if failed */
 	if (result < 0)
@@ -748,7 +748,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
 	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
 				USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
 				alternate, interface, NULL, 0,
-				USB_CNTL_TIMEOUT * 5);
+				USB_CNTL_TIMEOUT);
 	if (ret < 0)
 		return ret;
 
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 991f3d7dd1fe..8f3ce2aeff24 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -39,7 +39,7 @@
 #define USB_MAXCHILDREN			8	/* This is arbitrary */
 #define USB_MAX_HUB			16
 
-#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
+#define USB_CNTL_TIMEOUT 5000 /* 5000ms timeout */
 
 /* device request (setup) */
 struct devrequest {
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: increase USB_CNTL_TIMEOUT to match linux
  2015-04-28 10:51 [PATCH] usb: increase USB_CNTL_TIMEOUT to match linux Steffen Trumtrar
@ 2015-05-04  7:23 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-05-04  7:23 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

On Tue, Apr 28, 2015 at 12:51:49PM +0200, Steffen Trumtrar wrote:
> USB requests should be processed within a timeframe of 5s.
> The linux kernel also uses this timeout value for the control packets.
> 
> For the musb the increase in timeout helps successfully probing USB devices
> (at least on one test hardware), but on the other hand doesn't slow down the
> system, if there are no devices, i.e. the timeout never hits. That means,
> that the USB core correctly aborts instead of timing out.
> Why and how the 100ms was chosen in the first place, can not be deduced from
> the git history, just that it seems to work fine for most boards.
> 
> Change USB_CNTL_TIMEOUT to 5000ms and replace all occurences of
> 	`USB_CNTL_TIMEOUT * x`
> with just
> 	`USB_CNTL_TIMEOUT`,
> as the timeout is now large enough without it.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  drivers/usb/core/usb.c | 4 ++--
>  include/usb/usb.h      | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-04  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 10:51 [PATCH] usb: increase USB_CNTL_TIMEOUT to match linux Steffen Trumtrar
2015-05-04  7:23 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox