From owner-freebsd-usb@FreeBSD.ORG Sat Nov 3 21:42:52 2012 Return-Path: Delivered-To: usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 78942763 for ; Sat, 3 Nov 2012 21:42:52 +0000 (UTC) (envelope-from marcel@xcllnt.net) Received: from mail.xcllnt.net (mail.xcllnt.net [70.36.220.4]) by mx1.freebsd.org (Postfix) with ESMTP id 4304A8FC08 for ; Sat, 3 Nov 2012 21:42:52 +0000 (UTC) Received: from marcelm-sslvpn-nc.jnpr.net (natint3.juniper.net [66.129.224.36]) (authenticated bits=0) by mail.xcllnt.net (8.14.5/8.14.5) with ESMTP id qA3LgcuT039539 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Sat, 3 Nov 2012 14:42:40 -0700 (PDT) (envelope-from marcel@xcllnt.net) From: Marcel Moolenaar Content-Type: multipart/mixed; boundary="Apple-Mail=_B5CB6594-D133-408F-BCB1-EEA46C992522" Subject: RFC: new USB quirk Date: Sat, 3 Nov 2012 14:42:33 -0700 Message-Id: <5D9BFA84-4B90-4769-BE02-F771C3AE5441@xcllnt.net> To: Hans Petter Selasky Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) X-Mailer: Apple Mail (2.1499) Cc: usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2012 21:42:52 -0000 --Apple-Mail=_B5CB6594-D133-408F-BCB1-EEA46C992522 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hans, Juniper has a few products that use STmicro USB-NAND controllers (the ST72682 in particular) and they really don't like the SCSI command for prevent/allow medium removal. The attached patch adds a quirk for this to avoid spamming the console with errors or warnings. Does it look good to you? Ok to commit? Thanks, -- Marcel Moolenaar marcel@xcllnt.net --Apple-Mail=_B5CB6594-D133-408F-BCB1-EEA46C992522 Content-Disposition: attachment; filename=usb.diff Content-Type: application/octet-stream; name="usb.diff" Content-Transfer-Encoding: 7bit Index: quirk/usb_quirk.c =================================================================== --- quirk/usb_quirk.c (revision 242525) +++ quirk/usb_quirk.c (working copy) @@ -390,6 +390,7 @@ 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, Index: quirk/usb_quirk.h =================================================================== --- quirk/usb_quirk.h (revision 242525) +++ quirk/usb_quirk.h (working copy) @@ -75,6 +75,7 @@ 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 */ Index: storage/umass.c =================================================================== --- storage/umass.c (revision 242525) +++ storage/umass.c (working copy) @@ -361,6 +361,8 @@ * 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 @@ 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 @@ 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; Index: usbdevs =================================================================== --- usbdevs (revision 242525) +++ usbdevs (working copy) @@ -3949,6 +3949,7 @@ /* 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 --Apple-Mail=_B5CB6594-D133-408F-BCB1-EEA46C992522--