kernel_optimize_test/drivers/usb/usbip
Nobuo Iwata a38711a88b usbip: auto retry for concurrent attach
This patch adds recovery from false busy state on concurrent attach
operation.

The procedure of attach operation is as below.
1) Find an unused port in /sys/devices/platform/vhci_hcd/status.
(userspace)
2) Request attach found port to driver through
/sys/devices/platform/vhci_hcd/attach. (userspace)
3) Lock table, reserve requested port and unlock table. (vhci driver)

Attaching more than one remote devices concurrently, same unused port
number will be found in step-1. Then one request will succeed and
others will fail even though there are some unused ports.

With this patch, driver returns EBUSY when requested port has already
been used. In this case, attach command retries from step-1: finding
another unused port. If there's no unused port, the attach operation
will fail in step-1. Otherwise it retries automatically using another
unused port.

vhci-hcd's interface (only errno) is changed as following.

Current	errno	New errno	Condition
EINVAL		same as left	specified port number is in invalid
				range
EAGAIN		same as left	platform_get_drvdata() failed
EINVAL		same as left	specified socket fd is not valid
EINVAL		EBUSY		specified port status is not free

The errno EBUSY was not used in userspace
src/usbip_attach.c:import_device(). It is needed to distinguish the
condition to be able to retry from other unrecoverable errors.

It is possible to avoid this failure by introducing userspace exclusive
control. But it's exaggerated for this special condition. The locking
itself has done in driver.
As an alternate solution, userspace doesn't specify port number, driver
searches unused port and it returns port number to the userspace. With
this solution, the interface is much different than this patch.

Signed-off-by: Nobuo Iwata <nobuo.iwata@fujixerox.co.jp>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-31 18:08:45 +02:00
..
Kconfig usb: Kconfig: using select for USB_COMMON dependency 2016-09-27 12:20:17 +02:00
Makefile usbip: vudc: Add vudc to Kconfig 2016-04-26 15:19:50 -07:00
README
stub_dev.c usbip: fix NULL pointer dereference on errors 2016-04-28 12:28:08 -07:00
stub_main.c USB: usbip: remove unneeded MODULE_VERSION() usage 2017-07-22 15:56:53 +02:00
stub_rx.c usb: usbip: stub_rx: don't print error when allocating urb fails 2016-08-15 15:54:27 +02:00
stub_tx.c usb: usbip: set buffer pointers to NULL after free 2017-06-13 10:48:24 +02:00
stub.h usbip: fix NULL pointer dereference on errors 2016-04-28 12:28:08 -07:00
usbip_common.c USB: usbip: remove unneeded MODULE_VERSION() usage 2017-07-22 15:56:53 +02:00
usbip_common.h USB: usbip: remove unneeded MODULE_VERSION() usage 2017-07-22 15:56:53 +02:00
usbip_event.c usbip: event handler as one thread 2016-04-19 04:33:15 +09:00
vhci_hcd.c USB: usbip: remove unneeded MODULE_VERSION() usage 2017-07-22 15:56:53 +02:00
vhci_rx.c usbip: vhci-hcd: Set the vhci structure up to work 2017-06-13 10:51:10 +02:00
vhci_sysfs.c usbip: auto retry for concurrent attach 2017-08-31 18:08:45 +02:00
vhci_tx.c usb: usbip: Fix possible deadlocks reported by lockdep 2016-02-03 13:52:10 -08:00
vhci.h usbip: vhci-hcd: Clean up the code by adding a new macro 2017-06-13 10:51:10 +02:00
vudc_dev.c usbip: vudc: Refactor init_vudc_hw() to be more obvious 2016-12-05 15:08:45 +01:00
vudc_main.c usbip: vudc: Add VUDC main file 2016-04-26 15:19:50 -07:00
vudc_rx.c usb: usbip: vudc: fix left shift overflow 2016-08-30 22:28:52 +02:00
vudc_sysfs.c usb: usbip: remove null check 2016-06-07 22:18:39 -07:00
vudc_transfer.c usbip: vudc: fix: Clear already_seen flag also for ep0 2016-12-05 15:08:45 +01:00
vudc_tx.c usbip: vudc: Add vudc_tx 2016-04-26 15:19:50 -07:00
vudc.h usb: usbip: vudc: Rename find_endpoint() to vudc_find_endpoint() 2016-04-28 12:28:08 -07:00

TODO:
	- more discussion about the protocol
	- testing
	- review of the userspace interface
	- document the protocol

Please send patches for this code to Greg Kroah-Hartman <greg@kroah.com>