Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Cleanup the scsipi_xfer flags:



details:   https://anonhg.NetBSD.org/src/rev/38471872d5f9
branches:  trunk
changeset: 476884:38471872d5f9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Sep 30 22:57:52 1999 +0000

description:
Cleanup the scsipi_xfer flags:
- `flags' is now gone, replaced with `xs_control' and `xs_status'.
- Massive cleanup of the control flags.  Now we explicitly say that
  a job is to complete asynchronously, rather than relying on side-effects,
  and use a new flag to now that device discovery is being performed.
- Do SCSI device discovery interrupt-driven.

diffstat:

 sys/dev/scsipi/atapi_base.c   |  24 ++++++-----
 sys/dev/scsipi/atapi_wdc.c    |  45 +++++++++++----------
 sys/dev/scsipi/atapiconf.c    |   5 +-
 sys/dev/scsipi/cd.c           |  38 +++++++++--------
 sys/dev/scsipi/cd_scsi.c      |   6 +-
 sys/dev/scsipi/ch.c           |  23 +++++-----
 sys/dev/scsipi/if_se.c        |  18 ++++----
 sys/dev/scsipi/scsi_base.c    |   6 +-
 sys/dev/scsipi/scsiconf.c     |  39 ++++++++++++++----
 sys/dev/scsipi/scsipi_base.c  |  88 +++++++++++++++++++++++++-----------------
 sys/dev/scsipi/scsipi_ioctl.c |  14 +++---
 sys/dev/scsipi/scsipiconf.h   |  89 +++++++++++++++++++++++-------------------
 sys/dev/scsipi/sd.c           |  42 +++++++++++---------
 sys/dev/scsipi/sd_atapi.c     |   4 +-
 sys/dev/scsipi/sd_scsi.c      |   8 +-
 sys/dev/scsipi/ss.c           |  10 ++--
 sys/dev/scsipi/ss_mustek.c    |  11 ++--
 sys/dev/scsipi/ss_scanjet.c   |  13 +++--
 sys/dev/scsipi/st.c           |  61 ++++++++++++++--------------
 19 files changed, 302 insertions(+), 242 deletions(-)

diffs (truncated from 1791 to 300 lines):

diff -r e7e6ab94e569 -r 38471872d5f9 sys/dev/scsipi/atapi_base.c
--- a/sys/dev/scsipi/atapi_base.c       Thu Sep 30 22:28:11 1999 +0000
+++ b/sys/dev/scsipi/atapi_base.c       Thu Sep 30 22:57:52 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atapi_base.c,v 1.13 1999/08/28 22:28:35 thorpej Exp $  */
+/*     $NetBSD: atapi_base.c,v 1.14 1999/09/30 22:57:52 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -98,9 +98,9 @@
                case SKEY_NOT_READY:
                        if ((sc_link->flags & SDEV_REMOVABLE) != 0)
                                sc_link->flags &= ~SDEV_MEDIA_LOADED;
-                       if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0)
+                       if ((xs->xs_control & XS_CTL_IGNORE_NOT_READY) != 0)
                                return (0);
-                       if ((xs->flags & SCSI_SILENT) != 0)
+                       if ((xs->xs_control & XS_CTL_SILENT) != 0)
                                return (EIO);
                        msg = "not ready";
                        error = EIO;
@@ -114,9 +114,10 @@
                        error = EIO;
                        break;
                case SKEY_ILLEGAL_REQUEST:
-                       if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)
+                       if ((xs->xs_control &
+                            XS_CTL_IGNORE_ILLEGAL_REQUEST) != 0)
                                return (0);
-                       if ((xs->flags & SCSI_SILENT) != 0)
+                       if ((xs->xs_control & XS_CTL_SILENT) != 0)
                                return (EIO);
                        msg = "illegal request";
                        error = EINVAL;
@@ -124,11 +125,12 @@
                case SKEY_UNIT_ATTENTION:
                        if ((sc_link->flags & SDEV_REMOVABLE) != 0)
                                sc_link->flags &= ~SDEV_MEDIA_LOADED;
-                       if ((xs->flags & SCSI_IGNORE_MEDIA_CHANGE) != 0 ||
+                       if ((xs->xs_control &
+                            XS_CTL_IGNORE_MEDIA_CHANGE) != 0 ||
                            /* XXX Should reupload any transient state. */
                            (sc_link->flags & SDEV_REMOVABLE) == 0)
                                return (ERESTART);
-                       if ((xs->flags & SCSI_SILENT) != 0)
+                       if ((xs->xs_control & XS_CTL_SILENT) != 0)
                                return (EIO);
                        msg = "unit attention";
                        error = EIO;
@@ -221,8 +223,8 @@
        SC_DEBUG(sc_link, SDEV_DB2, ("atapi_cmd\n"));
 
 #ifdef DIAGNOSTIC
-       if (bp != 0 && (flags & SCSI_NOSLEEP) == 0)
-               panic("atapi_scsipi_cmd: buffer without nosleep");
+       if (bp != NULL && (flags & XS_CTL_ASYNC) == 0)
+               panic("atapi_scsipi_cmd: buffer without async");
 #endif
 
        if ((xs = scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr,
@@ -271,7 +273,7 @@
 
        error = scsipi_command(l, (struct scsipi_generic *)&scsipi_cmd,
            sizeof(scsipi_cmd), (void *)data, len, retries, timeout, NULL,
-           flags | SCSI_DATA_OUT);
+           flags | XS_CTL_DATA_OUT);
        SC_DEBUG(l, SDEV_DB2, ("atapi_mode_select: error=%d\n", error));
        return (error);
 }
@@ -292,7 +294,7 @@
 
        error = scsipi_command(l, (struct scsipi_generic *)&scsipi_cmd,
            sizeof(scsipi_cmd), (void *)data, len, retries, timeout, NULL,
-           flags | SCSI_DATA_IN);
+           flags | XS_CTL_DATA_IN);
        SC_DEBUG(l, SDEV_DB2, ("atapi_mode_sense: error=%d\n", error));
        return (error);
 }
diff -r e7e6ab94e569 -r 38471872d5f9 sys/dev/scsipi/atapi_wdc.c
--- a/sys/dev/scsipi/atapi_wdc.c        Thu Sep 30 22:28:11 1999 +0000
+++ b/sys/dev/scsipi/atapi_wdc.c        Thu Sep 30 22:57:52 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atapi_wdc.c,v 1.26 1999/09/23 11:04:33 enami Exp $     */
+/*     $NetBSD: atapi_wdc.c,v 1.27 1999/09/30 22:57:52 thorpej Exp $   */
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.
@@ -189,7 +189,7 @@
 {
        struct wdc_softc *wdc = (void*)sc_xfer->sc_link->adapter_softc;
        struct wdc_xfer *xfer;
-       int flags = sc_xfer->flags;
+       int flags = sc_xfer->xs_control;
        int channel = sc_xfer->sc_link->scsipi_atapi.channel;
        int drive = sc_xfer->sc_link->scsipi_atapi.drive;
        int s, ret;
@@ -197,11 +197,12 @@
        WDCDEBUG_PRINT(("wdc_atapi_send_cmd %s:%d:%d\n",
            wdc->sc_dev.dv_xname, channel, drive), DEBUG_XFERS);
 
-       xfer = wdc_get_xfer(flags & SCSI_NOSLEEP ? WDC_NOSLEEP : WDC_CANSLEEP);
+       xfer = wdc_get_xfer((flags & XS_CTL_NOSLEEP) ?
+           WDC_NOSLEEP : WDC_CANSLEEP);
        if (xfer == NULL) {
                return TRY_AGAIN_LATER;
        }
-       if (sc_xfer->flags & SCSI_POLL)
+       if (sc_xfer->xs_control & XS_CTL_POLL)
                xfer->c_flags |= C_POLL;
        xfer->drive = drive;
        xfer->c_flags |= C_ATAPI;
@@ -213,11 +214,12 @@
        s = splbio();
        wdc_exec_xfer(wdc->channels[channel], xfer);
 #ifdef DIAGNOSTIC
-       if ((sc_xfer->flags & SCSI_POLL) != 0 &&
-           (sc_xfer->flags & ITSDONE) == 0)
+       if ((sc_xfer->xs_control & XS_CTL_POLL) != 0 &&
+           (sc_xfer->xs_status & XS_STS_DONE) == 0)
                panic("wdc_atapi_send_cmd: polled command not done");
 #endif
-       ret = (sc_xfer->flags & ITSDONE) ? COMPLETE : SUCCESSFULLY_QUEUED;
+       ret = (sc_xfer->xs_status & XS_STS_DONE) ?
+           COMPLETE : SUCCESSFULLY_QUEUED;
        splx(s);
        return ret;
 }
@@ -232,7 +234,7 @@
 
        WDCDEBUG_PRINT(("wdc_atapi_start %s:%d:%d, scsi flags 0x%x \n",
            chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive,
-           sc_xfer->flags), DEBUG_XFERS);
+           sc_xfer->xs_control), DEBUG_XFERS);
        /* Adjust C_DMA, it may have changed if we are requesting sense */
        if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
            (sc_xfer->datalen > 0 || (xfer->c_flags & C_SENSE)))
@@ -240,7 +242,7 @@
        else
                xfer->c_flags &= ~C_DMA;
        /* start timeout machinery */
-       if ((sc_xfer->flags & SCSI_POLL) == 0)
+       if ((sc_xfer->xs_control & XS_CTL_POLL) == 0)
                timeout(wdctimeout, chp, sc_xfer->timeout * hz / 1000);
        /* Do control operations specially. */
        if (drvp->state < READY) {
@@ -283,15 +285,15 @@
         * routine until command is done.
         */
        if ((sc_xfer->sc_link->scsipi_atapi.cap  & ATAPI_CFG_DRQ_MASK) !=
-           ATAPI_CFG_IRQ_DRQ || (sc_xfer->flags & SCSI_POLL)) {
+           ATAPI_CFG_IRQ_DRQ || (sc_xfer->xs_control & XS_CTL_POLL)) {
                /* Wait for at last 400ns for status bit to be valid */
                DELAY(1);
                wdc_atapi_intr(chp, xfer, 0);
        } else {
                chp->ch_flags |= WDCF_IRQ_WAIT;
        }
-       if (sc_xfer->flags & SCSI_POLL) {
-               while ((sc_xfer->flags & ITSDONE) == 0) {
+       if (sc_xfer->xs_control & XS_CTL_POLL) {
+               while ((sc_xfer->xs_status & XS_STS_DONE) == 0) {
                        /* Wait for at last 400ns for status bit to be valid */
                        DELAY(1);
                        wdc_atapi_intr(chp, xfer, 0);
@@ -370,9 +372,10 @@
        }
 
        if (xfer->c_flags & C_DMA) {
-               dma_flags = ((sc_xfer->flags & SCSI_DATA_IN) ||
+               dma_flags = ((sc_xfer->xs_control & XS_CTL_DATA_IN) ||
                    (xfer->c_flags & C_SENSE)) ?  WDC_DMA_READ : 0;
-               dma_flags |= sc_xfer->flags & SCSI_POLL ? WDC_DMA_POLL : 0;
+               dma_flags |= sc_xfer->xs_control & XS_CTL_POLL ?
+                   WDC_DMA_POLL : 0;
        }
 again:
        len = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_lo) +
@@ -436,7 +439,7 @@
                            chp->channel, xfer->drive, dma_flags);
                }
 
-               if ((sc_xfer->flags & SCSI_POLL) == 0) {
+               if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
                        chp->ch_flags |= WDCF_IRQ_WAIT;
                }
                return 1;
@@ -444,7 +447,7 @@
         case PHASE_DATAOUT:
                /* write data */
                WDCDEBUG_PRINT(("PHASE_DATAOUT\n"), DEBUG_INTR);
-               if ((sc_xfer->flags & SCSI_DATA_OUT) == 0 ||
+               if ((sc_xfer->xs_control & XS_CTL_DATA_OUT) == 0 ||
                    (xfer->c_flags & C_DMA) != 0) {
                        printf("wdc_atapi_intr: bad data phase DATAOUT\n");
                        if (xfer->c_flags & C_DMA) {
@@ -513,7 +516,7 @@
                            xfer->c_bcount -= len;
                        }
                }
-               if ((sc_xfer->flags & SCSI_POLL) == 0) {
+               if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
                        chp->ch_flags |= WDCF_IRQ_WAIT;
                }
                return 1;
@@ -521,7 +524,7 @@
        case PHASE_DATAIN:
                /* Read data */
                WDCDEBUG_PRINT(("PHASE_DATAIN\n"), DEBUG_INTR);
-               if (((sc_xfer->flags & SCSI_DATA_IN) == 0 &&
+               if (((sc_xfer->xs_control & XS_CTL_DATA_IN) == 0 &&
                    (xfer->c_flags & C_SENSE) == 0) || 
                    (xfer->c_flags & C_DMA) != 0) {
                        printf("wdc_atapi_intr: bad data phase DATAIN\n");
@@ -589,7 +592,7 @@
                            xfer->c_bcount -=len;
                        }
                }
-               if ((sc_xfer->flags & SCSI_POLL) == 0) {
+               if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
                        chp->ch_flags |= WDCF_IRQ_WAIT;
                }
                return 1;
@@ -768,7 +771,7 @@
                wdc_atapi_start(chp, xfer);
                return 1;
        }
-       if ((sc_xfer->flags & SCSI_POLL) == 0) {
+       if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
                chp->ch_flags |= WDCF_IRQ_WAIT;
                xfer->c_intr = wdc_atapi_ctrl;
        } else {
@@ -810,7 +813,7 @@
        untimeout(wdctimeout, chp);
        /* remove this command from xfer queue */
        wdc_free_xfer(chp, xfer);
-       sc_xfer->flags |= ITSDONE;
+       sc_xfer->xs_status |= XS_STS_DONE;
        if (drvp->n_dmaerrs ||
          (sc_xfer->error != XS_NOERROR && sc_xfer->error != XS_SENSE &&
          sc_xfer->error != XS_SHORTSENSE)) {
diff -r e7e6ab94e569 -r 38471872d5f9 sys/dev/scsipi/atapiconf.c
--- a/sys/dev/scsipi/atapiconf.c        Thu Sep 30 22:28:11 1999 +0000
+++ b/sys/dev/scsipi/atapiconf.c        Thu Sep 30 22:57:52 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atapiconf.c,v 1.27 1999/09/23 11:04:33 enami Exp $     */
+/*     $NetBSD: atapiconf.c,v 1.28 1999/09/30 22:57:53 thorpej Exp $   */
 
 /*
  * Copyright (c) 1996 Manuel Bouyer.  All rights reserved.
@@ -322,7 +322,7 @@
                return;
 
        if (wdc_atapi_get_params(atapi->adapter_link, target,
-           SCSI_POLL|SCSI_NOSLEEP, id) == COMPLETE) {
+           XS_CTL_POLL|XS_CTL_NOSLEEP, id) == COMPLETE) {
 #ifdef ATAPI_DEBUG_PROBE
                printf("%s drive %d: cmdsz 0x%x drqtype 0x%x\n",
                    atapi->sc_dev.dv_xname, target,
@@ -342,6 +342,7 @@
                }
                /* Fill in link. */
                *sc_link = *atapi->adapter_link;
+               sc_link->active = 0;
                sc_link->scsipi_atapi.drive = target;
                sc_link->device = NULL;
                TAILQ_INIT(&sc_link->pending_xfers);
diff -r e7e6ab94e569 -r 38471872d5f9 sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Thu Sep 30 22:28:11 1999 +0000
+++ b/sys/dev/scsipi/cd.c       Thu Sep 30 22:57:52 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.129 1999/09/23 11:04:33 enami Exp $   */
+/*     $NetBSD: cd.c,v 1.130 1999/09/30 22:57:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -344,8 +344,8 @@
        } else {
                /* Check that it is still responding and ok. */
                error = scsipi_test_unit_ready(sc_link,
-                   SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
-                   SCSI_IGNORE_NOT_READY);
+                   XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_MEDIA_CHANGE |
+                   XS_CTL_IGNORE_NOT_READY);
                SC_DEBUG(sc_link, SDEV_DB1,
                    ("cdopen: scsipi_test_unit_ready, error=%d\n", error));
                if (error)
@@ -357,8 +357,8 @@
                 * will check for SDEV_MEDIA_LOADED.
                 */
                error = scsipi_start(sc_link, SSS_START,
-                   SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
-                   SCSI_SILENT);
+                   XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_MEDIA_CHANGE |
+                   XS_CTL_SILENT);
                SC_DEBUG(sc_link, SDEV_DB1,
                    ("cdopen: scsipi_start, error=%d\n", error));
                if (error) {
@@ -372,7 +372,7 @@
 
                /* Lock the pack in. */



Home | Main Index | Thread Index | Old Index