summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2004-02-21 00:47:43 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2004-02-21 00:47:43 +0000
commitddb6b73bdad86651566ce262f892d0a70dfe3d51 (patch)
treeb59f9b630343cb78a67b448dbcf9e318cb5366e4
parentfa2d508abe6bee4f96fc177eb5989f868bc84193 (diff)
Eliminate the quirks SDEV_NOSTARTUNIT, UMASS_QUIRK_NO_START_STOP, and
UMASS_QUIRK_FORCE_SHORT_INQUIRY. Fixes a bunch of USB devices. Based on work by Mycroft in NetBSD. ok tdeval@ deraadt@.
-rw-r--r--sys/dev/usb/umass_quirks.c30
-rw-r--r--sys/dev/usb/umass_scsi.c22
-rw-r--r--sys/dev/usb/umassvar.h4
-rw-r--r--sys/scsi/scsi_all.h4
-rw-r--r--sys/scsi/scsi_base.c31
-rw-r--r--sys/scsi/scsiconf.c14
-rw-r--r--sys/scsi/scsiconf.h3
-rw-r--r--sys/scsi/sd.c31
8 files changed, 56 insertions, 83 deletions
diff --git a/sys/dev/usb/umass_quirks.c b/sys/dev/usb/umass_quirks.c
index b3350e69239..1c107d7dc02 100644
--- a/sys/dev/usb/umass_quirks.c
+++ b/sys/dev/usb/umass_quirks.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umass_quirks.c,v 1.9 2004/01/14 02:00:41 krw Exp $ */
+/* $OpenBSD: umass_quirks.c,v 1.10 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: umass_quirks.c,v 1.39 2003/05/08 15:19:47 augustss Exp $ */
/*
@@ -90,7 +90,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_FUJIPHOTO, USB_PRODUCT_FUJIPHOTO_MASS0100 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOTUR | PQUIRK_NOSENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -98,7 +98,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_GENESYS, USB_PRODUCT_GENESYS_GL641USB },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -154,7 +154,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_USBCABLE },
UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
- UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOTUR,
UMATCH_VENDOR_PRODUCT,
umass_init_insystem, NULL
@@ -186,7 +186,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_IOMEGA, USB_PRODUCT_IOMEGA_ZIP250_2 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOTUR,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -194,7 +194,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_DUBPXXG },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -210,7 +210,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_MINOLTA, USB_PRODUCT_MINOLTA_S304 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
+ UMASS_QUIRK_NO_MAX_LUN,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -218,7 +218,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_MINOLTA, USB_PRODUCT_MINOLTA_X },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
+ UMASS_QUIRK_NO_MAX_LUN,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -274,7 +274,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_ONSPEC, USB_PRODUCT_ONSPEC_MD1II },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
+ UMASS_QUIRK_NO_MAX_LUN,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -306,7 +306,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_PEN, USB_PRODUCT_PEN_USBDISK },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
+ UMASS_QUIRK_NO_MAX_LUN,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -346,7 +346,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_EUSB },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
- UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOTUR | PQUIRK_NOSENSE,
UMATCH_VENDOR_PRODUCT,
umass_init_shuttle, NULL
@@ -354,7 +354,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_ZIOMMC },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
- UMASS_QUIRK_NO_START_STOP,
+ 0,
PQUIRK_NOTUR,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
@@ -362,7 +362,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_SIIG, USB_PRODUCT_SIIG_MULTICARDREADER },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
- UMASS_QUIRK_NO_START_STOP,
+ 0,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL,NULL
@@ -386,7 +386,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_MSC },
UMASS_WPROTO_CBI, UMASS_CPROTO_UFI,
- UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_RS_NO_CLEAR_UA,
+ UMASS_QUIRK_RS_NO_CLEAR_UA,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
@@ -418,7 +418,7 @@ Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_YANO, USB_PRODUCT_YANO_U640MO },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
- UMASS_QUIRK_FORCE_SHORT_INQUIRY,
+ 0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
diff --git a/sys/dev/usb/umass_scsi.c b/sys/dev/usb/umass_scsi.c
index dd6d993d132..f7b3a8a6203 100644
--- a/sys/dev/usb/umass_scsi.c
+++ b/sys/dev/usb/umass_scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umass_scsi.c,v 1.6 2004/01/14 02:00:41 krw Exp $ */
+/* $OpenBSD: umass_scsi.c,v 1.7 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: umass_scsipi.c,v 1.9 2003/02/16 23:14:08 augustss Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -71,8 +71,6 @@ struct umass_scsi_softc {
};
-#define SHORT_INQUIRY_LENGTH 36 /* XXX */
-
#define UMASS_SCSIID_HOST 0x00
#define UMASS_SCSIID_DEVICE 0x01
@@ -224,24 +222,6 @@ umass_scsi_cmd(struct scsi_xfer *xs)
goto done;
}
- if (cmd->opcode == START_STOP &&
- (sc->sc_quirks & UMASS_QUIRK_NO_START_STOP)) {
- xs->error = XS_NOERROR;
- goto done;
- }
-
- if (cmd->opcode == INQUIRY &&
- (sc->sc_quirks & UMASS_QUIRK_FORCE_SHORT_INQUIRY)) {
- /*
- * Some drives wedge when asked for full inquiry
- * information.
- */
- memcpy(&trcmd, cmd, sizeof(trcmd));
- trcmd.bytes[4] = SHORT_INQUIRY_LENGTH;
- cmd = &trcmd;
- xs->datalen = SHORT_INQUIRY_LENGTH;
- }
-
dir = DIR_NONE;
if (xs->datalen) {
switch (xs->flags & (SCSI_DATA_IN | SCSI_DATA_OUT)) {
diff --git a/sys/dev/usb/umassvar.h b/sys/dev/usb/umassvar.h
index e7636bfc4f3..8c023ffdba2 100644
--- a/sys/dev/usb/umassvar.h
+++ b/sys/dev/usb/umassvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: umassvar.h,v 1.3 2003/05/17 06:07:57 nate Exp $ */
+/* $OpenBSD: umassvar.h,v 1.4 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: umassvar.h,v 1.19 2003/02/22 05:18:50 tsutsui Exp $ */
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
@@ -178,8 +178,6 @@ struct umass_softc {
u_int32_t sc_quirks;
#define UMASS_QUIRK_RS_NO_CLEAR_UA 0x00000002
-#define UMASS_QUIRK_NO_START_STOP 0x00000004
-#define UMASS_QUIRK_FORCE_SHORT_INQUIRY 0x00000008
#define UMASS_QUIRK_WRONG_CSWSIG 0x00000010
#define UMASS_QUIRK_NO_MAX_LUN 0x00000020
#define UMASS_QUIRK_WRONG_CSWTAG 0x00000040
diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h
index 23228526fc0..d45ec1dcc07 100644
--- a/sys/scsi/scsi_all.h
+++ b/sys/scsi/scsi_all.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_all.h,v 1.15 2004/01/04 03:25:30 krw Exp $ */
+/* $OpenBSD: scsi_all.h,v 1.16 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */
/*
@@ -226,6 +226,8 @@ struct scsi_inquiry_data {
#define SID_ISO 0xC0
u_int8_t response_format;
u_int8_t additional_length;
+#define SID_INQUIRY_HDR 5 /* Bytes up to & including additional_length */
+#define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */
u_int8_t unused[2];
u_int8_t flags;
#define SID_SftRe 0x01
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index f1608f9d4a6..5e8a6a8adaa 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.53 2004/02/21 00:34:27 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.54 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -298,10 +298,10 @@ scsi_inquire(sc_link, inqbuf, flags)
int flags;
{
struct scsi_inquiry scsi_cmd;
+ int error;
bzero(&scsi_cmd, sizeof scsi_cmd);
scsi_cmd.opcode = INQUIRY;
- scsi_cmd.length = sizeof *inqbuf;
bzero(inqbuf, sizeof *inqbuf);
@@ -310,10 +310,28 @@ scsi_inquire(sc_link, inqbuf, flags)
memset(&inqbuf->revision, ' ', sizeof inqbuf->revision);
memset(&inqbuf->extra, ' ', sizeof inqbuf->extra);
- return scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), (u_char *) inqbuf,
- sizeof(struct scsi_inquiry_data), 2, 10000, NULL,
+ /*
+ * First try for the basic 36 bytes of SCSI2 inquiry information. This
+ * avoids problems with devices that choke trying to supply more.
+ */
+ scsi_cmd.length = SID_INQUIRY_HDR + SID_SCSI2_ALEN;
+ error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd,
+ sizeof(scsi_cmd), (u_char *)inqbuf, scsi_cmd.length, 2, 10000, NULL,
SCSI_DATA_IN | flags);
+
+ /*
+ * If the device can supply more information, ask for as much
+ * as we can handle or as much as it has, whichever is less.
+ */
+ if (!error && inqbuf->additional_length > SID_SCSI2_ALEN) {
+ scsi_cmd.length = min(sizeof(struct scsi_inquiry_data),
+ SID_INQUIRY_HDR + inqbuf->additional_length);
+ error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd,
+ sizeof(scsi_cmd), (u_char *)inqbuf, scsi_cmd.length, 2,
+ 10000, NULL, SCSI_DATA_IN | flags);
+ }
+
+ return (error);
}
/*
@@ -346,9 +364,6 @@ scsi_start(sc_link, type, flags)
{
struct scsi_start_stop scsi_cmd;
- if ((sc_link->quirks & SDEV_NOSTARTUNIT) == SDEV_NOSTARTUNIT)
- return 0;
-
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = START_STOP;
scsi_cmd.byte2 = 0x00;
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c
index 6f24b13e5cf..e89b04ea0dd 100644
--- a/sys/scsi/scsiconf.c
+++ b/sys/scsi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.c,v 1.85 2004/02/07 22:39:16 krw Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.86 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */
/*
@@ -406,11 +406,6 @@ const struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
"DEC ", "RZ55 (C) DEC", ""}, SDEV_AUTOSAVE},
{{T_DIRECT, T_FIXED,
"EMULEX ", "MD21/S2 ESDI", "A00"}, SDEV_AUTOSAVE},
- /* Gives non-media hardware failure in response to start-unit command */
- {{T_DIRECT, T_FIXED,
- "HITACHI", "DK515C", "CP15"}, SDEV_NOSTARTUNIT},
- {{T_DIRECT, T_FIXED,
- "HITACHI", "DK515C", "CP16"}, SDEV_NOSTARTUNIT},
{{T_DIRECT, T_FIXED,
"IBMRAID ", "0662S", ""}, SDEV_AUTOSAVE},
{{T_DIRECT, T_FIXED,
@@ -438,9 +433,6 @@ const struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
"IOMEGA", "ZIP 250", ""}, SDEV_NOMODESENSE},
{{T_DIRECT, T_FIXED,
"IBM", "0661467", "G"}, SDEV_NOMODESENSE},
- /* Letting the motor run kills floppy drives and disks quit fast. */
- {{T_DIRECT, T_REMOV,
- "TEAC", "FC-1", ""}, SDEV_NOSTARTUNIT},
{{T_DIRECT, T_FIXED,
"MICROP", "4421-07", ""}, SDEV_NOTAGS},
{{T_DIRECT, T_FIXED,
@@ -463,10 +455,6 @@ const struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
{{T_CDROM, T_REMOV,
"ALPS ELECTRIC CO.,LTD. DC544C", "", "SW03D"}, ADEV_NOTUR},
{{T_CDROM, T_REMOV,
- "BCD-16X", "", ""}, SDEV_NOSTARTUNIT},
- {{T_CDROM, T_REMOV,
- "BCD-24X", "", ""}, SDEV_NOSTARTUNIT},
- {{T_CDROM, T_REMOV,
"CR-2801TE", "", "1.07"}, ADEV_NOSENSE},
{{T_CDROM, T_REMOV,
"CREATIVECD3630E", "", "AC101"}, ADEV_NOSENSE},
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index db545035d8d..2d92c93ff94 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.40 2004/01/14 02:00:41 krw Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.41 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -176,7 +176,6 @@ struct scsi_link {
#define SDEV_NOWIDE 0x0004 /* does not grok WDTR */
#define SDEV_NOTAGS 0x0008 /* lies about having tagged queueing */
#define SDEV_NOMODESENSE 0x0040 /* removable media/optical drives */
-#define SDEV_NOSTARTUNIT 0x0080 /* do not issue start unit requests in sd.c */
#define SDEV_NOSYNCCACHE 0x0100 /* no SYNCHRONIZE_CACHE */
#define ADEV_NOSENSE 0x0200 /* No request sense - ATAPI */
#define ADEV_LITTLETOC 0x0400 /* little-endian TOC - ATAPI */
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index a1ad171164e..57e666b81bb 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.66 2004/02/15 02:45:47 tedu Exp $ */
+/* $OpenBSD: sd.c,v 1.67 2004/02/21 00:47:42 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -218,12 +218,9 @@ sdattach(parent, self, aux)
*/
printf("\n");
- if ((sd->sc_link->quirks & SDEV_NOSTARTUNIT) == 0) {
- error = scsi_start(sd->sc_link, SSS_START,
- scsi_autoconf | SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
- } else
- error = 0;
+ error = scsi_test_unit_ready(sd->sc_link, TEST_READY_RETRIES_DEFAULT,
+ scsi_autoconf | SCSI_IGNORE_ILLEGAL_REQUEST |
+ SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
/* Fill in name struct for spoofed label */
viscpy(sd->name.vendor, sa->sa_inqbuf->vendor, 8);
@@ -392,19 +389,14 @@ sdopen(dev, flag, fmt, p)
error = scsi_test_unit_ready(sc_link,
TEST_READY_RETRIES_DEFAULT,
SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE |
- SCSI_IGNORE_NOT_READY);
- if (error)
- goto bad3;
+ SCSI_IGNORE_MEDIA_CHANGE);
/* Start the pack spinning if necessary. */
- if ((sc_link->quirks & SDEV_NOSTARTUNIT) == 0) {
- error = scsi_start(sc_link, SSS_START,
- SCSI_IGNORE_ILLEGAL_REQUEST |
- SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
- if (error)
- goto bad3;
- }
+ if (error == EIO)
+ error = scsi_start(sc_link, SSS_START, 0);
+
+ if (error)
+ goto bad3;
sc_link->flags |= SDEV_OPEN;
@@ -1136,8 +1128,7 @@ sd_interpret_sense(xs)
*/
delay(1000000 * 5); /* 5 seconds */
retval = SCSIRET_RETRY;
- } else if ((sense->add_sense_code_qual == 0x2) &&
- (sd->sc_link->quirks & SDEV_NOSTARTUNIT) == 0) {
+ } else if (sense->add_sense_code_qual == 0x2) {
if (sd->sc_link->flags & SDEV_REMOVABLE) {
printf(
"%s: removable disk stopped - not restarting\n",