summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormjacob <mjacob@NetBSD.org>2000-01-04 22:35:57 +0000
committermjacob <mjacob@NetBSD.org>2000-01-04 22:35:57 +0000
commitc763ef5b5d2abd92660eb91c7860c4f3f15b0e03 (patch)
treea90d01f5d34d09b354879e8ef08cc3804a817f24 /sys/dev
parent56f2ef9f29f47ba8122dd52c60c643fde151eda7 (diff)
- If the user application issues an INITIALIZE ELEMENT STATUS which
succeeds, note that we now are valid. - Don't attempt to try and run initialize element status from interrupt level- we don't really support that yet. Also, key more correctly off of ASC/ASCQ instead of just the sense key. - Make the practice of doing an INITIALIZE ELEMENT STATUS automatically when we get params (from chopen time even) a policy decision that is not the default for now- this can be a dangerous practice as well as time consuming. It's dangerous in that you can have a hung open when all you really want to do is do a read of parameters- and parameters, including slot status, are perfectly fine to read even before an INITIALIZE ELEMENT STATUS is done- all the elements whos status your read are going to be marked with an exception- so leave it up to the application to decide how important this is.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/scsipi/ch.c70
1 files changed, 39 insertions, 31 deletions
diff --git a/sys/dev/scsipi/ch.c b/sys/dev/scsipi/ch.c
index 0a46c3f7f20..160536527bf 100644
--- a/sys/dev/scsipi/ch.c
+++ b/sys/dev/scsipi/ch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ch.c,v 1.40 1999/09/30 22:57:53 thorpej Exp $ */
+/* $NetBSD: ch.c,v 1.41 2000/01/04 22:35:57 mjacob Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -402,6 +402,9 @@ chioctl(dev, cmd, data, flags, p)
case CHIOIELEM:
error = ch_ielem(sc);
+ if (error == 0) {
+ sc->sc_link->flags |= SDEV_MEDIA_LOADED;
+ }
break;
case OCHIOGSTATUS:
@@ -463,46 +466,49 @@ ch_interpret_sense(xs)
struct scsipi_link *sc_link = xs->sc_link;
struct scsipi_sense_data *sense = &xs->sense.scsi_sense;
struct ch_softc *sc = sc_link->device_softc;
- int error, retval = SCSIRET_CONTINUE;
+ u_int16_t asc_ascq;
/*
- * If it isn't an extended or extended/defered error, let
+ * If it isn't an extended or extended/deferred error, let
* the generic code handle it.
*/
if ((sense->error_code & SSD_ERRCODE) != 0x70 &&
(sense->error_code & SSD_ERRCODE) != 0x71)
- return (retval);
+ return (SCSIRET_CONTINUE);
+
+ /*
+ * We're only interested in condtions that
+ * indicate potential inventory violation.
+ *
+ * We use ASC/ASCQ codes for this.
+ */
- if ((sense->flags & SSD_KEY) == SKEY_UNIT_ATTENTION) {
+ asc_ascq = (((u_int16_t) sense->add_sense_code) << 8) |
+ sense->add_sense_code_qual;
+
+ switch (asc_ascq) {
+ case 0x2800:
+ /* "Not Ready To Ready Transition (Medium May Have Changed)" */
+ case 0x2900:
+ /* "Power On, Reset, or Bus Device Reset Occurred" */
+ sc->sc_link->flags &= ~SDEV_MEDIA_LOADED;
/*
- * The element status has possibly changed, usually because
- * an operator has opened the door. We need to initialize
- * the element status. If we haven't gotten our params yet,
- * then we are about to (we are getting here via chopen()).
- * Just notify ch_get_params() that we need to do an
- * Init-Element-Status. Otherwise, we need to call
- * ch_get_params() ourselves.
+ * Enqueue an Element-Status-Changed event, and
+ * wake up any processes waiting for them.
*/
- retval = SCSIRET_RETRY;
- if (sc->sc_link->flags & SDEV_MEDIA_LOADED) {
- sc->sc_link->flags &= ~SDEV_MEDIA_LOADED;
- if ((xs->xs_control &
- XS_CTL_IGNORE_MEDIA_CHANGE) == 0) {
- error = ch_get_params(sc, 0);
- if (error)
- retval = error;
- }
+ if ((xs->flags & SCSI_IGNORE_MEDIA_CHANGE) == 0) {
+ ch_event(sc, CHEV_ELEMENT_STATUS_CHANGED);
}
-
/*
- * Enqueue an Element-Status-Changed event, and wake up
- * any processes waiting for them.
+ * When we get interrupt threads, we can possibly
+ * run automatic corrective commands here if the
+ * policy is that we do so.
*/
- if ((xs->xs_control & XS_CTL_IGNORE_MEDIA_CHANGE) == 0)
- ch_event(sc, CHEV_ELEMENT_STATUS_CHANGED);
+ break;
+ default:
+ break;
}
-
- return (retval);
+ return (SCSIRET_CONTINUE);
}
void
@@ -1159,7 +1165,7 @@ ch_get_params(sc, scsiflags)
sc->sc_firsts[CHET_DT] = _2btol(sense_data.pages.ea.fdtea);
sc->sc_counts[CHET_DT] = _2btol(sense_data.pages.ea.ndte);
- /* XXX ask for page trasport geom */
+ /* XXX ask for transport geometry page XXX */
/*
* Grab info from the capabilities page.
@@ -1192,9 +1198,10 @@ ch_get_params(sc, scsiflags)
sc->sc_exchangemask[from] = exchanges[from];
}
+#ifdef CH_AUTOMATIC_IELEM_POLICY
/*
- * If we need to do an Init-Element-Status, do that now that
- * we know what's in the changer.
+ * If we need to do an Init-Element-Status,
+ * do that now that we know what's in the changer.
*/
if ((scsiflags & XS_CTL_IGNORE_MEDIA_CHANGE) == 0) {
if ((sc->sc_link->flags & SDEV_MEDIA_LOADED) == 0)
@@ -1204,6 +1211,7 @@ ch_get_params(sc, scsiflags)
else
sc->sc_link->flags &= ~SDEV_MEDIA_LOADED;
}
+#endif
return (error);
}