Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Change the way ADW_CARRIER is allocated and handled.



details:   https://anonhg.NetBSD.org/src/rev/b6cb19ef88f6
branches:  trunk
changeset: 485897:b6cb19ef88f6
user:      dante <dante%NetBSD.org@localhost>
date:      Mon May 08 17:21:33 2000 +0000

description:
Change the way ADW_CARRIER is allocated and handled.
Increased ADW_MAX_CCB to 63 and ADW_MAX_CARRIER to 253
Print WDTR/SDTR negotiation result per target
Protect AdvISR() inside splbio()/splx() pair
Add a pending queue to keep track of all the CCBs that are being executed by the host adapter.
Rewrote timeout handler in a more efficient way:
    After 3 timeout now the SCSI is resetted and all pending queues not completed are now reenqueued in the waiting queue so to get executed just after the BUS Reset (hoping that resetting the SCSI 
BUS and reinitializing the adapter could solve the problem).

diffstat:

 sys/dev/ic/adw.c    |  319 ++++++++++++++++++++++++++++++++++-----------------
 sys/dev/ic/adw.h    |   34 ++--
 sys/dev/ic/adwlib.c |   51 +++-----
 sys/dev/ic/adwlib.h |   17 +-
 4 files changed, 255 insertions(+), 166 deletions(-)

diffs (truncated from 834 to 300 lines):

diff -r 64870387bf64 -r b6cb19ef88f6 sys/dev/ic/adw.c
--- a/sys/dev/ic/adw.c  Mon May 08 17:11:54 2000 +0000
+++ b/sys/dev/ic/adw.c  Mon May 08 17:21:33 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adw.c,v 1.18 2000/05/03 19:15:27 thorpej Exp $      */
+/* $NetBSD: adw.c,v 1.19 2000/05/08 17:21:33 dante Exp $        */
 
 /*
  * Generic driver for the Advanced Systems Inc. SCSI controllers
@@ -74,7 +74,6 @@
 static int adw_alloc_controls __P((ADW_SOFTC *));
 static int adw_alloc_carriers __P((ADW_SOFTC *));
 static int adw_create_carriers __P((ADW_SOFTC *));
-static int adw_init_carrier __P((ADW_SOFTC *, ADW_CARRIER *));
 static int adw_create_ccbs __P((ADW_SOFTC *, ADW_CCB *, int));
 static void adw_free_ccb __P((ADW_SOFTC *, ADW_CCB *));
 static void adw_reset_ccb __P((ADW_CCB *));
@@ -89,6 +88,8 @@
 static void adw_isr_callback __P((ADW_SOFTC *, ADW_SCSI_REQ_Q *));
 static void adw_async_callback __P((ADW_SOFTC *, u_int8_t));
 
+static void adw_print_info __P((ADW_SOFTC *, int));
+
 static int adw_poll __P((ADW_SOFTC *, struct scsipi_xfer *, int));
 static void adw_timeout __P((void *));
 
@@ -96,7 +97,7 @@
 /******************************************************************************/
 
 
-/* the below structure is so we have a default dev struct for out link struct */
+/* the below structure is so we have a default dev struct for our link struct */
 struct scsipi_device adw_dev =
 {
        NULL,                   /* Use default error handler */
@@ -106,12 +107,8 @@
 };
 
 
-#define ADW_ABORT_TIMEOUT       10000  /* time to wait for abort (mSec) */
-#define ADW_WATCH_TIMEOUT       10000  /* time to wait for watchdog (mSec) */
-
-
 /******************************************************************************/
-/*                                Control Blocks routines                     */
+/*                           Control Blocks routines                          */
 /******************************************************************************/
 
 
@@ -171,7 +168,7 @@
        /*
          * Allocate the control structure.
          */
-       sc->sc_control->carriers = malloc(ADW_CARRIER_SIZE * ADW_MAX_CARRIER,
+       sc->sc_control->carriers = malloc(sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
                        M_DEVBUF, M_WAITOK);
        if(!sc->sc_control->carriers) {
                printf("%s: malloc() failed in allocating carrier structures\n",
@@ -180,14 +177,14 @@
        }
 
        if ((error = bus_dmamem_alloc(sc->sc_dmat,
-                       ADW_CARRIER_SIZE * ADW_MAX_CARRIER,
-                       NBPG, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
+                       sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
+                       0x10, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
                printf("%s: unable to allocate carrier structures,"
                       " error = %d\n", sc->sc_dev.dv_xname, error);
                return (error);
        }
        if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
-                       ADW_CARRIER_SIZE * ADW_MAX_CARRIER,
+                       sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
                        (caddr_t *) &sc->sc_control->carriers,
                        BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
                printf("%s: unable to map carrier structures,"
@@ -199,8 +196,8 @@
          * Create and load the DMA map used for the control blocks.
          */
        if ((error = bus_dmamap_create(sc->sc_dmat,
-                       ADW_CARRIER_SIZE * ADW_MAX_CARRIER, 1,
-                       ADW_CARRIER_SIZE * ADW_MAX_CARRIER, 0, BUS_DMA_NOWAIT,
+                       sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, 1,
+                       sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, 0,BUS_DMA_NOWAIT,
                        &sc->sc_dmamap_carrier)) != 0) {
                printf("%s: unable to create carriers DMA map,"
                        " error = %d\n", sc->sc_dev.dv_xname, error);
@@ -208,23 +205,13 @@
        }
        if ((error = bus_dmamap_load(sc->sc_dmat,
                        sc->sc_dmamap_carrier, sc->sc_control->carriers,
-                       ADW_CARRIER_SIZE * ADW_MAX_CARRIER, NULL,
+                       sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, NULL,
                        BUS_DMA_NOWAIT)) != 0) {
                printf("%s: unable to load carriers DMA map,"
                        " error = %d\n", sc->sc_dev.dv_xname, error);
                return (error);
        }
 
-       error = bus_dmamap_create(sc->sc_dmat, ADW_CARRIER_SIZE* ADW_MAX_CARRIER,
-                       1, ADW_CARRIER_SIZE * ADW_MAX_CARRIER,
-                       0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
-                       &sc->sc_control->dmamap_xfer);
-       if (error) {
-               printf("%s: unable to create Carrier DMA map, error = %d\n",
-                      sc->sc_dev.dv_xname, error);
-               return (error);
-       }
-
        return (0);
 }
 
@@ -239,77 +226,30 @@
 {
        ADW_CARRIER     *carr;
        u_int32_t       carr_next = NULL;
-       int             i, error;
+       int             i;
 
        for(i=0; i < ADW_MAX_CARRIER; i++) {
                carr = (ADW_CARRIER *)(((u_int8_t *)sc->sc_control->carriers) +
-                               (ADW_CARRIER_SIZE * i));
-               if ((error = adw_init_carrier(sc, carr)) != 0) {
-                       printf("%s: unable to initialize carrier, error = %d\n",
-                              sc->sc_dev.dv_xname, error);
-                       return (i);
-               }
+                               (sizeof(ADW_CARRIER) * i));
+               carr->carr_pa = ADW_CARRIER_BADDR(sc, carr);
+               carr->carr_id = i;
                carr->next_vpa = carr_next;
                carr_next = carr->carr_pa;
-carr->id = i;
        }
        sc->carr_freelist = carr;
        return (i);
 }
 
 
-static int
-adw_init_carrier(sc, carr)
-       ADW_SOFTC       *sc;
-       ADW_CARRIER     *carr;
-{
-       u_int32_t       carr_pa;
-       int             /*error, */hashnum;
-
-       /*
-         * Create the DMA map for all of the Carriers.
-         */
-/*     error = bus_dmamap_create(sc->sc_dmat, ADW_CARRIER_SIZE,
-                       1, ADW_CARRIER_SIZE,
-                       0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
-                       &carr->dmamap_xfer);
-       if (error) {
-               printf("%s: unable to create Carrier DMA map, error = %d\n",
-                      sc->sc_dev.dv_xname, error);
-               return (error);
-       }
-*/
-       /*
-        * put in the phystokv hash table
-        * Never gets taken out.
-        */
-       carr_pa = ADW_CARRIER_ADDR(sc, carr);
-       carr->carr_pa = carr_pa;
-       hashnum = CARRIER_HASH(carr_pa);
-       carr->nexthash = sc->sc_carrhash[hashnum];
-       sc->sc_carrhash[hashnum] = carr;
-
-       return(0);
-}
-
-
 /*
  * Given a physical address, find the Carrier that it corresponds to.
  */
-ADW_CARRIER *
+inline ADW_CARRIER *
 adw_carrier_phys_kv(sc, carr_phys)
        ADW_SOFTC       *sc;
        u_int32_t       carr_phys;
 {
-       int hashnum = CARRIER_HASH(carr_phys);
-       ADW_CARRIER *carr = sc->sc_carrhash[hashnum];
-
-       while (carr) {
-               if (carr->carr_pa == carr_phys)
-                       break;
-               carr = carr->nexthash;
-       }
-       return (carr);
+       return (ADW_CARRIER_VADDR(sc, carr_phys));
 }
 
 
@@ -477,12 +417,11 @@
        ADW_CCB        *ccb;
        int             retry;
 {
-       int             errcode;
+       int             errcode = ADW_SUCCESS;
 
-       if(!retry)
+       if(!retry) {
                TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
-
-       errcode = ADW_SUCCESS;
+       }
 
        while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) {
 
@@ -502,6 +441,7 @@
                }
 
                TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
+               TAILQ_INSERT_TAIL(&sc->sc_pending_ccb, ccb, chain);
 
                if ((ccb->xs->xs_control & XS_CTL_POLL) == 0)
                        callout_reset(&ccb->xs->xs_callout,
@@ -580,6 +520,7 @@
 
        TAILQ_INIT(&sc->sc_free_ccb);
        TAILQ_INIT(&sc->sc_waiting_ccb);
+       TAILQ_INIT(&sc->sc_pending_ccb);
        TAILQ_INIT(&sc->sc_queue);
 
 
@@ -613,7 +554,7 @@
        if (error)
                return; /* (error) */ ;
 
-       bzero(sc->sc_control->carriers, ADW_CARRIER_SIZE * ADW_MAX_CARRIER);
+       bzero(sc->sc_control->carriers, sizeof(ADW_CARRIER) * ADW_MAX_CARRIER);
 
        i = adw_create_carriers(sc);
        if (i == 0) {
@@ -647,6 +588,16 @@
        }
 
        switch (error) {
+       case ASC_IERR_BIST_PRE_TEST:
+               panic("%s: BIST pre-test error",
+                     sc->sc_dev.dv_xname);
+               break;
+
+       case ASC_IERR_BIST_RAM_TEST:
+               panic("%s: BIST RAM test error",
+                     sc->sc_dev.dv_xname);
+               break;
+
        case ASC_IERR_MCODE_CHKSUM:
                panic("%s: Microcode checksum error",
                      sc->sc_dev.dv_xname);
@@ -662,6 +613,11 @@
                      sc->sc_dev.dv_xname);
                break;
 
+       case ASC_IERR_HVD_DEVICE:
+               panic("%s: HVD attached to LVD connector",
+                     sc->sc_dev.dv_xname);
+               break;
+
        case ASC_IERR_SINGLE_END_DEVICE:
                panic("%s: single-ended device is attached to"
                      " one of the connectors",
@@ -814,7 +770,6 @@
                case ADW_ERROR:
                        xs->error = XS_DRIVER_STUFFUP;
                        return (COMPLETE);
-                       
                }
 
                /*
@@ -1061,27 +1016,97 @@
        s = splbio();
 
        /*
-         * If it has been through before, then a previous abort has failed,
+         * If it has been through before, then previous aborts failed,
          * don't try abort again, reset the bus instead.
          */
        if (ccb->flags & CCB_ABORTED) {
        /*
         * Abort Timed Out
-        * Lets try resetting the bus!
+        *
+        * No more opportunities. Lets try resetting the bus!
         */
+               callout_stop(&xs->xs_callout);
+
                printf(" AGAIN. Resetting SCSI Bus\n");
-               ccb->flags &= ~CCB_ABORTED;
-               /* AdvResetSCSIBus() will call sbreset_callback() */
                AdvResetSCSIBus(sc);
+
+               while((ccb = TAILQ_LAST(&sc->sc_pending_ccb,
+                               adw_pending_ccb)) != NULL) {
+                       callout_stop(&ccb->xs->xs_callout);
+                       TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);



Home | Main Index | Thread Index | Old Index