On Mon, 23 Nov 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. > > Add a mutex per root hub to protect bandwidth operations: > adding/reseting/changing configurations, and changing alternate interface > settings. We want to ensure that the xHCI host controller and the USB > device are set up for the same configurations and alternate settings. > There are two (possibly three) steps to do this: > > 1. The host controller needs to check that bandwidth is available for a > different setting, by issuing and waiting for a configure endpoint > command. > 2. Once that returns successfully, a control message is sent to the > device. > 3. If that fails, the host controller must be notified through another > configure endpoint command. > > The mutex is used to make these three operations seem atomic, to prevent > another driver from using more bandwidth for a different device while > we're in the middle of these operations. > > While we're touching the bandwidth code, rename usb_hcd_check_bandwidth() > to usb_hcd_alloc_bandwidth(). This function does more than just check > that the bandwidth change won't exceed the bus bandwidth; it actually > changes the bandwidth configuration in the xHCI host controller. There appears to be a problem in usb_reset_and_verify_device(), where the old altsettings are restored. Initially you restore the old config, which allocates bandwidth for altsetting 0. Then the routine calls usb_set_interface() to restore the old altsetting. But the cur_alt argument passed to usb_hcd_alloc_bandwidth() will be the old altsetting, not altsetting 0. To fix this, you'll have to set intf->cur_altsetting to point to altsetting 0 before usb_reset_and_verify_device() calls usb_set_interface(). There are several places where usbcore searches for altsetting 0. Can they all use a single subroutine? Alan Stern -- 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