Module Name: src Committed By: martin Date: Sun Aug 16 13:06:32 UTC 2009
Modified Files: src/sys/dev/usb: usb_subr.c Log Message: If we are attaching a high speed device, request a full size descriptor block - we know the device will be able to handle it already. This fixes a strange failure mode when attaching a (apparently non standard conformant) USB ATA device I have, and *should* not cause any harm. Apparently the device in question answered with the full descriptor despite our short request - a failure mode not handled gracefully, leading to a port reset. From Jeremy Morse. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.162 src/sys/dev/usb/usb_subr.c:1.163 --- src/sys/dev/usb/usb_subr.c:1.162 Mon Aug 18 18:03:21 2008 +++ src/sys/dev/usb/usb_subr.c Sun Aug 16 13:06:32 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.162 2008/08/18 18:03:21 kent Exp $ */ +/* $NetBSD: usb_subr.c,v 1.163 2009/08/16 13:06:32 martin Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.162 2008/08/18 18:03:21 kent Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.163 2009/08/16 13:06:32 martin Exp $"); #include "opt_compat_netbsd.h" #include "opt_usbverbose.h" @@ -1059,7 +1059,10 @@ dev->def_ep_desc.bDescriptorType = UDESC_ENDPOINT; dev->def_ep_desc.bEndpointAddress = USB_CONTROL_ENDPOINT; dev->def_ep_desc.bmAttributes = UE_CONTROL; - USETW(dev->def_ep_desc.wMaxPacketSize, USB_MAX_IPACKET); + if (speed == USB_SPEED_HIGH) + USETW(dev->def_ep_desc.wMaxPacketSize, 64); + else + USETW(dev->def_ep_desc.wMaxPacketSize, USB_MAX_IPACKET); dev->def_ep_desc.bInterval = 0; dev->quirks = &usbd_no_quirk; @@ -1105,7 +1108,11 @@ /* Try a few times in case the device is slow (i.e. outside specs.) */ for (i = 0; i < 10; i++) { /* Get the first 8 bytes of the device descriptor. */ - err = usbd_get_desc(dev, UDESC_DEVICE, 0, USB_MAX_IPACKET, dd); + err = usbd_get_desc(dev, UDESC_DEVICE, 0, + (speed == USB_SPEED_HIGH) ? USB_DEVICE_DESCRIPTOR_SIZE + : USB_MAX_IPACKET, + dd); + if (!err) break; usbd_delay_ms(dev, 200);