Re: [PATCH] USB: accept some invalid ep0-maxpacket values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 14, 2010 at 03:25:21PM -0400, Alan Stern wrote:
> A few devices (such as the RCA VR5220 voice recorder) are so
> non-compliant with the USB spec that they have invalid maxpacket sizes
> for endpoint 0.  Nevertheless, as long as we can safely use them, we
> may as well do so.
> 
> This patch (as1432) softens our acceptance criterion by allowing
> high-speed devices to have ep0-maxpacket sizes other than 64.  A
> warning is printed in the system log when this happens, and the
> existing error message is clarified.

Alan, it looks like this patch allows udev->ep0.desc.wMaxPacketSize to
be set to the illegal value.  The xHCI driver has to communicate the max
packet size to the host hardware, and the driver will update the control
endpoint's max packet size once the descriptor is fetched.

However, the code in xhci_urb_enqueue() to update the max packet size is
only called if the device is running at full speed.  So I think this
buggy device will work fine under xHCI, but the control transfers will
be broken up into 64-byte packets rather than whatever illegal size the
device wanted.  Do you know if this will be an issue?  How will EHCI
schedule the control transfers with an illegal max packet size?

I could change the xHCI driver to update the max packet size for
non-full speed devices as well, but I'm not sure what the host hardware
will do with an illegal value.  It may just reject the Evaluate Context
command, which would show up as a bunch of failed control transfers
after the descriptor was fetched.

Sarah Sharp

> ---
> 
> Greg:
> 
> This doesn't fix a bug, since the device in question is not compliant 
> with the spec.  On the other hand I don't see how it could introduce 
> any poblems, and Windows already works with this device.
> 
> It's up to you whether or not to queue this for the -stable kernels.
> 
> Alan Stern
> 
> 
> 
> Index: usb-2.6/drivers/usb/core/hub.c
> ===================================================================
> --- usb-2.6.orig/drivers/usb/core/hub.c
> +++ usb-2.6/drivers/usb/core/hub.c
> @@ -2882,13 +2882,16 @@ hub_port_init (struct usb_hub *hub, stru
>  	else
>  		i = udev->descriptor.bMaxPacketSize0;
>  	if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
> -		if (udev->speed != USB_SPEED_FULL ||
> +		if (udev->speed == USB_SPEED_LOW ||
>  				!(i == 8 || i == 16 || i == 32 || i == 64)) {
> -			dev_err(&udev->dev, "ep0 maxpacket = %d\n", i);
> +			dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
>  			retval = -EMSGSIZE;
>  			goto fail;
>  		}
> -		dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
> +		if (udev->speed == USB_SPEED_FULL)
> +			dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
> +		else
> +			dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i);
>  		udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
>  		usb_ep0_reinit(udev);
>  	}
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux