ChangeSet 1.2181.4.62, 2005/03/24 15:13:53-08:00, [EMAIL PROTECTED]
[PATCH] USB Storage: combine waitqueues
This patch started life as as476, and has been rediffed against the tip.
However, that was a few days ago.
This patch combines the two separate waitqueue heads used by the
scsi-scanning thread and the device-reset routine into one. After all,
until the scanning thread is through waiting there will be no SCSI
devices and hence no device resets.
Once the scanning thread is done waiting, the waitqueue can be used by
the
reset logic -- so even if the act of scanning produces resets, we're
fine.
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Matthew Dharm <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
transport.c | 2 +-
usb.c | 14 ++++++--------
usb.h | 8 +++-----
3 files changed, 10 insertions(+), 14 deletions(-)
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c 2005-03-30 15:17:19 -08:00
+++ b/drivers/usb/storage/transport.c 2005-03-30 15:17:19 -08:00
@@ -1159,7 +1159,7 @@
/* Give the device some time to recover from the reset,
* but don't delay disconnect processing. */
- wait_event_interruptible_timeout(us->dev_reset_wait,
+ wait_event_interruptible_timeout(us->delay_wait,
test_bit(US_FLIDX_DISCONNECTING, &us->flags),
HZ*6);
if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c 2005-03-30 15:17:19 -08:00
+++ b/drivers/usb/storage/usb.c 2005-03-30 15:17:19 -08:00
@@ -844,7 +844,7 @@
printk(KERN_DEBUG "usb-storage: waiting for device "
"to settle before scanning\n");
retry:
- wait_event_interruptible_timeout(us->scsi_scan_wait,
+ wait_event_interruptible_timeout(us->delay_wait,
test_bit(US_FLIDX_DISCONNECTING, &us->flags),
delay_use * HZ);
if (current->flags & PF_FREEZE) {
@@ -893,9 +893,7 @@
init_MUTEX(&(us->dev_semaphore));
init_MUTEX_LOCKED(&(us->sema));
init_completion(&(us->notify));
- init_waitqueue_head(&us->dev_reset_wait);
- init_waitqueue_head(&us->scsi_scan_wait);
- init_completion(&us->scsi_scan_done);
+ init_waitqueue_head(&us->delay_wait);
/* Associate the us_data structure with the USB device */
result = associate_dev(us, intf);
@@ -988,13 +986,13 @@
US_DEBUGP("storage_disconnect() called\n");
/* Prevent new USB transfers, stop the current command, and
- * interrupt a device-reset delay */
+ * interrupt a SCSI-scan or device-reset delay */
set_bit(US_FLIDX_DISCONNECTING, &us->flags);
usb_stor_stop_transport(us);
- wake_up(&us->dev_reset_wait);
+ wake_up(&us->delay_wait);
- /* Interrupt the SCSI-device-scanning thread's time delay */
- wake_up(&us->scsi_scan_wait);
+ /* It doesn't matter if the SCSI-scanning thread is still running.
+ * The thread will exit when it sees the DISCONNECTING flag. */
/* Wait for the current command to finish, then remove the host */
down(&us->dev_semaphore);
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h 2005-03-30 15:17:19 -08:00
+++ b/drivers/usb/storage/usb.h 2005-03-30 15:17:19 -08:00
@@ -169,11 +169,9 @@
dma_addr_t iobuf_dma;
/* mutual exclusion and synchronization structures */
- struct semaphore sema; /* to sleep thread on */
- struct completion notify; /* thread begin/end */
- wait_queue_head_t dev_reset_wait; /* wait during reset */
- wait_queue_head_t scsi_scan_wait; /* wait before scanning */
- struct completion scsi_scan_done; /* scan thread end */
+ struct semaphore sema; /* to sleep thread on */
+ struct completion notify; /* thread begin/end */
+ wait_queue_head_t delay_wait; /* wait during scan, reset */
/* subdriver information */
void *extra; /* Any extra data */
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html