This patch fixes a thread-exit problem when the usb-storage module is
unloaded with a preemptable kernel.  Please refer to the comments in the
code for more detail.

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.1840  -> 1.1841 
#       drivers/usb/storage/usb.c       1.103   -> 1.104  
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/11/02      [EMAIL PROTECTED]       1.1841
# Fix a thread-exit problem in the module-remove case.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c Sun Nov  2 10:57:01 2003
+++ b/drivers/usb/storage/usb.c Sun Nov  2 10:57:01 2003
@@ -417,10 +417,21 @@
                scsi_unlock(host);
        } /* for (;;) */
 
-       /* notify the exit routine that we're actually exiting now */
-       complete(&(us->notify));
-
-       return 0;
+       /* notify the exit routine that we're actually exiting now 
+        *
+        * complete()/wait_for_completion() is similar to up()/down(),
+        * except that complete() is safe in the case where the structure
+        * is getting deleted in a parallel mode of execution (i.e. just
+        * after the down() -- that's necessary for the thread-shutdown
+        * case.
+        *
+        * complete_and_exit() goes even further than this -- it is safe in
+        * the case that the thread of the caller is going away (not just
+        * the structure) -- this is necessary for the module-remove case.
+        * This is important in preemption kernels, which transfer the flow
+        * of execution immediately upon a complete().
+        */
+       complete_and_exit(&(us->notify), 0);
 }      
 
 /***********************************************************************

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

Way to go, lava boy.
                                        -- Stef to Greg
User Friendly, 3/26/1998

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to