Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Do a START UNIT only if the TEST UNIT READY r...



details:   https://anonhg.NetBSD.org/src/rev/6a6f31867ce2
branches:  trunk
changeset: 551600:6a6f31867ce2
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Mon Sep 08 18:51:33 2003 +0000

description:
Do a START UNIT only if the TEST UNIT READY reports that the device is not
ready.  This avoids gratuitously starting the motor on floppy and CD-ROM
drives, and eliminates the need for the audio playing test in cdopen().

Therefore, also remove PQUIRK_NOSTARTUNIT.

diffstat:

 sys/dev/scsipi/atapiconf.c   |   8 +----
 sys/dev/scsipi/cd.c          |  61 ++++++++++++++++++++-----------------------
 sys/dev/scsipi/scsiconf.c    |  20 ++++----------
 sys/dev/scsipi/scsipi_base.c |   7 +---
 sys/dev/scsipi/scsipiconf.h  |   3 +-
 sys/dev/scsipi/sd.c          |  46 ++++++++++++++++++++------------
 6 files changed, 68 insertions(+), 77 deletions(-)

diffs (truncated from 328 to 300 lines):

diff -r d46d137961cb -r 6a6f31867ce2 sys/dev/scsipi/atapiconf.c
--- a/sys/dev/scsipi/atapiconf.c        Mon Sep 08 18:07:30 2003 +0000
+++ b/sys/dev/scsipi/atapiconf.c        Mon Sep 08 18:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atapiconf.c,v 1.57 2003/04/03 17:41:51 erh Exp $       */
+/*     $NetBSD: atapiconf.c,v 1.58 2003/09/08 18:51:33 mycroft Exp $   */
 
 /*
  * Copyright (c) 1996, 2001 Manuel Bouyer.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.57 2003/04/03 17:41:51 erh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.58 2003/09/08 18:51:33 mycroft Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,10 +76,6 @@
        {{T_CDROM, T_REMOV,
         "ALPS ELECTRIC CO.,LTD. DC544C", "", "SW03D"}, PQUIRK_NOTUR},
        {{T_CDROM, T_REMOV,
-        "BCD-16X 1997-04-25", "", "VER 2.2"},  PQUIRK_NOSTARTUNIT},
-       {{T_CDROM, T_REMOV,
-        "BCD-24X 1997-06-27", "", "VER 2.0"},  PQUIRK_NOSTARTUNIT},
-       {{T_CDROM, T_REMOV,
         "CR-2801TE", "", "1.07"},              PQUIRK_NOSENSE},
        {{T_CDROM, T_REMOV,
         "CREATIVECD3630E", "", "AC101"},       PQUIRK_NOSENSE},
diff -r d46d137961cb -r 6a6f31867ce2 sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Mon Sep 08 18:07:30 2003 +0000
+++ b/sys/dev/scsipi/cd.c       Mon Sep 08 18:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.191 2003/09/08 16:16:43 mycroft Exp $ */
+/*     $NetBSD: cd.c,v 1.192 2003/09/08 18:51:34 mycroft Exp $ */
 
 /*-
  * Copyright (c) 1998, 2001, 2003 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.191 2003/09/08 16:16:43 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.192 2003/09/08 18:51:34 mycroft Exp $");
 
 #include "rnd.h"
 
@@ -391,7 +391,6 @@
        struct cd_softc *cd;
        struct scsipi_periph *periph;
        struct scsipi_adapter *adapt;
-       struct cd_sub_channel_info data;
        int unit, part;
        int error;
 
@@ -436,40 +435,36 @@
                error = scsipi_test_unit_ready(periph,
                    XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_MEDIA_CHANGE |
                    XS_CTL_SILENT_NODEV);
-               SC_DEBUG(periph, SCSIPI_DB1,
-                   ("cdopen: scsipi_test_unit_ready, error=%d\n", error));
-               if (error) {
-                       if (part != RAW_PART || fmt != S_IFCHR)
-                               goto bad3;
-                       else
-                               goto out;
-               }
+
+               /*
+                * Start the pack spinning if necessary. Always allow the
+                * raw parition to be opened, for raw IOCTLs. Data transfers
+                * will check for SDEV_MEDIA_LOADED.
+                */
+               if (error == ENODEV) {
+                       int silent, error2;
 
-               /* Don't try to start the unit if audio is playing. */
-               error = cd_read_subchannel(cd, CD_LBA_FORMAT,
-                   CD_CURRENT_POSITION, 0, &data, sizeof(data),
-                   XS_CTL_DATA_ONSTACK);
-               if ((data.header.audio_status != CD_AS_PLAY_IN_PROGRESS &&
-                   data.header.audio_status != CD_AS_PLAY_PAUSED) || error) {
-                       /*
-                        * Start the pack spinning if necessary. Always
-                        * allow the raw parition to be opened, for raw
-                        * IOCTLs. Data transfers will check for
-                        * SDEV_MEDIA_LOADED.
-                        */
-                       error = scsipi_start(periph, SSS_START,
-                           XS_CTL_IGNORE_ILLEGAL_REQUEST |
-                           XS_CTL_IGNORE_MEDIA_CHANGE |
-                           XS_CTL_SILENT);
-                       SC_DEBUG(periph, SCSIPI_DB1,
-                           ("cdopen: scsipi_start, error=%d\n", error));
-                       if (error) {
-                               if (part != RAW_PART || fmt != S_IFCHR) 
-                                       goto bad3;
-                               else
+                       if (part == RAW_PART && fmt == S_IFCHR)
+                               silent = XS_CTL_SILENT;
+                       else
+                               silent = 0;
+                       error2 = scsipi_start(periph, SSS_START, silent);
+                       switch (error2) {
+                       case 0:
+                               error = 0;
+                               break;
+                       case ENODEV:
+                       case EINVAL:
+                               if (silent)
                                        goto out;
+                               break;
+                       default:
+                               error = error2;
+                               break;
                        }
                }
+               if (error)
+                       goto bad3;
 
                periph->periph_flags |= PERIPH_OPEN;
 
diff -r d46d137961cb -r 6a6f31867ce2 sys/dev/scsipi/scsiconf.c
--- a/sys/dev/scsipi/scsiconf.c Mon Sep 08 18:07:30 2003 +0000
+++ b/sys/dev/scsipi/scsiconf.c Mon Sep 08 18:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsiconf.c,v 1.208 2003/08/07 17:54:26 jrf Exp $       */
+/*     $NetBSD: scsiconf.c,v 1.209 2003/09/08 18:51:35 mycroft Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.208 2003/08/07 17:54:26 jrf Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.209 2003/09/08 18:51:35 mycroft Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -503,8 +503,7 @@
        {{T_CDROM, T_REMOV,
         "YAMAHA", "CRW8424S",           ""},     PQUIRK_NOLUNS},
        {{T_CDROM, T_REMOV,
-        "VMware", "Virtual",            "1.0"},
-                               PQUIRK_NOSTARTUNIT|PQUIRK_NODOORLOCK},
+        "VMware", "Virtual",            "1.0"},  PQUIRK_NODOORLOCK},
        {{T_CDROM, T_REMOV,
         "NEC     ", "CD-ROM DRIVE:222", ""},     PQUIRK_NOLUNS|PQUIRK_NOSYNC},
 
@@ -527,11 +526,6 @@
        {{T_DIRECT, T_FIXED,
         "EMULEX  ", "MD21/S2     ESDI", "A00"},
                                PQUIRK_FORCELUNS|PQUIRK_AUTOSAVE},
-       /* Gives non-media hardware failure in response to start-unit command */
-       {{T_DIRECT, T_FIXED,
-        "HITACHI", "DK515C",            "CP16"}, PQUIRK_NOSTARTUNIT},
-       {{T_DIRECT, T_FIXED,
-        "HITACHI", "DK515C",            "CP15"}, PQUIRK_NOSTARTUNIT},
        {{T_DIRECT, T_FIXED,
        /* improperly report DT-only sync mode */
         "HITACHI", "DX32DJ-72ME",       ""},
@@ -622,8 +616,7 @@
        {{T_DIRECT, T_FIXED,
         "TOSHIBA ", "MK538FB         ", "6027"}, PQUIRK_NOLUNS},
        {{T_DIRECT, T_FIXED,
-        "VMware", "Virtual",           "1.0"},
-                               PQUIRK_NOSTARTUNIT|PQUIRK_NODOORLOCK},
+        "VMware", "Virtual",           "1.0"},   PQUIRK_NODOORLOCK},
        {{T_DIRECT, T_FIXED,    /* XXX move to umass */
         "Maxtor 4", "D080H4",           "DAH0"}, PQUIRK_NOMODESENSE},
        {{T_DIRECT, T_FIXED,    /* XXX move to umass */
@@ -640,9 +633,6 @@
        {{T_DIRECT, T_REMOV,
         "IOMEGA", "ZIP 100",            "J.03"},
                                PQUIRK_NOMODESENSE|PQUIRK_NOLUNS},
-       /* Letting the motor run kills floppy drives and disks quite fast. */
-       {{T_DIRECT, T_REMOV,
-        "TEAC", "FC-1",                 ""},     PQUIRK_NOSTARTUNIT},
        {{T_DIRECT, T_REMOV,
         "INSITE", "I325VM",             ""},
                                PQUIRK_NOLUNS|PQUIRK_NODOORLOCK},
@@ -709,6 +699,8 @@
         "SONY    ", "CDL1100         ", ""},     PQUIRK_NOLUNS},
        {{T_ENCLOSURE, T_FIXED,
         "SUN     ", "SENA            ", ""},     PQUIRK_NOLUNS},
+       {{T_DIRECT, T_REMOV,
+        "Generic ", "USB Storage-SMC ", ""},     PQUIRK_FORCELUNS},
 };
 
 /*
diff -r d46d137961cb -r 6a6f31867ce2 sys/dev/scsipi/scsipi_base.c
--- a/sys/dev/scsipi/scsipi_base.c      Mon Sep 08 18:07:30 2003 +0000
+++ b/sys/dev/scsipi/scsipi_base.c      Mon Sep 08 18:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipi_base.c,v 1.91 2003/09/08 03:50:27 mycroft Exp $ */
+/*     $NetBSD: scsipi_base.c,v 1.92 2003/09/08 18:51:36 mycroft Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.91 2003/09/08 03:50:27 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.92 2003/09/08 18:51:36 mycroft Exp $");
 
 #include "opt_scsi.h"
 
@@ -1172,9 +1172,6 @@
 {
        struct scsipi_start_stop scsipi_cmd;
 
-       if (periph->periph_quirks & PQUIRK_NOSTARTUNIT)
-               return 0;
-
        memset(&scsipi_cmd, 0, sizeof(scsipi_cmd));
        scsipi_cmd.opcode = START_STOP;
        scsipi_cmd.byte2 = 0x00;
diff -r d46d137961cb -r 6a6f31867ce2 sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h       Mon Sep 08 18:07:30 2003 +0000
+++ b/sys/dev/scsipi/scsipiconf.h       Mon Sep 08 18:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipiconf.h,v 1.76 2003/06/29 22:30:41 fvdl Exp $     */
+/*     $NetBSD: scsipiconf.h,v 1.77 2003/09/08 18:51:37 mycroft Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -444,7 +444,6 @@
                                                   LUNs */
 #define        PQUIRK_NOMODESENSE      0x00000040      /* device doesn't do MODE SENSE
                                                   properly */
-#define        PQUIRK_NOSTARTUNIT      0x00000080      /* do not issue START UNIT */
 #define        PQUIRK_NOSYNCCACHE      0x00000100      /* do not issue SYNC CACHE */
 #define        PQUIRK_CDROM            0x00000200      /* device is a CD-ROM, no
                                                   matter what else it claims */
diff -r d46d137961cb -r 6a6f31867ce2 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Mon Sep 08 18:07:30 2003 +0000
+++ b/sys/dev/scsipi/sd.c       Mon Sep 08 18:51:33 2003 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: sd.c,v 1.203 2003/09/07 22:11:24 mycroft Exp $ */
+/*     $NetBSD: sd.c,v 1.204 2003/09/08 18:51:38 mycroft Exp $ */
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.203 2003/09/07 22:11:24 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.204 2003/09/08 18:51:38 mycroft Exp $");
 
 #include "opt_scsi.h"
 #include "opt_bufq.h"
@@ -190,9 +190,9 @@
        aprint_naive("\n");
        aprint_normal("\n");
 
-       error = scsipi_start(periph, SSS_START,
+       error = scsipi_test_unit_ready(periph,
            XS_CTL_DISCOVERY | XS_CTL_IGNORE_ILLEGAL_REQUEST |
-           XS_CTL_IGNORE_MEDIA_CHANGE | XS_CTL_SILENT);
+           XS_CTL_IGNORE_MEDIA_CHANGE | XS_CTL_SILENT_NODEV);
 
        if (error)
                result = SDGP_RESULT_OFFLINE;
@@ -414,24 +414,37 @@
                /* Check that it is still responding and ok. */
                error = scsipi_test_unit_ready(periph,
                    XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_MEDIA_CHANGE |
-                   XS_CTL_IGNORE_NOT_READY);
-               if (error)
-                       goto bad3;
+                   XS_CTL_SILENT_NODEV);
 
                /*
                 * Start the pack spinning if necessary. Always allow the
                 * raw parition to be opened, for raw IOCTLs. Data transfers
                 * will check for SDEV_MEDIA_LOADED.
                 */
-               error = scsipi_start(periph, SSS_START,
-                   XS_CTL_IGNORE_ILLEGAL_REQUEST |
-                   XS_CTL_IGNORE_MEDIA_CHANGE | XS_CTL_SILENT);
-               if (error) {
-                       if (part != RAW_PART || fmt != S_IFCHR)
-                               goto bad3;
+               if (error == ENODEV) {
+                       int silent, error2;
+
+                       if (part == RAW_PART && fmt == S_IFCHR)
+                               silent = XS_CTL_SILENT;
                        else
-                               goto out;
+                               silent = 0;
+                       error2 = scsipi_start(periph, SSS_START, silent);
+                       switch (error2) {



Home | Main Index | Thread Index | Old Index