This patch avoids sending URBs which are part of the reset system when the
device is being disconnected.  It also makes the control thread avoid
starting anything for a device in that state.

Greg, please apply.

Matt

# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.718   -> 1.719  
#       drivers/usb/storage/scsiglue.c  1.48    -> 1.49   
#       drivers/usb/storage/transport.c 1.86    -> 1.87   
#       drivers/usb/storage/usb.c       1.77    -> 1.78   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/06/28      [EMAIL PROTECTED]       1.719
# Avoid sending URBs to devices which are disconnectig.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c    Sat Jun 28 20:32:32 2003
+++ b/drivers/usb/storage/scsiglue.c    Sat Jun 28 20:32:32 2003
@@ -168,7 +168,11 @@
 
        /* lock the device pointers and do the reset */
        down(&(us->dev_semaphore));
-       result = us->transport_reset(us);
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+               result = FAILED;
+               US_DEBUGP("No reset during disconnect\n");
+       } else
+               result = us->transport_reset(us);
        up(&(us->dev_semaphore));
 
        /* lock access to the state and clear it */
@@ -204,7 +208,7 @@
        down(&(us->dev_semaphore));
        if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
                result = -EIO;
-               US_DEBUGP("Attempt to reset during disconnect\n");
+               US_DEBUGP("No reset during disconnect\n");
        } else if (us->pusb_dev->actconfig->desc.bNumInterfaces != 1) {
                result = -EBUSY;
                US_DEBUGP("Refusing to reset a multi-interface device\n");
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c   Sat Jun 28 20:32:33 2003
+++ b/drivers/usb/storage/transport.c   Sat Jun 28 20:32:33 2003
@@ -1065,6 +1065,10 @@
        schedule_timeout(HZ*6);
        set_current_state(TASK_RUNNING);
        down(&us->dev_semaphore);
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+               US_DEBUGP("Reset interrupted by disconnect\n");
+               return FAILED;
+       }
 
        US_DEBUGP("Soft reset: clearing bulk-in endpoint halt\n");
        result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c Sat Jun 28 20:32:33 2003
+++ b/drivers/usb/storage/usb.c Sat Jun 28 20:32:33 2003
@@ -338,10 +338,16 @@
                /* lock the device pointers */
                down(&(us->dev_semaphore));
 
+               /* don't do anything if we are disconnecting */
+               if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+                       US_DEBUGP("No command during disconnect\n");
+                       us->srb->result = DID_BAD_TARGET << 16;
+               }
+
                /* reject the command if the direction indicator 
                 * is UNKNOWN
                 */
-               if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) {
+               else if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) {
                        US_DEBUGP("UNKNOWN data direction\n");
                        us->srb->result = DID_ERROR << 16;
                }
-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

THEY CASTRATED MY QUAKE BITS! I WANT THEM BACK!!!!
                                        -- Greg
User Friendly, 3/27/1998

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to