]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
usb: allow drivers to use allocated bandwidth until unbound
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 28 Aug 2010 06:06:29 +0000 (03:06 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Sep 2010 20:36:20 +0000 (13:36 -0700)
commit91ffbb4a336762e363ef74197e712010c6c31e6f
tree685d8dc843d70de07ed6d1ffafa5bbceb5087659
parenta1af0d0dd0d3258f673c509b20c9834e78dbbfac
usb: allow drivers to use allocated bandwidth until unbound

commit 0791971ba8fbc44e4f476079f856335ed45e6324 upstream.

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 <cascardo@holoscopio.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/message.c