Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi - If the user application issues an INITIALIZ...
details: https://anonhg.NetBSD.org/src/rev/4ad615a49d4a
branches: trunk
changeset: 480124:4ad615a49d4a
user: mjacob <mjacob%NetBSD.org@localhost>
date: Tue Jan 04 22:35:57 2000 +0000
description:
- 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:
sys/dev/scsipi/ch.c | 70 +++++++++++++++++++++++++++++-----------------------
1 files changed, 39 insertions(+), 31 deletions(-)
diffs (126 lines):
diff -r 04d68f9b6034 -r 4ad615a49d4a sys/dev/scsipi/ch.c
--- a/sys/dev/scsipi/ch.c Tue Jan 04 21:37:54 2000 +0000
+++ b/sys/dev/scsipi/ch.c Tue Jan 04 22:35:57 2000 +0000
@@ -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 @@
case CHIOIELEM:
error = ch_ielem(sc);
+ if (error == 0) {
+ sc->sc_link->flags |= SDEV_MEDIA_LOADED;
+ }
break;
case OCHIOGSTATUS:
@@ -463,46 +466,49 @@
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 @@
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 @@
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 @@
else
sc->sc_link->flags &= ~SDEV_MEDIA_LOADED;
}
+#endif
return (error);
}
Home |
Main Index |
Thread Index |
Old Index