• S
    USB: Check bandwidth when switching alt settings. · 3f0479e0
    Sarah Sharp 提交于
    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.
    
    If a USB device doesn't have an alternate interface setting 0, install
    the first alt setting in its descriptors when a new configuration is
    requested, or the device is reset.
    
    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.
    Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
    Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
    3f0479e0
hcd.c 65.7 KB