1. 15 Jun, 2011 2 commits
    • Sarah Sharp's avatar
      USB: Free bandwidth when usb_disable_device is called. · fccf4e86
      Sarah Sharp authored
      Tanya ran into an issue when trying to switch a UAS device from the BOT
      configuration to the UAS configuration via the bConfigurationValue sysfs
      file.  Before installing the UAS configuration, set_bConfigurationValue()
      calls usb_disable_device().  That function is supposed to remove all host
      controller resources associated with that device, but it leaves some state
      in the xHCI host controller.
      
      Commit 0791971b
      	usb: allow drivers to use allocated bandwidth until unbound
      added a call to usb_disable_device() in usb_set_configuration(), before
      the xHCI bandwidth functions were invoked.  That commit fixed a bug, but
      also introduced a bug that is triggered when a configured device is
      switched to a new configuration.
      
      usb_disable_device() goes through all the motions of unbinding the drivers
      attached to active interfaces and removing the USB core structures
      associated with those interfaces, but it doesn't actually remove the
      endpoints from the internal xHCI host controller bandwidth structures.
      
      When usb_disable_device() calls usb_disable_endpoint() with reset_hardware
      set to true, the entries in udev->ep_out and udev->ep_in will be set to
      NULL.  Usually, when the USB core installs a new configuration,
      usb_hcd_alloc_bandwidth() will drop all non-NULL endpoints in udev->ep_out
      and udev->ep_in before adding any new endpoints.  However, when the new
      UAS configuration was added, all those entries were null, so none of the
      old endpoints in the BOT configuration were dropped.
      
      The xHCI driver blindly added the UAS configuration endpoints, and some of
      the endpoint addresses overlapped with the old BOT configuration
      endpoints.  This caused the xHCI host to reject the Configure Endpoint
      command.  Now that the xHCI driver code is cleaned up to reject a
      double-add of active endpoints, we need to fix the USB core to properly
      drop old endpoints in usb_disable_device().
      
      If the host controller driver needs bandwidth checking support, make
      usb_disable_device() call usb_disable_endpoint() with
      reset_hardware set to false, drop the endpoints from the xHCI host
      controller, and then call usb_disable_endpoint() again with
      reset_hardware set to true.
      
      The first call to usb_disable_endpoint() will cancel any pending URBs and
      wait on them to be freed in usb_hcd_disable_endpoint(), but will keep the
      pointers in udev->ep_out and udev->ep in intact.  Then
      usb_hcd_alloc_bandwidth() will use those pointers to know which endpoints
      to drop.
      
      The final call to usb_disable_endpoint() will do two things:
      
      1. It will call usb_hcd_disable_endpoint() again, which should be harmless
      since the ep->urb_list should be empty after the first call to
      usb_disable_endpoint() returns.
      
      2. It will set the entries in udev->ep_out and udev->ep in to NULL, and call
      usb_hcd_disable_endpoint().  That call will have no effect, since the xHCI
      driver doesn't set the endpoint_disable function pointer.
      
      Note that usb_disable_device() will now need to be called with
      hcd->bandwidth_mutex held.
      
      This should be backported to kernels as old as 2.6.32.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: default avatarTanya Brokhman <tlinder@codeaurora.org>
      Cc: ablay@codeaurora.org
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: stable@kernel.org
      fccf4e86
    • Sarah Sharp's avatar
      xhci: Reject double add of active endpoints. · fa75ac37
      Sarah Sharp authored
      While trying to switch a UAS device from the BOT configuration to the UAS
      configuration via the bConfigurationValue file, Tanya ran into an issue in
      the USB core.  usb_disable_device() sets entries in udev->ep_out and
      udev->ep_out to NULL, but doesn't call into the xHCI bandwidth management
      functions to remove the BOT configuration endpoints from the xHCI host's
      internal structures.
      
      The USB core would then attempt to add endpoints for the UAS
      configuration, and some of the endpoints had the same address as endpoints
      in the BOT configuration.  The xHCI driver blindly added the endpoints
      again, but the xHCI host controller rejected the Configure Endpoint
      command because active endpoints were added without being dropped.
      
      Make the xHCI driver reject calls to xhci_add_endpoint() that attempt to
      add active endpoints without first calling xhci_drop_endpoint().
      
      This should be backported to kernels as old as 2.6.31.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: default avatarTanya Brokhman <tlinder@codeaurora.org>
      Cc: stable@kernel.org
      fa75ac37
  2. 14 Jun, 2011 2 commits
  3. 13 Jun, 2011 10 commits
  4. 12 Jun, 2011 8 commits
  5. 11 Jun, 2011 16 commits
  6. 10 Jun, 2011 2 commits