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.

Greg, please apply.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Matthew Dharm <[EMAIL PROTECTED]>

Matt

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/03/06 18:05:27-08:00 [EMAIL PROTECTED] 
#   as477
# 
# drivers/usb/storage/usb.h
#   2005/03/06 18:04:58-08:00 [EMAIL PROTECTED] +3 -5
#   as477
# 
# drivers/usb/storage/usb.c
#   2005/03/06 18:04:58-08:00 [EMAIL PROTECTED] +6 -8
#   as477
# 
# drivers/usb/storage/transport.c
#   2005/03/06 18:04:58-08:00 [EMAIL PROTECTED] +1 -1
#   as477
# 
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c   2005-03-13 21:33:16 -08:00
+++ b/drivers/usb/storage/transport.c   2005-03-13 21:33:16 -08:00
@@ -1158,7 +1158,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-13 21:33:16 -08:00
+++ b/drivers/usb/storage/usb.c 2005-03-13 21:33:16 -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-13 21:33:16 -08:00
+++ b/drivers/usb/storage/usb.h 2005-03-13 21:33:16 -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          */

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

Sir, for the hundreth time, we do NOT carry 600-round boxes of belt-fed 
suction darts!
                                        -- Salesperson to Greg
User Friendly, 12/30/1997

Attachment: pgpkTNQkgeMwo.pgp
Description: PGP signature

Reply via email to