linux/drivers/staging/usbip
Max Vozeler 584c5b7cf0 staging: usbip: Process event flags without delay
The way the event handler works can cause it to delay
events until eventual wakeup for another event.

For example, on device detach (vhci):

 - Write to sysfs detach file
    -> usbip_event_add(VDEV_EVENT_DOWN)
      -> wakeup()

#define VDEV_EVENT_DOWN (USBIP_EH_SHUTDOWN | USBIP_EH_RESET).

 - Event thread wakes up and passes the event to
   event_handler() to process.

 - It processes and clears the USBIP_EH_SHUTDOWN
   flag then returns.

 - The outer event loop (event_handler_loop()) calls
   wait_event_interruptible().

The processing of the second flag which is part of
VDEV_EVENT_DOWN (USBIP_EH_RESET) did not happen yet.
It is delayed until the next event.

This means the ->reset callback may not happen for
a long time (if ever), leaving the usbip port in a
weird state which prevents its reuse.

This patch changes the handler to process all flags
before waiting for another wakeup.

I have verified this change to fix a problem which
prevented reattach of a usbip device. It also helps
for socket errors which missed the RESET as well.

The delayed event processing also affects the stub
side of usbip and the error handling there.

Signed-off-by: Max Vozeler <mvz@vozeler.com>
Reported-by: Marco Lancione <marco@optikam.com>
Tested-by: Luc Jalbert <ljalbert@optikam.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-09-21 11:00:22 -07:00
..
Kconfig Staging: usbip: Seperate usbip config debug from CONFIG_USB_DEBUG 2010-03-03 16:42:52 -08:00
Makefile Staging: usbip: Seperate usbip config debug from CONFIG_USB_DEBUG 2010-03-03 16:42:52 -08:00
README
stub_dev.c staging: usbip: fix memory leak 2010-08-31 14:51:52 -07:00
stub_main.c Staging: usbip: fix multiple interfaces 2010-07-27 11:06:29 -07:00
stub_rx.c Staging: usbip: fix up build error 2010-07-27 11:12:21 -07:00
stub_tx.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
stub.h Staging: usbip: fix multiple interfaces 2010-07-27 11:06:29 -07:00
usbip_common.c staging: usbip: resolved a space in a comment 2010-09-16 12:37:36 -07:00
usbip_common.h Staging: usbip: fix typos concerning "sequential" 2010-07-08 13:57:58 -07:00
usbip_event.c staging: usbip: Process event flags without delay 2010-09-21 11:00:22 -07:00
vhci_hcd.c staging: usbip: Notify usb core of port status changes 2010-09-21 11:00:21 -07:00
vhci_rx.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
vhci_sysfs.c
vhci_tx.c staging: usbip: fix coding style issues in the usbip driver 2010-05-11 11:35:46 -07:00
vhci.h USB: make hcd.h public (drivers dependency) 2010-05-20 13:21:30 -07:00

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

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