UPSTREAM: USB: fix endpoint-disabling for failed config changes
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 7 Nov 2012 15:31:30 +0000 (10:31 -0500)
committerChromeBot <chrome-bot@google.com>
Fri, 22 Mar 2013 01:02:45 +0000 (18:02 -0700)
commit6e8c003d3061c489e1b8ed1a3d9cf304317fb2ea
tree732cd550518b40a47122e2d531bb85065df7dcde
parent358464c59d0b9ab542527f4a63e98c55b39dfe0d
UPSTREAM: USB: fix endpoint-disabling for failed config changes

commit 36caff5d795429c572443894e8789c2150dd796b upstream.

This patch (as1631) fixes a bug that shows up when a config change
fails for a device under an xHCI controller.  The controller needs to
be told to disable the endpoints that have been enabled for the new
config.  The existing code does this, but before storing the
information about which endpoints were enabled!  As a result, any
second attempt to install the new config is doomed to fail because
xhci-hcd will refuse to enable an endpoint that is already enabled.

The patch optimistically initializes the new endpoints' device
structures before asking the device to switch to the new config.  If
the request fails then the endpoint information is already stored, so
we can use usb_hcd_alloc_bandwidth() to disable the endpoints with no
trouble.  The rest of the error path is slightly more complex now; we
have to disable the new interfaces and call put_device() rather than
simply deallocating them.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: Matthias Schniedermeyer <ms@citd.de>
CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 828b18866ce0907fdb67afe143d5d851deb9fec6)

BUG=None
TEST=Together with other cherry-picks: run BVT trybots on all platforms,
manually confirm that USB network/storage/input devices still work
(including across suspend/resume)

Change-Id: I4ba9bc75d096711a354580f2d562123b52b05bcc
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46072
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
drivers/usb/core/message.c