Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Mar 2004 10:45:35 +0100
From:      Bernd Walter <ticso@cicely12.cicely.de>
To:        Julian Elischer <julian@freebsd.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/dev/usb usb_subr.c
Message-ID:  <20040326094534.GA752@cicely12.cicely.de>
In-Reply-To: <200403260839.i2Q8dbDj003900@repoman.freebsd.org>
References:  <200403260839.i2Q8dbDj003900@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Mar 26, 2004 at 12:39:37AM -0800, Julian Elischer wrote:
> julian      2004/03/26 00:39:37 PST
> 
>   FreeBSD src repository
> 
>   Modified files:        (Branch: RELENG_4)
>     sys/dev/usb          usb_subr.c 
>   Log:
>   MFC 1.60->1.62
>    MFC some diffs from NetBSD to improve probing of some troublesom
>    devices.

Rev 1.61 broke the retry loop for first contact in that it added a
new first transaction.
The retry loop was required to improve probing of some USB devices
and the included port reset was at least required for some bluetooth
devices.
Since the port reset also resets the device address to zero it can't
help without setting the device address again.

I asume the following should fix the current breakage, but I have none
of such problematic device so I can't test if it still helps.

Index: usb_subr.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.62
diff -u -r1.62 usb_subr.c
--- usb_subr.c	20 Mar 2004 07:31:11 -0000	1.62
+++ usb_subr.c	23 Mar 2004 08:46:28 -0000
@@ -1045,8 +1072,19 @@
 	up->device = dev;
 
 	/* Set the address.  Do this early; some devices need that. */
-	err = usbd_set_address(dev, addr);
+	/* Try a few times in case the device is slow (i.e. outside specs.) */
 	DPRINTFN(5,("usbd_new_device: setting device address=%d\n", addr));
+	for (i = 0; i < 15; i++) {
+		err = usbd_set_address(dev, addr);
+		if (!err)
+			break;
+		usbd_delay_ms(dev, 200);
+		if ((i & 3) == 3) {
+			DPRINTFN(-1,("usb_new_device: set address %d "
+			    "failed - trying a port reset\n", addr));
+			usbd_reset_port(up->parent, port, &ps);
+		}
+	}
 	if (err) {
 		DPRINTFN(-1,("usb_new_device: set address %d failed\n", addr));
 		err = USBD_SET_ADDR_FAILED;
@@ -1059,16 +1097,8 @@
 	bus->devices[addr] = dev;
 
 	dd = &dev->ddesc;
-	/* Try a few times in case the device is slow (i.e. outside specs.) */
-	for (i = 0; i < 15; i++) {
-		/* Get the first 8 bytes of the device descriptor. */
-		err = usbd_get_desc(dev, UDESC_DEVICE, 0, USB_MAX_IPACKET, dd);
-		if (!err)
-			break;
-		usbd_delay_ms(dev, 200);
-		if ((i & 3) == 3)
-			usbd_reset_port(up->parent, port, &ps);
-	}
+	/* Get the first 8 bytes of the device descriptor. */
+	err = usbd_get_desc(dev, UDESC_DEVICE, 0, USB_MAX_IPACKET, dd);
 	if (err) {
 		DPRINTFN(-1, ("usbd_new_device: addr=%d, getting first desc "
 			      "failed\n", addr));
 
-- 
B.Walter                   BWCT                http://www.bwct.de
ticso@bwct.de                                  info@bwct.de



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040326094534.GA752>