Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Handle the SATA to USB external enclosure sol...



details:   https://anonhg.NetBSD.org/src/rev/5b160d077aa7
branches:  trunk
changeset: 993900:5b160d077aa7
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 07 18:14:32 2018 +0000

description:
Handle the SATA to USB external enclosure sold by "Sabrent" and
made by JMicro (vendor=0x152d product=0x0578). This bridge does
not understand FUA, so add a quirk for it.

diffstat:

 sys/dev/scsipi/scsiconf.c   |   6 ++++--
 sys/dev/scsipi/scsipiconf.h |   3 ++-
 sys/dev/scsipi/sd.c         |  19 +++++++++++--------
 3 files changed, 17 insertions(+), 11 deletions(-)

diffs (99 lines):

diff -r 19f9bfd0d240 -r 5b160d077aa7 sys/dev/scsipi/scsiconf.c
--- a/sys/dev/scsipi/scsiconf.c Sun Oct 07 18:07:00 2018 +0000
+++ b/sys/dev/scsipi/scsiconf.c Sun Oct 07 18:14:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsiconf.c,v 1.281 2018/09/01 07:20:29 mlelstv Exp $   */
+/*     $NetBSD: scsiconf.c,v 1.282 2018/10/07 18:14:32 christos Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.281 2018/09/01 07:20:29 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.282 2018/10/07 18:14:32 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -631,6 +631,8 @@
         ""        , "DFRSS2F",          ""},     PQUIRK_AUTOSAVE},
        {{T_DIRECT, T_FIXED,
         "Initio  ", "",                 ""},     PQUIRK_NOBIGMODESENSE},
+       {{T_DIRECT, T_FIXED,
+        "JMicron ", "Generic         ", ""},     PQUIRK_NOFUA},
        {{T_DIRECT, T_REMOV,
         "MPL     ", "MC-DISK-        ", ""},     PQUIRK_NOLUNS},
        {{T_DIRECT, T_FIXED,
diff -r 19f9bfd0d240 -r 5b160d077aa7 sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h       Sun Oct 07 18:07:00 2018 +0000
+++ b/sys/dev/scsipi/scsipiconf.h       Sun Oct 07 18:14:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipiconf.h,v 1.128 2018/09/01 07:20:29 mlelstv Exp $ */
+/*     $NetBSD: scsipiconf.h,v 1.129 2018/10/07 18:14:32 christos Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -478,6 +478,7 @@
 #define PQUIRK_CAP_WIDE16      0x00100000      /* SCSI device with ST wide op*/
 #define PQUIRK_CAP_NODT                0x00200000      /* signals DT, but can't. */
 #define PQUIRK_START           0x00400000      /* needs start before tur */
+#define        PQUIRK_NOFUA            0x00800000      /* does not grok FUA */
 
 
 /*
diff -r 19f9bfd0d240 -r 5b160d077aa7 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Sun Oct 07 18:07:00 2018 +0000
+++ b/sys/dev/scsipi/sd.c       Sun Oct 07 18:14:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sd.c,v 1.325 2017/06/17 22:35:50 mlelstv Exp $ */
+/*     $NetBSD: sd.c,v 1.326 2018/10/07 18:14:32 christos Exp $        */
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.325 2017/06/17 22:35:50 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.326 2018/10/07 18:14:32 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -655,6 +655,7 @@
        struct scsipi_xfer *xs;
        int error, flags, nblks, cmdlen;
        int cdb_flags;
+       bool havefua = !(periph->periph_quirks & PQUIRK_NOFUA);
 
        mutex_enter(chan_mtx(chan));
 
@@ -703,12 +704,13 @@
         * selection, as 6-byte CDB doesn't support the flags.
         */
        cdb_flags = 0;
+       if (havefua) {
+               if (bp->b_flags & B_MEDIA_FUA)
+                       cdb_flags |= SRWB_FUA;
 
-       if (bp->b_flags & B_MEDIA_FUA)
-               cdb_flags |= SRWB_FUA;
-
-       if (bp->b_flags & B_MEDIA_DPO)
-               cdb_flags |= SRWB_DPO;
+               if (bp->b_flags & B_MEDIA_DPO)
+                       cdb_flags |= SRWB_DPO;
+       }
 
        /*
         * Fill out the scsi command.  Use the smallest CDB possible
@@ -1846,7 +1848,8 @@
         * Support for FUA/DPO, defined starting with SCSI-2. Use only
         * if device claims to support it, according to the MODE SENSE.
         */
-       if (ISSET(dev_spec, SMH_DSP_DPOFUA))
+       if (!(periph->periph_quirks & PQUIRK_NOFUA) &&
+           ISSET(dev_spec, SMH_DSP_DPOFUA))
                bits |= DKCACHE_FUA | DKCACHE_DPO;
 
        memset(&scsipi_sense, 0, sizeof(scsipi_sense));



Home | Main Index | Thread Index | Old Index