<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/usb/core/message.c, branch v3.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.0</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2011-07-07T20:29:33Z</updated>
<entry>
<title>USB: additional regression fix for device removal</title>
<updated>2011-07-07T20:29:33Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2011-07-06T21:03:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ca5c485f55d326d9a23e4badd05890148aa53f74'/>
<id>urn:sha1:ca5c485f55d326d9a23e4badd05890148aa53f74</id>
<content type='text'>
Commit e534c5b831c8b8e9f5edee5c8a37753c808b80dc (USB: fix regression
occurring during device removal) didn't go far enough.  It failed to
take into account that when a driver claims multiple interfaces, it may
release them all at the same time.  As a result, some interfaces can
get released before they are unregistered, and we deadlock trying to
acquire the bandwidth_mutex that we already own.

This patch (asl478) handles this case by setting the "unregistering"
flag on all the interfaces before removing any of them.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: stable &lt;stable@kernel.org&gt;
Tested-by: Éric Piel &lt;eric.piel@tremplin-utc.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>USB: fix regression occurring during device removal</title>
<updated>2011-07-01T21:20:39Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2011-07-01T20:43:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e534c5b831c8b8e9f5edee5c8a37753c808b80dc'/>
<id>urn:sha1:e534c5b831c8b8e9f5edee5c8a37753c808b80dc</id>
<content type='text'>
This patch (as1476) fixes a regression introduced by
fccf4e86200b8f5edd9a65da26f150e32ba79808 (USB: Free bandwidth when
usb_disable_device is called).  usb_disconnect() grabs the
bandwidth_mutex before calling usb_disable_device(), which calls down
indirectly to usb_set_interface(), which tries to acquire the
bandwidth_mutex.

The fix causes usb_set_interface() to return early when it is called
for an interface that has already been unregistered, which is what
happens in usb_disable_device().

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Tested-by: Sarah Sharp &lt;sarah.a.sharp@linux.intel.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>USB: Free bandwidth when usb_disable_device is called.</title>
<updated>2011-06-15T21:05:18Z</updated>
<author>
<name>Sarah Sharp</name>
<email>sarah.a.sharp@linux.intel.com</email>
</author>
<published>2011-06-06T06:22:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fccf4e86200b8f5edd9a65da26f150e32ba79808'/>
<id>urn:sha1:fccf4e86200b8f5edd9a65da26f150e32ba79808</id>
<content type='text'>
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 0791971ba8fbc44e4f476079f856335ed45e6324
	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-&gt;ep_out and udev-&gt;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-&gt;ep_out
and udev-&gt;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-&gt;ep_out and udev-&gt;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-&gt;urb_list should be empty after the first call to
usb_disable_endpoint() returns.

2. It will set the entries in udev-&gt;ep_out and udev-&gt;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-&gt;bandwidth_mutex held.

This should be backported to kernels as old as 2.6.32.

Signed-off-by: Sarah Sharp &lt;sarah.a.sharp@linux.intel.com&gt;
Reported-by: Tanya Brokhman &lt;tlinder@codeaurora.org&gt;
Cc: ablay@codeaurora.org
Cc: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: stable@kernel.org
</content>
</entry>
<entry>
<title>usb: Change usb_hcd-&gt;bandwidth_mutex to a pointer.</title>
<updated>2011-03-14T01:07:14Z</updated>
<author>
<name>Sarah Sharp</name>
<email>sarah.a.sharp@linux.intel.com</email>
</author>
<published>2010-10-15T15:55:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d673bfcbfffdeb56064a6b1ee047b85590bed76c'/>
<id>urn:sha1:d673bfcbfffdeb56064a6b1ee047b85590bed76c</id>
<content type='text'>
Change the bandwith_mutex in struct usb_hcd to a pointer.  This will allow
the pointer to be shared across usb_hcds for the upcoming work to split
the xHCI driver roothub into a USB 2.0/1.1 and a USB 3.0 bus.

Signed-off-by: Sarah Sharp &lt;sarah.a.sharp@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>USB: make usb_mark_last_busy use pm_runtime_mark_last_busy</title>
<updated>2010-11-16T22:02:54Z</updated>
<author>
<name>Ming Lei</name>
<email>tom.leiming@gmail.com</email>
</author>
<published>2010-11-15T20:57:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6ddf27cdbc218a412d7e993fdc08e30eec2042ce'/>
<id>urn:sha1:6ddf27cdbc218a412d7e993fdc08e30eec2042ce</id>
<content type='text'>
Since the runtime-PM core already defines a .last_busy field in
device.power, this patch uses it to replace the .last_busy field
defined in usb_device and uses pm_runtime_mark_last_busy to implement
usb_mark_last_busy.

Signed-off-by: Ming Lei &lt;tom.leiming@gmail.com&gt;
Reviewed-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>USB: use the no_callbacks flag for interfaces</title>
<updated>2010-11-16T22:02:00Z</updated>
<author>
<name>Ming Lei</name>
<email>tom.leiming@gmail.com</email>
</author>
<published>2010-11-15T20:56:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=63defa73c8c1193c1273474440c30d34c2524597'/>
<id>urn:sha1:63defa73c8c1193c1273474440c30d34c2524597</id>
<content type='text'>
Call pm_runtime_no_callbacks to set no_callbacks flag for USB
interfaces.  Since interfaces cannot be power-managed separately from
their parent devices, there's no reason for the runtime-PM core to
invoke any callbacks for them.

Signed-off-by: Ming Lei &lt;tom.leiming@gmail.com&gt;
Reviewed-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>USB: disable endpoints after unbinding interfaces, not before</title>
<updated>2010-10-22T17:22:01Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2010-09-30T19:16:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=80f0cf3947889014d3a3dc0ad60fb87cfda4b12a'/>
<id>urn:sha1:80f0cf3947889014d3a3dc0ad60fb87cfda4b12a</id>
<content type='text'>
This patch (as1430) fixes a bug in usbcore.  When a device
configuration change occurs or a device is removed, the endpoints for
the old config should be completely disabled.  However it turns out
they aren't; this is because usb_unbind_interface() calls
usb_enable_interface() or usb_set_interface() to put interfaces back
in altsetting 0, which re-enables the interfaces' endpoints.

As a result, when a device goes through a config change or is
unconfigured, the ep_in[] and ep_out[] arrays may be left holding old
pointers to usb_host_endpoint structures.  If the device is
deauthorized these structures get freed, and the stale pointers cause
errors when the the device is eventually unplugged.

The solution is to disable the endpoints after unbinding the
interfaces instead of before.  This isn't as large a change as it
sounds, since usb_unbind_interface() disables all the interface's
endpoints anyway before calling the driver's disconnect routine,
unless the driver claims to support "soft" unbind.

This fixes Bugzilla #19192.  Thanks to "Tom" Lei Ming for diagnosing
the underlying cause of the problem.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Tested-by: Carsten Sommer &lt;carsten_sommer@ymail.com&gt;
CC: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>USB: fix bug in initialization of interface minor numbers</title>
<updated>2010-09-24T18:05:00Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2010-09-21T19:01:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0026e00523a85b90a92a93ddf6660939ecef3e54'/>
<id>urn:sha1:0026e00523a85b90a92a93ddf6660939ecef3e54</id>
<content type='text'>
Recent changes in the usbhid layer exposed a bug in usbcore.  If
CONFIG_USB_DYNAMIC_MINORS is enabled then an interface may be assigned
a minor number of 0.  However interfaces that aren't registered as USB
class devices also have their minor number set to 0, during
initialization.  As a result usb_find_interface() may return the
wrong interface, leading to a crash.

This patch (as1418) fixes the problem by initializing every
interface's minor number to -1.  It also cleans up the
usb_register_dev() function, which besides being somewhat awkwardly
written, does not unwind completely on all its error paths.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Tested-by: Philip J. Turmel &lt;philip@turmel.org&gt;
Tested-by: Gabriel Craciunescu &lt;nix.or.die@googlemail.com&gt;
Tested-by: Alex Riesen &lt;raa.lkml@gmail.com&gt;
Tested-by: Matthias Bayer &lt;jackdachef@gmail.com&gt;
CC: Jiri Kosina &lt;jkosina@suse.cz&gt;
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>usb: allow drivers to use allocated bandwidth until unbound</title>
<updated>2010-09-04T00:33:40Z</updated>
<author>
<name>Thadeu Lima de Souza Cascardo</name>
<email>cascardo@holoscopio.com</email>
</author>
<published>2010-08-28T06:06:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0791971ba8fbc44e4f476079f856335ed45e6324'/>
<id>urn:sha1:0791971ba8fbc44e4f476079f856335ed45e6324</id>
<content type='text'>
When using the remove sysfs file, the device configuration is set to -1
(unconfigured). This eventually unbind drivers with the bandwidth_mutex
held. Some drivers may call functions that hold said mutex, like
usb_reset_device. This is the case for rtl8187, for example. This will
lead to the same process holding the mutex twice, which deadlocks.

Besides, according to Alan Stern:
"The deadlock problem probably could be handled somehow, but there's a
separate issue: Until the usb_disable_device call finishes unbinding
the drivers, the drivers are free to continue using their allocated
bandwidth.  We musn't change the bandwidth allocations until after the
unbinding is done.  So this patch is indeed necessary."

Unbinding the driver before holding the bandwidth_mutex solves the
problem. If any operation after that fails, drivers are not bound again.
But that would be a problem anyway that the user may solve resetting the
device configuration to one that works, just like he would need to do in
most other failure cases.

Signed-off-by: Thadeu Lima de Souza Cascardo &lt;cascardo@holoscopio.com&gt;
Cc: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: Sarah Sharp &lt;sarah.a.sharp@linux.intel.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>USB: fix oops in usb_sg_init()</title>
<updated>2010-06-30T15:16:06Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2010-06-18T14:16:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=64d65872f96e2a754caa12ef48949c314384bd9f'/>
<id>urn:sha1:64d65872f96e2a754caa12ef48949c314384bd9f</id>
<content type='text'>
This patch (as1401) fixes a bug in usb_sg_init() that can cause an
invalid pointer dereference.  An inner loop reuses some local variables
in an unsafe manner, so new variables are introduced.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Tested-by: Ajay Kumar Gupta &lt;ajay.gupta@ti.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
</feed>
