Module Name: src
Committed By: christos
Date: Sun Oct 7 18:14:32 UTC 2018
Modified Files:
src/sys/dev/scsipi: scsiconf.c scsipiconf.h sd.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.281 -r1.282 src/sys/dev/scsipi/scsiconf.c
cvs rdiff -u -r1.128 -r1.129 src/sys/dev/scsipi/scsipiconf.h
cvs rdiff -u -r1.325 -r1.326 src/sys/dev/scsipi/sd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.281 src/sys/dev/scsipi/scsiconf.c:1.282
--- src/sys/dev/scsipi/scsiconf.c:1.281 Sat Sep 1 03:20:29 2018
+++ src/sys/dev/scsipi/scsiconf.c Sun Oct 7 14:14:32 2018
@@ -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 @@ static const struct scsi_quirk_inquiry_p
"" , "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,
Index: src/sys/dev/scsipi/scsipiconf.h
diff -u src/sys/dev/scsipi/scsipiconf.h:1.128 src/sys/dev/scsipi/scsipiconf.h:1.129
--- src/sys/dev/scsipi/scsipiconf.h:1.128 Sat Sep 1 03:20:29 2018
+++ src/sys/dev/scsipi/scsipiconf.h Sun Oct 7 14:14:32 2018
@@ -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 @@ struct scsipi_periph {
#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 */
/*
Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.325 src/sys/dev/scsipi/sd.c:1.326
--- src/sys/dev/scsipi/sd.c:1.325 Sat Jun 17 18:35:50 2017
+++ src/sys/dev/scsipi/sd.c Sun Oct 7 14:14:32 2018
@@ -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 @@ sd_diskstart(device_t dev, struct buf *b
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 @@ sd_diskstart(device_t dev, struct buf *b
* 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 @@ sd_getcache(struct sd_softc *sd, int *bi
* 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));