From 2f67cd5b1d5066d11761aebb0bf4b76bc253cc99 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 16 Aug 2007 16:16:00 -0400 Subject: usb-storage: fix bugs in the disconnect pathway This patch (as961) fixes a couple of bugs in the disconnect pathway of usb-storage. The first problem, which apparently has been around for a while although nobody noticed it, shows up when an aborted command is still pending when a disconnect occurs. The SCSI error-handler will continue to wait in command_abort() until the us->notify completion is signalled. Thus quiesce_and_remove_host() needs to signal it. The second problem was introduced recently along with autosuspend support. Since usb_stor_scan_thread() now calls usb_autopm_put_interface() before exiting, we can't simply leave the scanning thread running after a disconnect; we must wait until the thread exits. This is solved by adding a new struct completion to the private data structure. Fortuitously, it allows the removal of the rather clunky mechanism used in the past to insure that all threads have finished before the module is unloaded. Signed-off-by: Alan Stern CC: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/usb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/storage/usb.h') diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 6445665b1577..8d87503e2560 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -150,6 +150,7 @@ struct us_data { struct semaphore sema; /* to sleep thread on */ struct completion notify; /* thread begin/end */ wait_queue_head_t delay_wait; /* wait during scan, reset */ + struct completion scanning_done; /* wait for scan thread */ /* subdriver information */ void *extra; /* Any extra data */ -- cgit v1.2.3