Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/dev/ic Pull up revisions 1.23-1.24, 1.28-1.36 (reque...



details:   https://anonhg.NetBSD.org/src/rev/716712f36e5f
branches:  netbsd-1-5
changeset: 490383:716712f36e5f
user:      he <he%NetBSD.org@localhost>
date:      Fri Dec 15 04:48:03 2000 +0000

description:
Pull up revisions 1.23-1.24,1.28-1.36 (requested by bouyer):
  Speed improvements to the siop driver, and add tagged queueing
  support.  As a side effect, better handling of some not so common
  phase or message sequences.

diffstat:

 sys/dev/ic/siop.c |  1471 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 939 insertions(+), 532 deletions(-)

diffs (truncated from 2119 to 300 lines):

diff -r 3d03e66e1935 -r 716712f36e5f sys/dev/ic/siop.c
--- a/sys/dev/ic/siop.c Fri Dec 15 04:47:06 2000 +0000
+++ b/sys/dev/ic/siop.c Fri Dec 15 04:48:03 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siop.c,v 1.21.2.4 2000/10/03 15:21:43 bouyer Exp $     */
+/*     $NetBSD: siop.c,v 1.21.2.5 2000/12/15 04:48:03 he Exp $ */
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -42,10 +42,6 @@
 #include <machine/endian.h>
 #include <machine/bus.h>
 
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_kern.h>
-
 #include <dev/microcode/siop/siop.out>
 
 #include <dev/scsipi/scsi_all.h>
@@ -58,10 +54,13 @@
 #include <dev/ic/siopvar.h>
 #include <dev/ic/siopvar_common.h>
 
+#ifndef DEBUG
 #undef DEBUG
-#undef DEBUG_DR
-#undef DEBUG_INTR
-#undef DEBUG_SHED
+#endif
+#undef SIOP_DEBUG
+#undef SIOP_DEBUG_DR
+#undef SIOP_DEBUG_INTR
+#undef SIOP_DEBUG_SCHED
 #undef DUMP_SCRIPT
 
 #define SIOP_STATS
@@ -73,14 +72,21 @@
 /* number of cmd descriptors per block */
 #define SIOP_NCMDPB (NBPG / sizeof(struct siop_xfer))
 
+/* Number of scheduler slot (needs to match script) */
+#define SIOP_NSLOTS 40
+
 void   siop_reset __P((struct siop_softc *));
 void   siop_handle_reset __P((struct siop_softc *));
+int    siop_handle_qtag_reject __P((struct siop_cmd *));
 void   siop_scsicmd_end __P((struct siop_cmd *));
 void   siop_start __P((struct siop_softc *));
 void   siop_timeout __P((void *));
 int    siop_scsicmd __P((struct scsipi_xfer *));
 void   siop_dump_script __P((struct siop_softc *));
 int    siop_morecbd __P((struct siop_softc *));
+struct siop_lunsw *siop_get_lunsw __P((struct siop_softc *));
+void   siop_add_reselsw __P((struct siop_softc *, int));
+void   siop_update_scntl3 __P((struct siop_softc *, struct siop_target *));
 
 struct scsipi_adapter siop_adapter = {
        0,
@@ -103,36 +109,51 @@
 static int siop_stat_intr_shortxfer = 0;
 static int siop_stat_intr_sdp = 0;
 static int siop_stat_intr_done = 0;
-static int siop_stat_intr_reselect = 0;
 static int siop_stat_intr_xferdisc = 0;
+static int siop_stat_intr_lunresel = 0;
+static int siop_stat_intr_qfull = 0;
 void siop_printstats __P((void));
 #define INCSTAT(x) x++
 #else
 #define INCSTAT(x) 
 #endif
 
-static __inline__ void siop_table_sync __P((struct siop_cmd *, int));
+static __inline__ void siop_script_sync __P((struct siop_softc *, int));
 static __inline__ void
-siop_table_sync(siop_cmd, ops)
-       struct siop_cmd *siop_cmd;
-       int ops;
-{
-       struct siop_softc *sc  = siop_cmd->siop_target->siop_sc;
-       bus_addr_t offset;
-       
-       offset = siop_cmd->dsa -
-           siop_cmd->siop_cbdp->xferdma->dm_segs[0].ds_addr;
-       bus_dmamap_sync(sc->sc_dmat, siop_cmd->siop_cbdp->xferdma, offset,
-           sizeof(struct siop_xfer), ops);
-}
-
-static __inline__ void siop_shed_sync __P((struct siop_softc *, int));
-static __inline__ void
-siop_shed_sync(sc, ops)
+siop_script_sync(sc, ops)
        struct siop_softc *sc;
        int ops;
 {
-       bus_dmamap_sync(sc->sc_dmat, sc->sc_sheddma, 0, NBPG, ops);
+       if ((sc->features & SF_CHIP_RAM) == 0)
+               bus_dmamap_sync(sc->sc_dmat, sc->sc_scriptdma, 0, NBPG, ops);
+}
+
+static __inline__ u_int32_t siop_script_read __P((struct siop_softc *, u_int));
+static __inline__ u_int32_t
+siop_script_read(sc, offset)
+       struct siop_softc *sc;
+       u_int offset;
+{
+       if (sc->features & SF_CHIP_RAM) {
+               return bus_space_read_4(sc->sc_ramt, sc->sc_ramh, offset * 4);
+       } else {
+               return le32toh(sc->sc_script[offset]);
+       }
+}
+
+static __inline__ void siop_script_write __P((struct siop_softc *, u_int,
+       u_int32_t));
+static __inline__ void
+siop_script_write(sc, offset, val)
+       struct siop_softc *sc;
+       u_int offset;
+       u_int32_t val;
+{
+       if (sc->features & SF_CHIP_RAM) {
+               bus_space_write_4(sc->sc_ramt, sc->sc_ramh, offset * 4, val);
+       } else {
+               sc->sc_script[offset] = htole32(val);
+       }
 }
 
 void
@@ -144,8 +165,7 @@
        int rseg;
 
        /*
-        * Allocate DMA-safe memory for the script and script scheduler
-        * and map it.
+        * Allocate DMA-safe memory for the script and map it.
         */
        if ((sc->features & SF_CHIP_RAM) == 0) {
                error = bus_dmamem_alloc(sc->sc_dmat, NBPG, 
@@ -170,59 +190,29 @@
                        return;
                }
                error = bus_dmamap_load(sc->sc_dmat, sc->sc_scriptdma,
-                   sc->sc_script,
-                   NBPG, NULL, BUS_DMA_NOWAIT);
+                   sc->sc_script, NBPG, NULL, BUS_DMA_NOWAIT);
                if (error) {
                        printf("%s: unable to load script DMA map, "
                            "error = %d\n", sc->sc_dev.dv_xname, error);
                        return;
                }
                sc->sc_scriptaddr = sc->sc_scriptdma->dm_segs[0].ds_addr;
-       }
-       error = bus_dmamem_alloc(sc->sc_dmat, NBPG, 
-           NBPG, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
-       if (error) {
-               printf("%s: unable to allocate scheduler DMA memory, "
-                   "error = %d\n", sc->sc_dev.dv_xname, error);
-               return;
-       }
-       error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, NBPG,
-           (caddr_t *)&sc->sc_shed, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
-       if (error) {
-               printf("%s: unable to map scheduler DMA memory, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
-               return;
-       }
-       error = bus_dmamap_create(sc->sc_dmat, NBPG, 1,
-           NBPG, 0, BUS_DMA_NOWAIT, &sc->sc_sheddma);
-       if (error) {
-               printf("%s: unable to create scheduler DMA map, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
-               return;
-       }
-       error = bus_dmamap_load(sc->sc_dmat, sc->sc_sheddma, sc->sc_shed,
-           NBPG, NULL, BUS_DMA_NOWAIT);
-       if (error) {
-               printf("%s: unable to load scheduler DMA map, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
-               return;
+               sc->ram_size = NBPG;
        }
        TAILQ_INIT(&sc->free_list);
+       TAILQ_INIT(&sc->ready_list);
+       TAILQ_INIT(&sc->urgent_list);
        TAILQ_INIT(&sc->cmds);
-       /* compute number of scheduler slots */
-       sc->sc_nshedslots = (
-           NBPG /* memory size allocated for scheduler */
-           - sizeof(endslot_script) /* memory needed at end of scheduler */
-           ) / (sizeof(slot_script) - 8);
-       sc->sc_currshedslot = 0;
-#ifdef DEBUG
-       printf("%s: script size = %d, PHY addr=0x%x, VIRT=%p nslots %d\n",
+       TAILQ_INIT(&sc->lunsw_list);
+       sc->sc_currschedslot = 0;
+#ifdef SIOP_DEBUG
+       printf("%s: script size = %d, PHY addr=0x%x, VIRT=%p\n",
            sc->sc_dev.dv_xname, (int)sizeof(siop_script),
-           sc->sc_scriptaddr, sc->sc_script, sc->sc_nshedslots);
+           (u_int32_t)sc->sc_scriptaddr, sc->sc_script);
 #endif
 
        sc->sc_link.adapter_softc = sc;
-       sc->sc_link.openings = 1;
+       sc->sc_link.openings = 2;
        sc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
        sc->sc_link.scsipi_scsi.max_target  =
            (sc->features & SF_BUS_WIDE) ? 15 : 7;
@@ -272,8 +262,7 @@
        struct siop_softc *sc;
 {
        int i, j;
-       u_int32_t *scr;
-       bus_addr_t physaddr;
+       struct siop_lunsw *lunsw;
 
        siop_common_reset(sc);
 
@@ -282,12 +271,11 @@
                bus_space_write_region_4(sc->sc_ramt, sc->sc_ramh, 0,
                    siop_script, sizeof(siop_script) / sizeof(siop_script[0]));
                for (j = 0; j <
-                   (sizeof(E_script_abs_shed_Used) /
-                   sizeof(E_script_abs_shed_Used[0]));
+                   (sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
                    j++) {
                        bus_space_write_4(sc->sc_ramt, sc->sc_ramh,
-                           E_script_abs_shed_Used[j] * 4,
-                           sc->sc_sheddma->dm_segs[0].ds_addr);
+                           E_abs_msgin_Used[j] * 4,
+                           sc->sc_scriptaddr + Ent_msgin_space);
                }
        } else {
                for (j = 0;
@@ -295,52 +283,48 @@
                        sc->sc_script[j] = htole32(siop_script[j]);
                }
                for (j = 0; j <
-                   (sizeof(E_script_abs_shed_Used) /
-                   sizeof(E_script_abs_shed_Used[0]));
+                   (sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
                    j++) {
-                       sc->sc_script[E_script_abs_shed_Used[j]] =
-                               htole32(sc->sc_sheddma->dm_segs[0].ds_addr);
+                       sc->sc_script[E_abs_msgin_Used[j]] =
+                           htole32(sc->sc_scriptaddr + Ent_msgin_space);
                }
        }
-       /* copy and init the scheduler slots script */
-       for (i = 0; i < sc->sc_nshedslots; i++) {
-               scr = &sc->sc_shed[(Ent_nextslot / 4) * i];
-               physaddr = sc->sc_sheddma->dm_segs[0].ds_addr +
-                   Ent_nextslot * i;
-               for (j = 0; j < (sizeof(slot_script) / sizeof(slot_script[0]));
-                   j++) {
-                       scr[j] = htole32(slot_script[j]);
+       sc->script_free_lo = sizeof(siop_script) / sizeof(siop_script[0]);
+       sc->script_free_hi = sc->ram_size / 4;
+
+       /* free used and unused lun switches */
+       while((lunsw = TAILQ_FIRST(&sc->lunsw_list)) != NULL) {
+#ifdef SIOP_DEBUG
+               printf("%s: free lunsw at offset %d\n",
+                               sc->sc_dev.dv_xname, lunsw->lunsw_off);
+#endif
+               TAILQ_REMOVE(&sc->lunsw_list, lunsw, next);
+               free(lunsw, M_DEVBUF);
+       }
+       TAILQ_INIT(&sc->lunsw_list);
+       /* restore reselect switch */
+       for (i = 0; i <= sc->sc_link.scsipi_scsi.max_target; i++) {
+               if (sc->targets[i] == NULL)
+                       continue;
+#ifdef SIOP_DEBUG
+               printf("%s: restore sw for target %d\n",
+                               sc->sc_dev.dv_xname, i);
+#endif
+               free(sc->targets[i]->lunsw, M_DEVBUF);
+               sc->targets[i]->lunsw = siop_get_lunsw(sc);
+               if (sc->targets[i]->lunsw == NULL) {
+                       printf("%s: can't alloc lunsw for target %d\n",
+                           sc->sc_dev.dv_xname, i);
+                       break;
                }
-               /*
-                * save current jump offset and patch MOVE MEMORY operands
-                * to restore it.
-                */
-               scr[Ent_slotdata/4 + 1] = scr[Ent_slot/4 + 1];
-               scr[E_slot_nextp_Used[0]] = htole32(physaddr + Ent_slot + 4);
-               scr[E_slot_shed_addrsrc_Used[0]] = htole32(physaddr +
-                   Ent_slotdata + 4);
-               /* JUMP selected, in main script */
-               scr[E_slot_abs_selected_Used[0]] =
-                  htole32(sc->sc_scriptaddr + Ent_selected);
-               /* JUMP addr if SELECT fail */
-               scr[E_slot_abs_reselect_Used[0]] = 
-                  htole32(sc->sc_scriptaddr + Ent_reselect);



Home | Main Index | Thread Index | Old Index