[4264] in linux-scsi channel archive

home help back first fref pref prev next nref lref last post

update to aha152x.c

daemon@ATHENA.MIT.EDU (Oliver Neukum)
Wed Jul 1 14:05:52 1998

Date: 	Wed, 1 Jul 1998 18:24:56 +0200 (CEST)
From: Oliver Neukum <neukum@fachschaft.org.chemie.uni-muenchen.de>
To: linux-scsi@vger.rutgers.edu

Dear Developers,
i would like to present an update to aha152x.c .
It has been submitted to the maintainer, who has not replied.
However as the driver has not been changed since 1996, i hope 
an update is welcome. It has been tested on my system(UP,Pentium) and
performed flawlessly controlling my scanner. It saves 1 page on my setup.
The patch has been tested on 2.1.105 and 2.1.107.
Oliver Neukum

-----------------------------------------------

--- aha152x.c	Mon Jun 29 18:35:25 1998
+++ linux/drivers/scsi/aha152x.c	Tue Jun 30 23:27:23 1998
@@ -23,6 +23,10 @@
  * $Id: aha152x.c,v 1.18 1996/09/07 20:10:40 fischer Exp $
  *
  * $Log: aha152x.c,v $
+ * Revision 1.19  1998/06/29 19:14:03  neukum
+ * - basic change for SMP
+ * - __initfunc added
+ *
  * Revision 1.18  1996/09/07 20:10:40  fischer
  * - fixed can_queue handling (multiple outstanding commands working again)
  *
@@ -343,7 +347,7 @@
 #include <linux/wait.h>
 #include <linux/ioport.h>
 #include <linux/proc_fs.h>
-
+#include <linux/init.h>
 #include "aha152x.h"
 #include <linux/stat.h>
 
@@ -568,6 +572,10 @@
 #define SIGNATURE_COUNT (sizeof(signatures) / sizeof(struct signature))
 #endif
 
+/* try make it acceptable to SMP */
+spinlock_t aha152x_lock = SPIN_LOCK_UNLOCKED;
+/* UNTESTED on SMP */
+/* feedback to: c188@org.chemie.uni-muenchen.de */
 
 static void do_pause(unsigned amount) /* Pause for amount*10 milliseconds */
 {
@@ -677,7 +685,10 @@
 }
 
 /* called from init/main.c */
-void aha152x_setup(char *str, int *ints)
+/* is this still true ? */
+
+__initfunc(void aha152x_setup(char *str, int *ints))
+
 {
   if(setup_count>2)
     panic("aha152x: you can only configure up to two controllers\n");
@@ -708,7 +719,7 @@
 /*
  * Test, if port_base is valid.
  */
-static int aha152x_porttest(int io_port)
+__initfunc(static int aha152x_porttest(int io_port))
 {
   int i;
 
@@ -726,7 +737,7 @@
   return(i==16);
 }
 
-int aha152x_checksetup(struct aha152x_setup *setup)
+__initfunc(int aha152x_checksetup(struct aha152x_setup *setup))
 {
   int i;
   
@@ -774,7 +785,8 @@
 }
 
 
-int aha152x_detect(Scsi_Host_Template * tpnt)
+__initfunc(int aha152x_detect(Scsi_Host_Template * tpnt))
+
 {
   int                 i, j, ok;
 #if defined(AUTOCONF)
@@ -1123,8 +1135,8 @@
   SCpnt->SCp.sent_command        = 0;
 
   /* Turn led on, when this is the first command. */
-  save_flags(flags);
-  cli();
+ 
+  spin_lock_irqsave(&aha152x_lock, flags);
   HOSTDATA(shpnt)->commands++;
   if(HOSTDATA(shpnt)->commands==1)
     SETPORT(PORTA, 1);
@@ -1140,7 +1152,8 @@
     SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
     SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
   }
-  restore_flags(flags);
+  
+  spin_unlock_irqrestore(&aha152x_lock, flags);
 
 #if defined(DEBUG_RACE)
   leave_driver("queue");
@@ -1168,9 +1181,7 @@
   unsigned long flags;
   Scsi_Cmnd *ptr, *prev;
 
-  save_flags(flags);
-  cli();
-
+  spin_lock_irqsave(&aha152x_lock, flags);
 #if defined(DEBUG_ABORT)
   if(HOSTDATA(shpnt)->debug & debug_abort) { 
     printk("aha152x: abort(), SCpnt=0x%08x, ", (unsigned int) SCpnt);
@@ -1193,7 +1204,7 @@
 
     HOSTDATA(shpnt)->commands--; 
 
-    restore_flags(flags);
+    spin_unlock_irqrestore(&aha152x_lock, flags);
 
     ptr->host_scribble = NULL;
     ptr->result = DID_ABORT << 16;
@@ -1210,7 +1221,7 @@
     if(!CURRENT_SC)
       printk("bus busy w/o current command, ");
  
-    restore_flags(flags);
+    spin_unlock_irqrestore(&aha152x_lock, flags);
 
     return SCSI_ABORT_BUSY;
   }
@@ -1220,8 +1231,8 @@
   if(CURRENT_SC) { 
     HOSTDATA(shpnt)->commands--; 
 
-    /* target entered bus free before COMMAND COMPLETE, nothing to abort */
-    restore_flags(flags);
+    /* target entered bus free before COMMAND COMPLETE, nothing to abort */ 
+    spin_unlock_irqrestore(&aha152x_lock, flags);
     CURRENT_SC->result = DID_ERROR << 16;
     CURRENT_SC->scsi_done(CURRENT_SC);
     CURRENT_SC = (Scsi_Cmnd *) NULL;
@@ -1238,7 +1249,7 @@
   if(!ptr) {
     /* command wasn't found */
     printk("command not found\n");
-    restore_flags(flags);
+    spin_unlock_irqrestore(&aha152x_lock, flags);
 
     return SCSI_ABORT_NOT_RUNNING;
   }
@@ -1271,8 +1282,8 @@
     HOSTDATA(shpnt)->abort_result=SCSI_ABORT_SUCCESS;
     HOSTDATA(shpnt)->aborting++;
     HOSTDATA(shpnt)->abortion_complete=0;
-
-    restore_flags(flags);
+    
+    spin_unlock_irqrestore(&aha152x_lock, flags);
 
     /* sleep until the abortion is complete */
     while(!HOSTDATA(shpnt)->abortion_complete)
@@ -1282,7 +1293,7 @@
     return HOSTDATA(shpnt)->abort_result;
   } else {
     /* we're already aborting a command */
-    restore_flags(flags);
+     spin_unlock_irqrestore(&aha152x_lock, flags);
 
     return SCSI_ABORT_BUSY;
   }
@@ -1353,8 +1364,8 @@
       CURRENT_SC=NULL;
     }
 
-    save_flags(flags);
-    cli();
+
+    spin_lock_irqsave(&aha152x_lock, flags);
     prev=NULL; ptr=DISCONNECTED_SC;
     while(ptr) {
       if(!ptr->device->soft_reset) {
@@ -1375,7 +1386,7 @@
         ptr = (Scsi_Cmnd *) ptr->host_scribble;
       }
     }
-    restore_flags(flags);
+    spin_unlock_irqrestore(&aha152x_lock, flags);
 
 #if defined(DEBUG_RESET)
     if(HOSTDATA(shpnt)->debug & debug_reset) {
@@ -1480,9 +1491,9 @@
       printk("done(%x), ", error);
 #endif
 
-    save_flags(flags);
-    cli();
-
+    
+    /* SMP 13 */ /* will it crash here ? :-; */
+    spin_lock_irqsave(&aha152x_lock, flags);
     done_SC = CURRENT_SC;
     CURRENT_SC = NULL;
 
@@ -1495,8 +1506,7 @@
     if(HOSTDATA(shpnt)->debug & debug_queues) 
       printk("ok (%d), ", HOSTDATA(shpnt)->commands);
 #endif
-    restore_flags(flags);
-
+    spin_unlock_irqrestore(&aha152x_lock, flags);
     SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
     SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
 
@@ -1575,11 +1585,10 @@
       if(HOSTDATA(shpnt)->debug & debug_queues)
         printk("i+, ");
 #endif
-      save_flags(flags);
-      cli();
+      spin_lock_irqsave(&aha152x_lock, flags);
       append_SC(&ISSUE_SC, CURRENT_SC);
       CURRENT_SC=NULL;
-      restore_flags(flags);
+      spin_unlock_irqrestore(&aha152x_lock, flags);
     }
 
     /* disable sequences */
@@ -1638,8 +1647,7 @@
       printk("identify=%02x, lun=%d, ", identify_msg, identify_msg & 0x3f);
 #endif
 
-    save_flags(flags);
-    cli();
+    spin_lock_irqsave(&aha152x_lock, flags);
 
 #if defined(DEBUG_QUEUES)
     if(HOSTDATA(shpnt)->debug & debug_queues)
@@ -1653,7 +1661,7 @@
     }
 
     CURRENT_SC->SCp.phase &= ~disconnected;
-    restore_flags(flags);
+    spin_unlock_irqrestore(&aha152x_lock, flags); 
 
     make_acklow(shpnt);
     if(getphase(shpnt)!=P_MSGI) {
@@ -1671,14 +1679,13 @@
   if(!CURRENT_SC) {
     /* bus is free to issue a queued command */
     if(TESTHI(SSTAT1, BUSFREE) && ISSUE_SC) {
-      save_flags(flags);
-      cli();
+      spin_lock_irqsave(&aha152x_lock, flags);  
 #if defined(DEBUG_QUEUES)
       if(HOSTDATA(shpnt)->debug & debug_queues)
         printk("i-, ");
 #endif
       CURRENT_SC = remove_first_SC(&ISSUE_SC);
-      restore_flags(flags);
+      spin_unlock_irqrestore(&aha152x_lock, flags);
 
 #if defined(DEBUG_INTR) || defined(DEBUG_SELECTION) || defined(DEBUG_PHASES)
       if(HOSTDATA(shpnt)->debug & (debug_intr|debug_selection|debug_phases))
@@ -2142,8 +2149,7 @@
         SETPORT(SXFRCTL0, CH1|CLRCH1);
 
       if(CURRENT_SC->SCp.phase & disconnected) {
-        save_flags(flags);
-        cli();
+        spin_lock_irqsave(&aha152x_lock, flags);
 #if defined(DEBUG_QUEUES)
         if(HOSTDATA(shpnt)->debug & debug_queues)
           printk("d+, ");
@@ -2151,7 +2157,7 @@
         append_SC(&DISCONNECTED_SC, CURRENT_SC);
         CURRENT_SC->SCp.phase |= 1<<16;
         CURRENT_SC = NULL;
-        restore_flags(flags);
+        spin_unlock_irqrestore(&aha152x_lock, flags);
 
         SETBITS(SCSISEQ, ENRESELI);
 
@@ -2792,8 +2798,7 @@
 {
   unsigned long flags;
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&aha152x_lock, flags);
   printk("aha152x: entering %s() (%x)\n", func, jiffies);
   if(in_driver) {
     printk("%s should leave first.\n", should_leave);
@@ -2802,15 +2807,14 @@
 
   in_driver++;
   should_leave=func;
-  restore_flags(flags);
+  spin_unlock_irqrestore(&aha152x_lock, flags);
 }
 
 static void leave_driver(const char *func)
 {
   unsigned long flags;
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&aha152x_lock, flags);
   printk("\naha152x: leaving %s() (%x)\n", func, jiffies);
   if(!in_driver) {
     printk("aha152x: %s already left.\n", should_leave);
@@ -2819,7 +2823,7 @@
 
   in_driver--;
   should_leave=func;
-  restore_flags(flags);
+  spin_unlock_irqrestore(&aha152x_lock, flags);
 }
 #endif
 
@@ -2881,8 +2885,7 @@
   unsigned long flags;
   Scsi_Cmnd *ptr;
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&aha152x_lock, flags);
   printk("QUEUE STATUS:\nissue_SC:\n");
   for(ptr=ISSUE_SC; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
     show_command(ptr);
@@ -2899,7 +2902,7 @@
 
   disp_ports(shpnt);
   disp_enintr(shpnt);
-  restore_flags(flags);
+  spin_unlock_irqrestore(&aha152x_lock, flags);
 }
 
 int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt)
@@ -3173,8 +3176,7 @@
   
   SPRINTF(AHA152X_REVID "\n");
   
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&aha152x_lock, flags);
   
   SPRINTF("ioports 0x%04lx to 0x%04lx\n",
           shpnt->io_port, shpnt->io_port+shpnt->n_io_port-1);
@@ -3257,7 +3259,7 @@
   } else
     SPRINTF("no disconnected commands\n");
   
-  restore_flags(flags);
+  spin_unlock_irqrestore(&aha152x_lock, flags);
 
   pos += get_ports(shpnt, pos);
   



-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.rutgers.edu

home help back first fref pref prev next nref lref last post