[SCSI] Disable sym2 driver queueing
[safe/jmp/linux-2.6] / drivers / scsi / sym53c8xx_2 / sym_hipd.c
index 8260f04..a6cbb90 100644 (file)
@@ -40,7 +40,6 @@
 
 #include <linux/slab.h>
 #include <asm/param.h>         /* for timeouts in units of HZ */
-#include <scsi/scsi_dbg.h>
 
 #include "sym_glue.h"
 #include "sym_nvram.h"
@@ -473,7 +472,7 @@ static int sym_getpciclock (struct sym_hcb *np)
  *  calculations more simple.
  */
 #define _5M 5000000
-static u32 div_10M[] = {2*_5M, 3*_5M, 4*_5M, 6*_5M, 8*_5M, 12*_5M, 16*_5M};
+static const u32 div_10M[] = {2*_5M, 3*_5M, 4*_5M, 6*_5M, 8*_5M, 12*_5M, 16*_5M};
 
 /*
  *  Get clock factor and sync divisor for a given 
@@ -919,6 +918,8 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
 
                tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED);
                tp->usrtags = SYM_SETUP_MAX_TAG;
+               tp->usr_width = np->maxwide;
+               tp->usr_period = 9;
 
                sym_nvram_setup_target(tp, i, nvram);
 
@@ -972,8 +973,8 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
  *
  *  Has to be called with interrupts disabled.
  */
-#ifndef CONFIG_SCSI_SYM53C8XX_IOMAPPED
-static int sym_regtest (struct sym_hcb *np)
+#ifdef CONFIG_SCSI_SYM53C8XX_MMIO
+static int sym_regtest(struct sym_hcb *np)
 {
        register volatile u32 data;
        /*
@@ -991,20 +992,25 @@ static int sym_regtest (struct sym_hcb *np)
 #endif
                printf ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n",
                        (unsigned) data);
-               return (0x10);
+               return 0x10;
        }
-       return (0);
+       return 0;
+}
+#else
+static inline int sym_regtest(struct sym_hcb *np)
+{
+       return 0;
 }
 #endif
 
-static int sym_snooptest (struct sym_hcb *np)
+static int sym_snooptest(struct sym_hcb *np)
 {
-       u32     sym_rd, sym_wr, sym_bk, host_rd, host_wr, pc, dstat;
-       int     i, err=0;
-#ifndef CONFIG_SCSI_SYM53C8XX_IOMAPPED
-       err |= sym_regtest (np);
-       if (err) return (err);
-#endif
+       u32 sym_rd, sym_wr, sym_bk, host_rd, host_wr, pc, dstat;
+       int i, err;
+
+       err = sym_regtest(np);
+       if (err)
+               return err;
 restart_test:
        /*
         *  Enable Master Parity Checking as we intend 
@@ -1093,7 +1099,7 @@ restart_test:
                err |= 4;
        }
 
-       return (err);
+       return err;
 }
 
 /*
@@ -1430,29 +1436,18 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp
 
        switch (nego) {
        case NS_SYNC:
-               msgptr[msglen++] = M_EXTENDED;
-               msgptr[msglen++] = 3;
-               msgptr[msglen++] = M_X_SYNC_REQ;
-               msgptr[msglen++] = goal->period;
-               msgptr[msglen++] = goal->offset;
+               msglen += spi_populate_sync_msg(msgptr + msglen, goal->period,
+                               goal->offset);
                break;
        case NS_WIDE:
-               msgptr[msglen++] = M_EXTENDED;
-               msgptr[msglen++] = 2;
-               msgptr[msglen++] = M_X_WIDE_REQ;
-               msgptr[msglen++] = goal->width;
+               msglen += spi_populate_width_msg(msgptr + msglen, goal->width);
                break;
        case NS_PPR:
-               msgptr[msglen++] = M_EXTENDED;
-               msgptr[msglen++] = 6;
-               msgptr[msglen++] = M_X_PPR_REQ;
-               msgptr[msglen++] = goal->period;
-               msgptr[msglen++] = 0;
-               msgptr[msglen++] = goal->offset;
-               msgptr[msglen++] = goal->width;
-               msgptr[msglen++] = (goal->iu ? PPR_OPT_IU : 0) |
+               msglen += spi_populate_ppr_msg(msgptr + msglen, goal->period,
+                               goal->offset, goal->width,
+                               (goal->iu ? PPR_OPT_IU : 0) |
                                        (goal->dt ? PPR_OPT_DT : 0) |
-                                       (goal->qas ? PPR_OPT_QAS : 0);
+                                       (goal->qas ? PPR_OPT_QAS : 0));
                break;
        }
 
@@ -1474,7 +1469,7 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp
 /*
  *  Insert a job into the start queue.
  */
-static void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp)
+void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp)
 {
        u_short qidx;
 
@@ -3588,7 +3583,7 @@ static int sym_evaluate_dp(struct sym_hcb *np, struct sym_ccb *cp, u32 scr, int
 
        if (pm) {
                dp_scr  = scr_to_cpu(pm->ret);
-               dp_ofs -= scr_to_cpu(pm->sg.size);
+               dp_ofs -= scr_to_cpu(pm->sg.size) & 0x00ffffff;
        }
 
        /*
@@ -3948,11 +3943,7 @@ sym_sync_nego_check(struct sym_hcb *np, int req, struct sym_ccb *cp)
        /*
         *  It was a request. Prepare an answer message.
         */
-       np->msgout[0] = M_EXTENDED;
-       np->msgout[1] = 3;
-       np->msgout[2] = M_X_SYNC_REQ;
-       np->msgout[3] = per;
-       np->msgout[4] = ofs;
+       spi_populate_sync_msg(np->msgout, per, ofs);
 
        if (DEBUG_FLAGS & DEBUG_NEGO) {
                sym_print_nego_msg(np, target, "sync msgout", np->msgout);
@@ -4078,14 +4069,7 @@ sym_ppr_nego_check(struct sym_hcb *np, int req, int target)
        /*
         *  It was a request. Prepare an answer message.
         */
-       np->msgout[0] = M_EXTENDED;
-       np->msgout[1] = 6;
-       np->msgout[2] = M_X_PPR_REQ;
-       np->msgout[3] = per;
-       np->msgout[4] = 0;
-       np->msgout[5] = ofs;
-       np->msgout[6] = wide;
-       np->msgout[7] = opts;
+       spi_populate_ppr_msg(np->msgout, per, ofs, wide, opts);
 
        if (DEBUG_FLAGS & DEBUG_NEGO) {
                sym_print_nego_msg(np, target, "ppr msgout", np->msgout);
@@ -4197,10 +4181,7 @@ sym_wide_nego_check(struct sym_hcb *np, int req, struct sym_ccb *cp)
        /*
         *  It was a request. Prepare an answer message.
         */
-       np->msgout[0] = M_EXTENDED;
-       np->msgout[1] = 2;
-       np->msgout[2] = M_X_WIDE_REQ;
-       np->msgout[3] = wide;
+       spi_populate_width_msg(np->msgout, wide);
 
        np->msgin [0] = M_NOOP;
 
@@ -4245,11 +4226,8 @@ static void sym_wide_nego(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb
                 * a single SCSI command (Suggested by Justin Gibbs).
                 */
                if (tp->tgoal.offset) {
-                       np->msgout[0] = M_EXTENDED;
-                       np->msgout[1] = 3;
-                       np->msgout[2] = M_X_SYNC_REQ;
-                       np->msgout[3] = tp->tgoal.period;
-                       np->msgout[4] = tp->tgoal.offset;
+                       spi_populate_sync_msg(np->msgout, tp->tgoal.period,
+                                       tp->tgoal.offset);
 
                        if (DEBUG_FLAGS & DEBUG_NEGO) {
                                sym_print_nego_msg(np, cp->target,
@@ -4624,7 +4602,8 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t
                         *  Debugging purpose.
                         */
 #ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING
-                       assert(lp->busy_itl == 0);
+                       if (lp->busy_itl != 0)
+                               goto out_free;
 #endif
                        /*
                         *  Allocate resources for tags if not yet.
@@ -4669,7 +4648,8 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t
                         *  Debugging purpose.
                         */
 #ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING
-                       assert(lp->busy_itl == 0 && lp->busy_itlq == 0);
+                       if (lp->busy_itl != 0 || lp->busy_itlq != 0)
+                               goto out_free;
 #endif
                        /*
                         *  Count this nexus for this LUN.