patch-2.4.0-test8 linux/drivers/usb/microtek.c

Next file: linux/drivers/usb/plusb.c
Previous file: linux/drivers/usb/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test7/linux/drivers/usb/microtek.c linux/drivers/usb/microtek.c
@@ -98,6 +98,10 @@
  *	20000603 Version 0.2.1
  *	20000620 minor cosmetic changes
  *	20000620 Version 0.2.2
+ *  20000822 Hopefully fixed deadlock in mts_remove_nolock()
+ *  20000822 Fixed minor race in mts_transfer_cleanup()
+ *  20000822 Fixed deadlock on submission error in queuecommand
+ *  20000822 Version 0.2.3
  */
 
 #include <linux/module.h>
@@ -129,7 +133,7 @@
 
 /* Should we do debugging? */
 
-#define MTS_DO_DEBUG
+// #define MTS_DO_DEBUG
 
 
 /* USB layer driver interface */
@@ -147,7 +151,7 @@
 
 /* Internal driver stuff */
 
-#define MTS_VERSION	"0.2.2"
+#define MTS_VERSION	"0.2.3"
 #define MTS_NAME	"microtek usb (rev " MTS_VERSION "): "
 
 #define MTS_WARNING(x...) \
@@ -332,9 +336,8 @@
 	MTS_DEBUG( "removing 0x%x from list\n",
 		   (int)to_remove );
 
+	lock_kernel();
 	mts_wait_abort(to_remove);
-	
-	down( &to_remove->lock );
 
 	MTS_DEBUG_GOT_HERE();
 	
@@ -358,6 +361,7 @@
 
 	MTS_DEBUG_GOT_HERE();
 	scsi_unregister_module(MODULE_SCSI_HA, &(to_remove->ctempl));
+	unlock_kernel();
 	
 	kfree( to_remove );
 }
@@ -391,7 +395,7 @@
 }
 
 static int mts_scsi_abort (Scsi_Cmnd *srb)
-/* interrupt context (!) */
+/* interrupt context (!) */ /* FIXME this is about to become task context */
 {
 	struct mts_desc* desc = (struct mts_desc*)(srb->host->hostdata[0]);
 
@@ -508,9 +512,9 @@
 {
 	struct mts_transfer_context* context = (struct mts_transfer_context*)transfer->context;
 	
-	up( &context->instance->lock );
 	if ( context->final_callback )
 		context->final_callback(context->srb);
+	up( &context->instance->lock );
 
 }
 
@@ -708,6 +712,7 @@
 
 		if(callback)
 			callback(srb);
+	up(&desc->lock); /* no further cleanup is done */
 
 		goto out;
 	}	

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)