Remove spl*() in dev/raid/{aac,amr,asr,ciss} and replace them
authorSascha Wildner <swildner@dragonflybsd.org>
Thu, 9 Jun 2005 20:55:05 +0000 (20:55 +0000)
committerSascha Wildner <swildner@dragonflybsd.org>
Thu, 9 Jun 2005 20:55:05 +0000 (20:55 +0000)
with critical sections.

sys/dev/raid/aac/aac.c
sys/dev/raid/aac/aacvar.h
sys/dev/raid/amr/amr.c
sys/dev/raid/amr/amr_cam.c
sys/dev/raid/amr/amr_pci.c
sys/dev/raid/amr/amrvar.h
sys/dev/raid/asr/asr.c
sys/dev/raid/ciss/ciss.c
sys/dev/raid/ciss/cissvar.h

index 91c33a7..b2b90f7 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/aac/aac.c,v 1.9.2.14 2003/04/08 13:22:08 scottl Exp $
- *     $DragonFly: src/sys/dev/raid/aac/aac.c,v 1.17 2005/02/04 02:55:44 dillon Exp $
+ *     $DragonFly: src/sys/dev/raid/aac/aac.c,v 1.18 2005/06/09 20:55:05 swildner Exp $
  */
 
 /*
@@ -531,13 +531,12 @@ aac_shutdown(device_t dev)
        struct aac_softc *sc;
        struct aac_fib *fib;
        struct aac_close_command *cc;
-       int s;
 
        debug_called(1);
 
        sc = device_get_softc(dev);
 
-       s = splbio();
+       crit_enter();
 
        sc->aac_state |= AAC_STATE_SUSPEND;
 
@@ -575,7 +574,7 @@ aac_shutdown(device_t dev)
 
        AAC_MASK_INTERRUPTS(sc);
 
-       splx(s);
+       crit_exit();
        return(0);
 }
 
@@ -586,18 +585,17 @@ int
 aac_suspend(device_t dev)
 {
        struct aac_softc *sc;
-       int s;
 
        debug_called(1);
 
        sc = device_get_softc(dev);
 
-       s = splbio();
+       crit_enter();
 
        sc->aac_state |= AAC_STATE_SUSPEND;
        
        AAC_MASK_INTERRUPTS(sc);
-       splx(s);
+       crit_exit();
        return(0);
 }
 
@@ -1118,7 +1116,7 @@ aac_dump_complete(struct aac_softc *sc)
 static int
 aac_wait_command(struct aac_command *cm, int timeout)
 {
-       int s, error = 0;
+       int error = 0;
 
        debug_called(2);
 
@@ -1126,11 +1124,11 @@ aac_wait_command(struct aac_command *cm, int timeout)
        cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE;
        aac_enqueue_ready(cm);
        aac_startio(cm->cm_sc);
-       s = splbio();
+       crit_enter();
        while (!(cm->cm_flags & AAC_CMD_COMPLETED) && (error != EWOULDBLOCK)) {
                error = tsleep(cm, 0, "aacwait", 0);
        }
-       splx(s);
+       crit_exit();
        return(error);
 }
 
@@ -1796,7 +1794,7 @@ static int
 aac_enqueue_fib(struct aac_softc *sc, int queue, struct aac_command *cm)
 {
        u_int32_t pi, ci;
-       int s, error;
+       int error;
        u_int32_t fib_size;
        u_int32_t fib_addr;
 
@@ -1805,7 +1803,7 @@ aac_enqueue_fib(struct aac_softc *sc, int queue, struct aac_command *cm)
        fib_size = cm->cm_fib->Header.Size; 
        fib_addr = cm->cm_fib->Header.ReceiverFibAddress;
 
-       s = splbio();
+       crit_enter();
 
        /* get the producer/consumer indices */
        pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX];
@@ -1841,7 +1839,7 @@ aac_enqueue_fib(struct aac_softc *sc, int queue, struct aac_command *cm)
        error = 0;
 
 out:
-       splx(s);
+       crit_exit();
        return(error);
 }
 
@@ -1854,12 +1852,12 @@ aac_dequeue_fib(struct aac_softc *sc, int queue, u_int32_t *fib_size,
                struct aac_fib **fib_addr)
 {
        u_int32_t pi, ci;
-       int s, error;
+       int error;
        int notify;
 
        debug_called(3);
 
-       s = splbio();
+       crit_enter();
 
        /* get the producer/consumer indices */
        pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX];
@@ -1902,7 +1900,7 @@ aac_dequeue_fib(struct aac_softc *sc, int queue, u_int32_t *fib_size,
        error = 0;
 
 out:
-       splx(s);
+       crit_exit();
        return(error);
 }
 
@@ -1913,7 +1911,7 @@ static int
 aac_enqueue_response(struct aac_softc *sc, int queue, struct aac_fib *fib)
 {
        u_int32_t pi, ci;
-       int s, error;
+       int error;
        u_int32_t fib_size;
        u_int32_t fib_addr;
 
@@ -1924,7 +1922,7 @@ aac_enqueue_response(struct aac_softc *sc, int queue, struct aac_fib *fib)
        fib_addr = fib->Header.SenderFibAddress;
        fib->Header.ReceiverFibAddress = fib_addr;
 
-       s = splbio();
+       crit_enter();
 
        /* get the producer/consumer indices */
        pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX];
@@ -1954,7 +1952,7 @@ aac_enqueue_response(struct aac_softc *sc, int queue, struct aac_fib *fib)
        error = 0;
 
 out:
-       splx(s);
+       crit_exit();
        return(error);
 }
 
@@ -1966,7 +1964,6 @@ static void
 aac_timeout(void *xsc)
 {
        struct aac_softc *sc = xsc;
-       int s;
        struct aac_command *cm;
        time_t deadline;
 
@@ -1978,9 +1975,9 @@ aac_timeout(void *xsc)
         * threads in the interrupt handler at the same time!  If calling
         * is deamed neccesary in the future, proper mutexes must be used.
         */
-       s = splbio();
+       crit_enter();
        aac_intr(sc);
-       splx(s);
+       crit_exit();
 
        /* kick the I/O queue to restart it in the case of deadlock */
        aac_startio(sc);
@@ -1991,7 +1988,7 @@ aac_timeout(void *xsc)
         * only.
         */
        deadline = time_second - AAC_CMD_TIMEOUT;
-       s = splbio();
+       crit_enter();
        TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) {
                if ((cm->cm_timestamp  < deadline)
                        /* && !(cm->cm_flags & AAC_CMD_TIMEDOUT) */) {
@@ -2002,7 +1999,7 @@ aac_timeout(void *xsc)
                        AAC_PRINT_FIB(sc, cm->cm_fib);
                }
        }
-       splx(s);
+       crit_exit();
 
        /* reset the timer for next time */
        callout_reset(&sc->aac_watchdog, AAC_PERIODIC_INTERVAL * hz,
@@ -2737,7 +2734,7 @@ static int
 aac_getnext_aif(struct aac_softc *sc, caddr_t arg)
 {
        struct get_adapter_fib_ioctl agf;
-       int error, s;
+       int error;
 
        debug_called(2);
 
@@ -2750,7 +2747,7 @@ aac_getnext_aif(struct aac_softc *sc, caddr_t arg)
                        error = EFAULT;
                } else {
        
-                       s = splbio();
+                       crit_enter();
                        error = aac_return_aif(sc, agf.AifFib);
        
                        if ((error == EAGAIN) && (agf.Wait)) {
@@ -2764,7 +2761,7 @@ aac_getnext_aif(struct aac_softc *sc, caddr_t arg)
                                }
                                sc->aac_state &= ~AAC_STATE_AIF_SLEEPER;
                        }
-               splx(s);
+                       crit_exit();
                }
        }
        return(error);
index 736406c..8139773 100644 (file)
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/aac/aacvar.h,v 1.4.2.7 2003/04/08 13:22:08 scottl Exp $
- *     $DragonFly: src/sys/dev/raid/aac/aacvar.h,v 1.8 2005/02/17 13:59:36 joerg Exp $
+ *     $DragonFly: src/sys/dev/raid/aac/aacvar.h,v 1.9 2005/06/09 20:55:05 swildner Exp $
  */
 
+#include <sys/thread2.h>
+
 /*
  * Driver Parameter Definitions
  */
@@ -477,9 +479,7 @@ aac_initq_ ## name (struct aac_softc *sc)                           \
 static __inline void                                                   \
 aac_enqueue_ ## name (struct aac_command *cm)                          \
 {                                                                      \
-       int s;                                                          \
-                                                                       \
-       s = splbio();                                                   \
+       crit_enter();                                                   \
        if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {                   \
                printf("command %p is on another queue, flags = %#x\n", \
                       cm, cm->cm_flags);                               \
@@ -488,14 +488,12 @@ aac_enqueue_ ## name (struct aac_command *cm)                             \
        TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link);       \
        cm->cm_flags |= AAC_ON_ ## index;                               \
        AACQ_ADD(cm->cm_sc, index);                                     \
-       splx(s);                                                        \
+       crit_exit();                                                    \
 }                                                                      \
 static __inline void                                                   \
 aac_requeue_ ## name (struct aac_command *cm)                          \
 {                                                                      \
-       int s;                                                          \
-                                                                       \
-       s = splbio();                                                   \
+       crit_enter();                                                   \
        if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {                   \
                printf("command %p is on another queue, flags = %#x\n", \
                       cm, cm->cm_flags);                               \
@@ -504,15 +502,14 @@ aac_requeue_ ## name (struct aac_command *cm)                             \
        TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link);       \
        cm->cm_flags |= AAC_ON_ ## index;                               \
        AACQ_ADD(cm->cm_sc, index);                                     \
-       splx(s);                                                        \
+       crit_exit();                                                    \
 }                                                                      \
 static __inline struct aac_command *                                   \
 aac_dequeue_ ## name (struct aac_softc *sc)                            \
 {                                                                      \
        struct aac_command *cm;                                         \
-       int s;                                                          \
                                                                        \
-       s = splbio();                                                   \
+       crit_enter();                                                   \
        if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) {            \
                if ((cm->cm_flags & AAC_ON_ ## index) == 0) {           \
                        printf("command %p not in queue, flags = %#x, " \
@@ -524,15 +521,13 @@ aac_dequeue_ ## name (struct aac_softc *sc)                               \
                cm->cm_flags &= ~AAC_ON_ ## index;                      \
                AACQ_REMOVE(sc, index);                                 \
        }                                                               \
-       splx(s);                                                        \
+       crit_exit();                                                    \
        return(cm);                                                     \
 }                                                                      \
 static __inline void                                                   \
 aac_remove_ ## name (struct aac_command *cm)                           \
 {                                                                      \
-       int s;                                                          \
-                                                                       \
-       s = splbio();                                                   \
+       crit_enter();                                                   \
        if ((cm->cm_flags & AAC_ON_ ## index) == 0) {                   \
                printf("command %p not in queue, flags = %#x, "         \
                       "bit = %#x\n", cm, cm->cm_flags,                 \
@@ -542,7 +537,7 @@ aac_remove_ ## name (struct aac_command *cm)                                \
        TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link);            \
        cm->cm_flags &= ~AAC_ON_ ## index;                              \
        AACQ_REMOVE(cm->cm_sc, index);                                  \
-       splx(s);                                                        \
+       crit_exit();                                                    \
 }                                                                      \
 struct hack
 
@@ -564,26 +559,23 @@ aac_initq_bio(struct aac_softc *sc)
 static __inline void
 aac_enqueue_bio(struct aac_softc *sc, struct bio *bp)
 {
-       int s;
-
-       s = splbio();
+       crit_enter();
        bioq_insert_tail(&sc->aac_bioq, bp);
        AACQ_ADD(sc, AACQ_BIO);
-       splx(s);
+       crit_exit();
 }
 
 static __inline struct bio *
 aac_dequeue_bio(struct aac_softc *sc)
 {
-       int s;
        struct bio *bp;
 
-       s = splbio();
+       crit_enter();
        if ((bp = bioq_first(&sc->aac_bioq)) != NULL) {
                bioq_remove(&sc->aac_bioq, bp);
                AACQ_REMOVE(sc, AACQ_BIO);
        }
-       splx(s);
+       crit_exit();
        return(bp);
 }
 
index c2d7e86..1f2bf17 100644 (file)
@@ -53,7 +53,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/amr/amr.c,v 1.7.2.13 2003/01/15 13:41:18 emoore Exp $
- *     $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.14 2005/02/04 02:55:46 dillon Exp $
+ *     $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.15 2005/06/09 20:55:05 swildner Exp $
  */
 
 /*
@@ -986,7 +986,6 @@ static int
 amr_quartz_poll_command(struct amr_command *ac)
 {
     struct amr_softc   *sc = ac->ac_sc;
-    int                        s;
     int                        error,count;
 
     debug_called(2);
@@ -994,7 +993,7 @@ amr_quartz_poll_command(struct amr_command *ac)
     /* now we have a slot, we can map the command (unmapped in amr_complete) */
     amr_mapcmd(ac);
 
-    s = splbio();
+    crit_enter();
 
     if (sc->amr_state & AMR_STATE_INTEN) {
            count=0;
@@ -1007,7 +1006,7 @@ amr_quartz_poll_command(struct amr_command *ac)
            
            if(sc->amr_busyslots) {
                    device_printf(sc->amr_dev, "adapter is busy\n");
-                   splx(s);
+                   crit_exit();
                    amr_unmapcmd(ac);
                    ac->ac_status=0;
                    return(1);
@@ -1038,7 +1037,7 @@ amr_quartz_poll_command(struct amr_command *ac)
     AMR_QPUT_IDB(sc, sc->amr_mailboxphys | AMR_QIDB_ACK);
     while(AMR_QGET_IDB(sc) & AMR_QIDB_ACK);
 
-    splx(s);
+    crit_exit();
 
     /* unmap the command's data buffer */
     amr_unmapcmd(ac);
@@ -1055,7 +1054,7 @@ static int
 amr_getslot(struct amr_command *ac)
 {
     struct amr_softc   *sc = ac->ac_sc;
-    int                        s, slot, limit, error;
+    int                        slot, limit, error;
 
     debug_called(3);
 
@@ -1072,7 +1071,7 @@ amr_getslot(struct amr_command *ac)
      * Allocate a slot.  XXX linear scan is slow
      */
     error = EBUSY;
-    s = splbio();
+    crit_enter();
     for (slot = 0; slot < sc->amr_maxio; slot++) {
        if (sc->amr_busycmd[slot] == NULL) {
            sc->amr_busycmd[slot] = ac;
@@ -1082,7 +1081,7 @@ amr_getslot(struct amr_command *ac)
            break;
        }
     }
-    splx(s);
+    crit_exit();
 
     return(error);
 }
@@ -1252,7 +1251,7 @@ static int
 amr_start(struct amr_command *ac)
 {
     struct amr_softc   *sc = ac->ac_sc;
-    int                        done, s, i;
+    int                        done, i;
 
     debug_called(3);
 
@@ -1288,7 +1287,7 @@ amr_start(struct amr_command *ac)
      */
     debug(4, "wait for mailbox");
     for (i = 10000, done = 0; (i > 0) && !done; i--) {
-       s = splbio();
+       crit_enter();
        
        /* is the mailbox free? */
        if (sc->amr_mailbox->mb_busy == 0) {
@@ -1303,7 +1302,7 @@ amr_start(struct amr_command *ac)
            /* this is somewhat ugly */
            DELAY(100);
        }
-       splx(s);        /* drop spl to allow completion interrupts */
+       crit_exit();
     }
 
     /*
@@ -1491,12 +1490,12 @@ amr_alloccmd_cluster(struct amr_softc *sc)
 {
     struct amr_command_cluster *acc;
     struct amr_command         *ac;
-    int                                s, i;
+    int                                i;
 
     acc = malloc(AMR_CMD_CLUSTERSIZE, M_DEVBUF, M_INTWAIT);
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_TAIL(&sc->amr_cmd_clusters, acc, acc_link);
-    splx(s);
+    crit_exit();
     for (i = 0; i < AMR_CMD_CLUSTERCOUNT; i++) {
        ac = &acc->acc_command[i];
        bzero(ac, sizeof(*ac));
@@ -1559,13 +1558,13 @@ amr_std_submit_command(struct amr_softc *sc)
 static int
 amr_quartz_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave)
 {
-    int                s, worked;
+    int                worked;
     u_int32_t  outd;
 
     debug_called(3);
 
     worked = 0;
-    s = splbio();
+    crit_enter();
 
     /* work waiting for us? */
     if ((outd = AMR_QGET_ODB(sc)) == AMR_QODB_READY) {
@@ -1596,20 +1595,20 @@ amr_quartz_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave)
        worked = 1;                     /* got some work */
     }
 
-    splx(s);
+    crit_exit();
     return(worked);
 }
 
 static int
 amr_std_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave)
 {
-    int                s, worked;
+    int                worked;
     u_int8_t   istat;
 
     debug_called(3);
 
     worked = 0;
-    s = splbio();
+    crit_enter();
 
     /* check for valid interrupt status */
     istat = AMR_SGET_ISTAT(sc);
@@ -1623,7 +1622,7 @@ amr_std_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave)
        worked = 1;
     }
 
-    splx(s);
+    crit_exit();
     return(worked);
 }
 
index 7a34fb9..137fe12 100644 (file)
@@ -53,7 +53,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/amr/amr_cam.c,v 1.1.2.3 2002/11/11 13:19:10 emoore Exp $
- *     $DragonFly: src/sys/dev/raid/amr/amr_cam.c,v 1.5 2004/06/21 15:39:30 dillon Exp $
+ *     $DragonFly: src/sys/dev/raid/amr/amr_cam.c,v 1.6 2005/06/09 20:55:05 swildner Exp $
  */
 
 #include <sys/param.h>
@@ -95,33 +95,28 @@ static void         amr_cam_complete_extcdb(struct amr_command *ac);
 static __inline void
 amr_enqueue_ccb(struct amr_softc *sc, union ccb *ccb)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_TAIL(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
-    splx(s);
+    crit_exit();
 }
 
 static __inline void
 amr_requeue_ccb(struct amr_softc *sc, union ccb *ccb)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_HEAD(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
-    splx(s);
+    crit_exit();
 }
 
 static __inline union ccb *
 amr_dequeue_ccb(struct amr_softc *sc)
 {
     union ccb  *ccb;
-    int                s;
 
-    s = splbio();
+    crit_enter();
     if ((ccb = (union ccb *)TAILQ_FIRST(&sc->amr_cam_ccbq)) != NULL)
        TAILQ_REMOVE(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
-    splx(s);
+    crit_exit();
     return(ccb);
 }
 
index 94fcc7d..c0ce240 100644 (file)
@@ -53,7 +53,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/amr/amr_pci.c,v 1.1.2.9 2002/12/20 15:12:04 emoore Exp $
- *     $DragonFly: src/sys/dev/raid/amr/amr_pci.c,v 1.4 2005/05/24 20:59:03 dillon Exp $
+ *     $DragonFly: src/sys/dev/raid/amr/amr_pci.c,v 1.5 2005/06/09 20:55:05 swildner Exp $
  */
 
 #include <sys/param.h>
@@ -340,7 +340,7 @@ static int
 amr_pci_shutdown(device_t dev)
 {
     struct amr_softc   *sc = device_get_softc(dev);
-    int                        i,error,s;
+    int                        i,error;
 
     debug_called(1);
 
@@ -352,7 +352,7 @@ amr_pci_shutdown(device_t dev)
     device_printf(sc->amr_dev, "flushing cache...");
     printf("%s\n", amr_flush(sc) ? "failed" : "done");
 
-    s = splbio();
+    crit_enter();
     error = 0;
 
     /* delete all our child devices */
@@ -367,7 +367,7 @@ amr_pci_shutdown(device_t dev)
     /* XXX disable interrupts? */
 
 shutdown_out:
-    splx(s);
+    crit_exit();
     return(error);
 }
 
index 75e9bee..c49e116 100644 (file)
  * SUCH DAMAGE.
  *
  *      $FreeBSD: src/sys/dev/amr/amrvar.h,v 1.2.2.5 2002/12/20 15:12:04 emoore Exp $
- *      $DragonFly: src/sys/dev/raid/amr/amrvar.h,v 1.5 2004/09/15 16:11:52 joerg Exp $
+ *      $DragonFly: src/sys/dev/raid/amr/amrvar.h,v 1.6 2005/06/09 20:55:05 swildner Exp $
  */
 
+#include <sys/thread2.h>
+
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
 # include <sys/taskqueue.h>
 #endif
@@ -273,101 +275,87 @@ extern int       amr_dump_blocks(struct amr_softc *sc, int unit, u_int32_t lba, void *
 static __inline void
 amr_enqueue_bio(struct amr_softc *sc, struct bio *bio)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     bioq_insert_tail(&sc->amr_bioq, bio);
-    splx(s);
+    crit_exit();
 }
 
 static __inline struct bio *
 amr_dequeue_bio(struct amr_softc *sc)
 {
     struct bio *bio;
-    int                s;
 
-    s = splbio();
+    crit_enter();
     if ((bio = bioq_first(&sc->amr_bioq)) != NULL)
        bioq_remove(&sc->amr_bioq, bio);
-    splx(s);
+    crit_exit();
     return(bio);
 }
 
 static __inline void
 amr_enqueue_ready(struct amr_command *ac)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link);
-    splx(s);
+    crit_exit();
 }
 
 static __inline void
 amr_requeue_ready(struct amr_command *ac)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link);
-    splx(s);
+    crit_exit();
 }
 
 static __inline struct amr_command *
 amr_dequeue_ready(struct amr_softc *sc)
 {
     struct amr_command *ac;
-    int                        s;
 
-    s = splbio();
+    crit_enter();
     if ((ac = TAILQ_FIRST(&sc->amr_ready)) != NULL)
        TAILQ_REMOVE(&sc->amr_ready, ac, ac_link);
-    splx(s);
+    crit_exit();
     return(ac);
 }
 
 static __inline void
 amr_enqueue_completed(struct amr_command *ac)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_TAIL(&ac->ac_sc->amr_completed, ac, ac_link);
-    splx(s);
+    crit_exit();
 }
 
 static __inline struct amr_command *
 amr_dequeue_completed(struct amr_softc *sc)
 {
     struct amr_command *ac;
-    int                        s;
 
-    s = splbio();
+    crit_enter();
     if ((ac = TAILQ_FIRST(&sc->amr_completed)) != NULL)
        TAILQ_REMOVE(&sc->amr_completed, ac, ac_link);
-    splx(s);
+    crit_exit();
     return(ac);
 }
 
 static __inline void
 amr_enqueue_free(struct amr_command *ac)
 {
-    int                s;
-
-    s = splbio();
+    crit_enter();
     TAILQ_INSERT_TAIL(&ac->ac_sc->amr_freecmds, ac, ac_link);
-    splx(s);
+    crit_exit();
 }
 
 static __inline struct amr_command *
 amr_dequeue_free(struct amr_softc *sc)
 {
     struct amr_command *ac;
-    int                        s;
 
-    s = splbio();
+    crit_enter();
     if ((ac = TAILQ_FIRST(&sc->amr_freecmds)) != NULL)
        TAILQ_REMOVE(&sc->amr_freecmds, ac, ac_link);
-    splx(s);
+    crit_exit();
     return(ac);
 }
index daa6768..188adb5 100644 (file)
@@ -1,5 +1,5 @@
 /* $FreeBSD: src/sys/dev/asr/asr.c,v 1.3.2.2 2001/08/23 05:21:29 scottl Exp $ */
-/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.19 2005/05/24 20:59:03 dillon Exp $ */
+/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.20 2005/06/09 20:55:05 swildner Exp $ */
 /*
  * Copyright (c) 1996-2000 Distributed Processing Technology Corporation
  * Copyright (c) 2000-2001 Adaptec Corporation
@@ -224,6 +224,7 @@ static dpt_sig_S ASR_sig = {
 #include <sys/rman.h>
 #include <sys/stat.h>
 #include <sys/device.h>
+#include <sys/thread2.h>
 
 #include <bus/cam/cam.h>
 #include <bus/cam/cam_ccb.h>
@@ -866,7 +867,6 @@ ASR_queue_s (
         INOUT union asr_ccb * ccb,
         IN PI2O_MESSAGE_FRAME Message)
 {
-        int                   s;
         U32                   Mask;
         Asr_softc_t         * sc = (Asr_softc_t *)(ccb->ccb_h.spriv_ptr0);
 
@@ -877,7 +877,7 @@ ASR_queue_s (
         I2O_MESSAGE_FRAME_setInitiatorContext64(Message, (long)ccb);
 
         /* Prevent interrupt service */
-        s = splcam ();
+       crit_enter();
         sc->ha_Virt->Mask = (Mask = sc->ha_Virt->Mask)
           | Mask_InterruptsDisabled;
 
@@ -895,7 +895,7 @@ ASR_queue_s (
 
         /* Re-enable Interrupts */
         sc->ha_Virt->Mask = Mask;
-        splx(s);
+       crit_exit();
 
         return (ccb->ccb_h.status);
 } /* ASR_queue_s */
@@ -930,9 +930,7 @@ ASR_ccbAdd (
         IN Asr_softc_t      * sc,
         INOUT union asr_ccb * ccb)
 {
-        int s;
-
-        s = splcam();
+       crit_enter();
         LIST_INSERT_HEAD(&(sc->ha_ccb), &(ccb->ccb_h), sim_links.le);
         if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
                 if (ccb->ccb_h.timeout == CAM_TIME_DEFAULT) {
@@ -946,7 +944,7 @@ ASR_ccbAdd (
                 callout_reset(&ccb->ccb_h.timeout_ch,
                    (ccb->ccb_h.timeout * hz) / 1000, asr_timeout, ccb);
         }
-        splx(s);
+       crit_exit();
 } /* ASR_ccbAdd */
 
 /*
@@ -957,12 +955,10 @@ ASR_ccbRemove (
         IN Asr_softc_t      * sc,
         INOUT union asr_ccb * ccb)
 {
-        int s;
-
-        s = splcam();
+       crit_enter();
         callout_stop(&ccb->ccb_h.timeout_ch);
         LIST_REMOVE(&(ccb->ccb_h), sim_links.le);
-        splx(s);
+       crit_exit();
 } /* ASR_ccbRemove */
 
 /*
@@ -974,7 +970,6 @@ ASR_failActiveCommands (
         IN Asr_softc_t                         * sc)
 {
         struct ccb_hdr                         * ccb;
-        int                                      s;
 
 #if 0 /* Currently handled by callers, unnecessary paranoia currently */
       /* Left in for historical perspective. */
@@ -991,7 +986,7 @@ ASR_failActiveCommands (
         (void)ASR_queue_c(sc, (PI2O_MESSAGE_FRAME)Message_Ptr);
 #endif
 
-        s = splcam();
+       crit_enter();
         /*
          *      We do not need to inform the CAM layer that we had a bus
          * reset since we manage it on our own, this also prevents the
@@ -1017,7 +1012,7 @@ ASR_failActiveCommands (
                         wakeup ((caddr_t)ccb);
                 }
         }
-        splx(s);
+       crit_exit();
 } /* ASR_failActiveCommands */
 
 /*
@@ -1234,19 +1229,18 @@ ASR_getTid (
         IN int           lun)
 {
         tid_t          * tid_ptr;
-        int              s;
         OUT tid_t        retval;
 
-        s = splcam();
+       crit_enter();
         if (((tid_ptr = ASR_getTidAddress (sc, bus, target, lun, FALSE))
           == (tid_t *)NULL)
         /* (tid_t)0 or (tid_t)-1 indicate no TID */
          || (*tid_ptr == (tid_t)0)) {
-                splx(s);
+               crit_exit();
                 return ((tid_t)-1);
         }
         retval = *tid_ptr;
-        splx(s);
+       crit_exit();
         return (retval);
 } /* ASR_getTid */
 
@@ -1266,20 +1260,19 @@ ASR_setTid (
         INOUT tid_t         TID)
 {
         tid_t             * tid_ptr;
-        int                 s;
 
         if (TID != (tid_t)-1) {
                 if (TID == 0) {
                         return ((tid_t)-1);
                 }
-                s = splcam();
+               crit_enter();
                 if ((tid_ptr = ASR_getTidAddress (sc, bus, target, lun, TRUE))
                  == (tid_t *)NULL) {
-                        splx(s);
+                       crit_exit();
                         return ((tid_t)-1);
                 }
                 *tid_ptr = TID;
-                splx(s);
+               crit_exit();
         }
         return (TID);
 } /* ASR_setTid */
@@ -1441,12 +1434,12 @@ STATIC INLINE int
 ASR_reset(
         IN Asr_softc_t * sc)
 {
-        int              s, retVal;
+        int              retVal;
 
-        s = splcam();
+       crit_enter();
         if ((sc->ha_in_reset == HA_IN_RESET)
          || (sc->ha_in_reset == HA_OFF_LINE_RECOVERY)) {
-                splx (s);
+               crit_exit();
                 return (EBUSY);
         }
         /*
@@ -1474,7 +1467,7 @@ ASR_reset(
                             ? cam_sim_unit(xpt_path_sim(sc->ha_path[0]))
                             : 0);
                         sc->ha_in_reset = HA_OFF_LINE;
-                        splx (s);
+                       crit_exit();
                         return (ENXIO);
 #               else
                         /* Wait Forever */
@@ -1482,7 +1475,7 @@ ASR_reset(
 #               endif
         }
         retVal = ASR_init (sc);
-        splx (s);
+       crit_exit();
         if (retVal != 0) {
                 debug_asr_printf ("ASR_init failed\n");
                 sc->ha_in_reset = HA_OFF_LINE;
@@ -1535,7 +1528,7 @@ asr_timeout(
          * the SCSI command is also *very* dangerous. A SCSI BUS reset is
          * our best bet, followed by a complete adapter reset if that fails.
          */
-        s = splcam();
+       crit_enter();
         /* Check if we already timed out once to raise the issue */
         if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_CMD_TIMEOUT) {
                 debug_asr_printf (" AGAIN\nreinitializing adapter\n");
@@ -1543,7 +1536,7 @@ asr_timeout(
                         callout_reset(&ccb->ccb_h.timeout_ch,
                             (ccb->ccb_h.timeout * hz) / 1000, asr_timeout, ccb);
                 }
-                splx(s);
+               crit_exit();
                 return;
         }
         debug_asr_printf ("\nresetting bus\n");
@@ -1554,7 +1547,7 @@ asr_timeout(
                      asr_timeout, ccb);
         ASR_resetBus (sc, cam_sim_bus(xpt_path_sim(ccb->ccb_h.path)));
         xpt_async (AC_BUS_RESET, ccb->ccb_h.path, NULL);
-        splx(s);
+       crit_exit();
 } /* asr_timeout */
 
 /*
@@ -3318,7 +3311,6 @@ asr_open(
         int32_t          ifmt,
         IN d_thread_t *td)
 {
-        int              s;
         OUT int          error;
         UNREFERENCED_PARAMETER(flags);
         UNREFERENCED_PARAMETER(ifmt);
@@ -3327,13 +3319,13 @@ asr_open(
                 return (ENODEV);
         }
        KKASSERT(td->td_proc);
-        s = splcam ();
+       crit_enter();
         if (ASR_ctlr_held) {
                 error = EBUSY;
         } else if ((error = suser_cred(td->td_proc->p_ucred, 0)) == 0) {
                 ++ASR_ctlr_held;
         }
-        splx(s);
+       crit_exit();
         return (error);
 } /* asr_open */
 
@@ -3739,7 +3731,7 @@ ASR_queue_i(
         /*
          * Wait for the board to report a finished instruction.
          */
-        s = splcam();
+       crit_enter();
         while ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG) {
                 if (ASR_getBlinkLedCode(sc)) {
                         /* Reset Adapter */
@@ -3750,7 +3742,7 @@ ASR_queue_i(
                                 /* Command Cleanup */
                                 ASR_ccbRemove(sc, ccb);
                         }
-                        splx(s);
+                       crit_exit();
                         /* Free up in-kernel buffers */
                         while ((elm = SLIST_FIRST(&sgList))
                           != (struct ioctlSgList_S *)NULL) {
@@ -3764,7 +3756,7 @@ ASR_queue_i(
                 /* Check every second for BlinkLed */
                 tsleep((caddr_t)ccb, 0, "asr", hz);
         }
-        splx(s);
+       crit_exit();
 
         debug_usr_cmd_printf ("Outbound: ");
         debug_usr_cmd_dump_message(Reply_Ptr);
index 840a373..73cae41 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/ciss/ciss.c,v 1.2.2.6 2003/02/18 22:27:41 ps Exp $
- *     $DragonFly: src/sys/dev/raid/ciss/ciss.c,v 1.14 2005/05/24 20:59:03 dillon Exp $
+ *     $DragonFly: src/sys/dev/raid/ciss/ciss.c,v 1.15 2005/06/09 20:55:05 swildner Exp $
  */
 
 /*
@@ -1685,7 +1685,7 @@ ciss_poll_request(struct ciss_request *cr, int timeout)
 static int
 ciss_wait_request(struct ciss_request *cr, int timeout)
 {
-    int                s, error;
+    int                error;
 
     debug_called(2);
 
@@ -1693,7 +1693,7 @@ ciss_wait_request(struct ciss_request *cr, int timeout)
     if ((error = ciss_start(cr)) != 0)
        return(error);
 
-    s = splcam();
+    crit_enter();
     while (cr->cr_flags & CISS_REQ_SLEEP) {
        error = tsleep(cr, PCATCH, "cissREQ", (timeout * hz) / 1000);
        /* 
@@ -1709,7 +1709,7 @@ ciss_wait_request(struct ciss_request *cr, int timeout)
         */
        break;
     }
-    splx(s);
+    crit_exit();
     return(error);
 }
 
@@ -2818,7 +2818,7 @@ ciss_notify_abort(struct ciss_softc *sc)
     struct ciss_request                *cr;
     struct ciss_command                *cc;
     struct ciss_notify_cdb     *cnc;
-    int                                error, s, command_status, scsi_status;
+    int                                error, command_status, scsi_status;
 
     debug_called(1);
 
@@ -2908,7 +2908,7 @@ ciss_notify_abort(struct ciss_softc *sc)
      * requires the Notify Event command to be cancelled in order to
      * maintain internal bookkeeping.
      */
-    s = splcam();
+    crit_enter();
     while (sc->ciss_periodic_notify != NULL) {
        error = tsleep(&sc->ciss_periodic_notify, 0, "cissNEA", hz * 5);
        if (error == EWOULDBLOCK) {
@@ -2916,7 +2916,7 @@ ciss_notify_abort(struct ciss_softc *sc)
            break;
        }
     }
-    splx(s);
+    crit_exit();
 
  out:
     /* release the cancel request */
index 9b04f10..9a83a86 100644 (file)
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/ciss/cissvar.h,v 1.3.2.2 2003/02/06 21:42:59 ps Exp $
- *     $DragonFly: src/sys/dev/raid/ciss/cissvar.h,v 1.4 2004/09/15 16:02:41 joerg Exp $
+ *     $DragonFly: src/sys/dev/raid/ciss/cissvar.h,v 1.5 2005/06/09 20:55:05 swildner Exp $
  */
 
+#include <sys/thread2.h>
+
 /*
  * CISS adapter driver datastructures
  */
@@ -311,46 +313,41 @@ ciss_initq_ ## name (struct ciss_softc *sc)                               \
 static __inline void                                                   \
 ciss_enqueue_ ## name (struct ciss_request *cr)                                \
 {                                                                      \
-    int                s;                                                      \
-                                                                       \
-    s = splcam();                                                      \
+    crit_enter();                                                      \
     TAILQ_INSERT_TAIL(&cr->cr_sc->ciss_ ## name, cr, cr_link);         \
     CISSQ_ADD(cr->cr_sc, index);                                       \
     cr->cr_onq = index;                                                        \
-    splx(s);                                                           \
+    crit_exit();                                                       \
 }                                                                      \
 static __inline void                                                   \
 ciss_requeue_ ## name (struct ciss_request *cr)                                \
 {                                                                      \
-    int                s;                                                      \
-                                                                       \
-    s = splcam();                                                      \
+    crit_enter();                                                      \
     TAILQ_INSERT_HEAD(&cr->cr_sc->ciss_ ## name, cr, cr_link);         \
     CISSQ_ADD(cr->cr_sc, index);                                       \
     cr->cr_onq = index;                                                        \
-    splx(s);                                                           \
+    crit_exit();                                                       \
 }                                                                      \
 static __inline struct ciss_request *                                  \
 ciss_dequeue_ ## name (struct ciss_softc *sc)                          \
 {                                                                      \
     struct ciss_request        *cr;                                            \
-    int                        s;                                              \
                                                                        \
-    s = splcam();                                                      \
+    crit_enter();                                                      \
     if ((cr = TAILQ_FIRST(&sc->ciss_ ## name)) != NULL) {              \
        TAILQ_REMOVE(&sc->ciss_ ## name, cr, cr_link);                  \
        CISSQ_REMOVE(sc, index);                                        \
        cr->cr_onq = -1;                                                \
     }                                                                  \
-    splx(s);                                                           \
+    crit_exit();                                                       \
     return(cr);                                                                \
 }                                                                      \
 static __inline int                                                    \
 ciss_remove_ ## name (struct ciss_request *cr)                         \
 {                                                                      \
-    int                        s, error;                                       \
+    int                        error;                                          \
                                                                        \
-    s = splcam();                                                      \
+    crit_enter();                                                      \
     if (cr->cr_onq != index) {                                         \
        printf("request on queue %d (expected %d)\n", cr->cr_onq, index);\
        error = 1;                                                      \
@@ -360,7 +357,7 @@ ciss_remove_ ## name (struct ciss_request *cr)                              \
        cr->cr_onq = -1;                                                \
        error = 0;                                                      \
     }                                                                  \
-    splx(s);                                                           \
+    crit_exit();                                                       \
     return(error);                                                     \
 }                                                                      \
 struct hack