Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Nov 2012 21:03:38 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r242628 - in head/sys/dev/usb: . quirk storage
Message-ID:  <201211052103.qA5L3cEg084813@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Mon Nov  5 21:03:38 2012
New Revision: 242628
URL: http://svnweb.freebsd.org/changeset/base/242628

Log:
  Add the UQ_MSC_NO_PREVENT_ALLOW quirk to handle devices that do not support
  the 'PREVENT/ALLOW MEDIUM REMOVAL' SCSI command. An example of such a
  device is the STmicro ST72682. We send the SCSI command for every open and
  close, which can result in a significant amount of spam on the console
  during boot.
  
  Reviewed by:	hps@

Modified:
  head/sys/dev/usb/quirk/usb_quirk.c
  head/sys/dev/usb/quirk/usb_quirk.h
  head/sys/dev/usb/storage/umass.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/quirk/usb_quirk.c
==============================================================================
--- head/sys/dev/usb/quirk/usb_quirk.c	Mon Nov  5 20:55:17 2012	(r242627)
+++ head/sys/dev/usb/quirk/usb_quirk.c	Mon Nov  5 21:03:38 2012	(r242628)
@@ -390,6 +390,7 @@ static struct usb_quirk_entry usb_quirks
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN),
 	USB_QUIRK(SONY, PORTABLE_HDD_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI),
+	USB_QUIRK(STMICRO, ST72682, 0x0000, 0xffff, UQ_MSC_NO_PREVENT_ALLOW),
 	USB_QUIRK(SUPERTOP, IDE, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE,
 	    UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(SUPERTOP, FLASHDRIVE, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY,
@@ -523,6 +524,7 @@ static const char *usb_quirk_str[USB_QUI
 	[UQ_MSC_NO_GETMAXLUN]		= "UQ_MSC_NO_GETMAXLUN",
 	[UQ_MSC_NO_INQUIRY]		= "UQ_MSC_NO_INQUIRY",
 	[UQ_MSC_NO_INQUIRY_EVPD]	= "UQ_MSC_NO_INQUIRY_EVPD",
+	[UQ_MSC_NO_PREVENT_ALLOW]	= "UQ_MSC_NO_PREVENT_ALLOW",
 	[UQ_MSC_NO_SYNC_CACHE]		= "UQ_MSC_NO_SYNC_CACHE",
 	[UQ_MSC_SHUTTLE_INIT]		= "UQ_MSC_SHUTTLE_INIT",
 	[UQ_MSC_ALT_IFACE_1]		= "UQ_MSC_ALT_IFACE_1",

Modified: head/sys/dev/usb/quirk/usb_quirk.h
==============================================================================
--- head/sys/dev/usb/quirk/usb_quirk.h	Mon Nov  5 20:55:17 2012	(r242627)
+++ head/sys/dev/usb/quirk/usb_quirk.h	Mon Nov  5 21:03:38 2012	(r242628)
@@ -75,6 +75,7 @@ enum {
 	UQ_MSC_NO_GETMAXLUN,		/* does not support get max LUN */
 	UQ_MSC_NO_INQUIRY,		/* fake generic inq response */
 	UQ_MSC_NO_INQUIRY_EVPD,		/* does not support inq EVPD */
+	UQ_MSC_NO_PREVENT_ALLOW,	/* does not support medium removal */ 
 	UQ_MSC_NO_SYNC_CACHE,		/* does not support sync cache */ 
 	UQ_MSC_SHUTTLE_INIT,		/* requires Shuttle init sequence */
 	UQ_MSC_ALT_IFACE_1,		/* switch to alternate interface 1 */

Modified: head/sys/dev/usb/storage/umass.c
==============================================================================
--- head/sys/dev/usb/storage/umass.c	Mon Nov  5 20:55:17 2012	(r242627)
+++ head/sys/dev/usb/storage/umass.c	Mon Nov  5 21:03:38 2012	(r242628)
@@ -361,6 +361,8 @@ typedef uint8_t (umass_transform_t)(stru
 	 * result.
 	 */
 #define	NO_SYNCHRONIZE_CACHE	0x4000
+	/* Device does not support 'PREVENT/ALLOW MEDIUM REMOVAL'. */
+#define	NO_PREVENT_ALLOW	0x8000
 
 struct umass_softc {
 
@@ -831,6 +833,8 @@ umass_probe_proto(device_t dev, struct u
 		quirks |= NO_INQUIRY;
 	if (usb_test_quirk(uaa, UQ_MSC_NO_INQUIRY_EVPD))
 		quirks |= NO_INQUIRY_EVPD;
+	if (usb_test_quirk(uaa, UQ_MSC_NO_PREVENT_ALLOW))
+		quirks |= NO_PREVENT_ALLOW;
 	if (usb_test_quirk(uaa, UQ_MSC_NO_SYNC_CACHE))
 		quirks |= NO_SYNCHRONIZE_CACHE;
 	if (usb_test_quirk(uaa, UQ_MSC_SHUTTLE_INIT))
@@ -2245,6 +2249,13 @@ umass_cam_action(struct cam_sim *sim, un
 					if (sc->sc_quirks & FORCE_SHORT_INQUIRY) {
 						ccb->csio.dxfer_len = SHORT_INQUIRY_LENGTH;
 					}
+				} else if (sc->sc_transfer.cmd_data[0] == PREVENT_ALLOW) {
+					if (sc->sc_quirks & NO_PREVENT_ALLOW) {
+						ccb->csio.scsi_status = SCSI_STATUS_OK;
+						ccb->ccb_h.status = CAM_REQ_CMP;
+						xpt_done(ccb);
+						goto done;
+					}
 				} else if (sc->sc_transfer.cmd_data[0] == SYNCHRONIZE_CACHE) {
 					if (sc->sc_quirks & NO_SYNCHRONIZE_CACHE) {
 						ccb->csio.scsi_status = SCSI_STATUS_OK;

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Mon Nov  5 20:55:17 2012	(r242627)
+++ head/sys/dev/usb/usbdevs	Mon Nov  5 21:03:38 2012	(r242628)
@@ -3949,6 +3949,7 @@ product STELERA E1012		0x1012	3G modem
 /* STMicroelectronics products */
 product STMICRO BIOCPU		0x2016	Biometric Coprocessor
 product STMICRO COMMUNICATOR	0x7554	USB Communicator
+product STMICRO ST72682		0xfada  USB 2.0 Flash drive controller
 
 /* STSN products */
 product STSN STSN0001		0x0001	Internet Access Device



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211052103.qA5L3cEg084813>