summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/scsi/sd.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index d44a7e985a6..fc928eb261e 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.105 2006/05/11 00:45:59 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.106 2006/05/18 00:10:05 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -209,14 +209,15 @@ sdattach(parent, self, aux)
*/
printf("\n");
+ /* Spin up the unit ready or not. */
+ scsi_start(sc_link, SSS_START, scsi_autoconf | SCSI_SILENT |
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE);
+
+ /* Check that it is still responding and ok. */
error = scsi_test_unit_ready(sd->sc_link, TEST_READY_RETRIES_DEFAULT,
scsi_autoconf | SCSI_IGNORE_ILLEGAL_REQUEST |
SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
- /* Spin up the unit ready or not. */
- error = scsi_start(sc_link, SSS_START, scsi_autoconf | SCSI_SILENT |
- SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE);
-
if (error)
result = SDGP_RESULT_OFFLINE;
else
@@ -362,7 +363,16 @@ sdopen(dev, flag, fmt, p)
goto bad;
}
} else {
- /* Use sd_interpret_sense() for sense errors. */
+ /* Spin up the unit, ready or not. */
+ scsi_start(sc_link, SSS_START, (rawopen ? SCSI_SILENT : 0) |
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE);
+
+ /* Use sd_interpret_sense() for sense errors.
+ *
+ * But only after spinning the disk up! Just in case a broken
+ * device returns "Initialization command required." and causes
+ * a loop of scsi_start() calls.
+ */
sc_link->flags |= SDEV_OPEN;
/* Check that it is still responding and ok. */
@@ -370,11 +380,6 @@ sdopen(dev, flag, fmt, p)
TEST_READY_RETRIES_DEFAULT, (rawopen ? SCSI_SILENT : 0) |
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE);
- /* Spin up the unit, ready or not. */
- error = scsi_start(sc_link, SSS_START,
- (rawopen ? SCSI_SILENT : 0) | SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE);
-
if (error) {
if (rawopen) {
error = 0;