patch-2.1.103 linux/drivers/scsi/hosts.c

Next file: linux/drivers/scsi/ppa.c
Previous file: linux/drivers/scsi/fdomain.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.102/linux/drivers/scsi/hosts.c linux/drivers/scsi/hosts.c
@@ -575,6 +575,7 @@
 {
     static int called = 0;
     int i, pcount;
+    unsigned long flags;
     Scsi_Host_Template * tpnt;
     struct Scsi_Host * shpnt;
     const char * name;
@@ -590,9 +591,27 @@
 	 */
 	
 	pcount = next_scsi_host;
-	if ((tpnt->detect) &&
-	    (tpnt->present =
-	     tpnt->detect(tpnt)))
+	if (tpnt->detect) {
+
+           /* The detect routine must carefully spinunlock/spinlock if 
+              it enables interrupts, since all interrupt handlers do 
+              spinlock as well.
+              All lame drivers are going to fail due to the following 
+              spinlock. For the time beeing let's use it only for drivers 
+              using the new scsi code. NOTE: the detect routine could
+              redefine the value tpnt->use_new_eh_code. (DB, 13 May 1998) */
+
+           if (tpnt->use_new_eh_code) {
+              spin_lock_irqsave(&io_request_lock, flags);
+              tpnt->present = tpnt->detect(tpnt);
+              spin_unlock_irqrestore(&io_request_lock, flags);
+              }
+           else
+              tpnt->present = tpnt->detect(tpnt);
+
+           }
+
+	if (tpnt->detect && tpnt->present)
 	{
 	    /* The only time this should come up is when people use
 	     * some kind of patched driver of some kind or another. */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov