Re: [RFC 2/2] USB: Check bandwidth when switching alt settings.

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

 



On Mon, Sep 21, 2009 at 04:23:33PM -0400, Alan Stern wrote:
> On Fri, 18 Sep 2009, Sarah Sharp wrote:
> 
> > Make the USB core check the bandwidth when switching from one
> > interface alternate setting to another.  Also check the bandwidth
> > when resetting a configuration (so that alt setting 0 is used).  If
> > this check fails, the device's state is unchanged.  If the device
> > refuses the new alt setting, re-instate the old alt setting in the
> > host controller hardware.
> > 
> > I'm not entirely sure how to handle this race condition:
> > 
> > Device A has one interface with two alt settings:
> >  alt setting 0 has an interrupt endpoint with max packet size 32
> >  alt setting 1 has an interrupt endpoint with max packet size 64
> > 
> > Device A currently uses alt setting 1, but the driver wants to switch
> > back to alt setting 0.
> > 
> > 1. USB core sets up alt setting 0 for device A, which succeeds on
> > the xHCI hardware side.
> > 2. A new USB device gets plugged in, and consumes the rest of the bus
> > bandwidth.  Or another driver asks for a different alt setting that
> > consumes more bandwidth.
> > 3. USB core sends the USB_REQ_SET_INTERFACE control transfer, which
> > fails due to electrical noise.
> > 
> > If the USB core tries to re-instate alt setting 1, the xHCI hardware
> > will reject it because it takes up too much bandwidth.  So it seems
> > like there needs to be some sort of bus lock whenever the USB core
> > starts to install a new configuration or alt setting.
> 
> Alternatively when switching configurations or altsettings, you could 
> temporarily reserve the maximum of the old and the new bandwidths.  
> Then after the switch succeeded or failed, you could release any 
> excess bandwidth.

Good suggestion, however, that won't work with the xHCI hardware.  The
xHCI hardware representation of a USB device includes 31 physical
endpoints, and the bandwidth code indicates which of the 31 endpoints
were added, dropped, or changed.  The endpoint address is used as an
index into the xHCI device representation.  So you can't have the same
endpoint address with two different bandwidth reservations.

The xHCI driver could fake the address (add the old endpoint setting on
an unused endpoint), but that won't work if the device uses all 31
endpoints.

Sarah
--
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