NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: netbsd-5 USB mouse issue
On 5/14/2010 12:34 PM, Stephen Borrill wrote:
On Wed, 12 May 2010, Brad du Plessis wrote:
I've searched and seen these sorts of errors a number of times for
various USB devices but have yet to find a way around the problem.
I'm running netbsd-5 and I've got a USB mouse (no PS/2 on my
motherboard) that will quite often (1 out of 3 boots) not work in X.
The startup error message I see is always the same when it fails:
uhub0 at usb0: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00,
addr 1
uhub0: 2 ports with 2 removable, self powered
uhub1 at usb1: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00,
addr 1
uhub1: 2 ports with 2 removable, self powered
uhub2 at usb2: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00,
addr 1
uhub2: 2 ports with 2 removable, self powered
uhub3 at usb3: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00,
addr 1
uhub3: 2 ports with 2 removable, self powered
uhub4 at usb4: vendor 0x8086 EHCI root hub, class 9/0, rev 2.00/1.00,
addr 1
uhub4: 8 ports with 8 removable, self powered
ehci0: handing over low speed device on port 7 to uhci3
uhub3: device problem, disabling port 1
Well I've found a solution that works for me here.
After adding in the USB_DEBUG logging I could see that every time it failed
there was a short transfer when requesting the full device descriptor -
when it failed it always came back with 10 bytes rather than 18 bytes. I
noticed that the initial request for the first 8 bytes of the device
descriptor always succeeded, but this 8 byte packet is requested up to 10
times in a delayed loop - a code comment there mentions that some
out-of-spec devices are slow.
I then checked the request for the full device descriptor and from what I
could see, it is only requested once and if this request fails, the device
would be disabled. So I tried sticking this in a loop much like the
request for the initial 8 bytes and it seems to have worked.
Where before I was getting a failure of the device every 3 boots, I had
the system rebooting on a script the whole night and after checking the
message logs this morning, I didn't have one failure. I put printouts
inside my loop and I can see that basically on every third boot or so, the
first request for the full descriptor would fail, but the second request
would succeed.
See the patch below against a fairly recent netbsd-5, can anyone see any
problems with this?
Thanks,
Brad
Index: usbdi_util.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usbdi_util.c,v
retrieving revision 1.51
diff -u -r1.51 usbdi_util.c
--- usbdi_util.c 26 May 2008 18:00:33 -0000 1.51
+++ usbdi_util.c 18 May 2010 06:54:49 -0000
@@ -101,9 +101,20 @@
usbd_status
usbd_get_device_desc(usbd_device_handle dev, usb_device_descriptor_t *d)
{
- DPRINTFN(3,("usbd_get_device_desc:\n"));
- return (usbd_get_desc(dev, UDESC_DEVICE,
- 0, USB_DEVICE_DESCRIPTOR_SIZE, d));
+ usbd_status err;
+ int i;
+
+ DPRINTFN(3,("usbd_get_device_desc:\n"));
+ for (i=0;i<10;++i) {
+ err=usbd_get_desc(dev, UDESC_DEVICE,
+ 0, USB_DEVICE_DESCRIPTOR_SIZE, d);
+ if (!err)
+ break;
+
+ usbd_delay_ms(dev,200);
+ }
+
+ return err;
}
usbd_status
Home |
Main Index |
Thread Index |
Old Index