Date: Sun, 4 Nov 2012 12:07:31 -0800 From: Marcel Moolenaar <marcel@xcllnt.net> To: Hans Petter Selasky <hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: RFC: new USB quirk Message-ID: <1DCEF6B8-5917-49F0-90AE-072835A8E595@xcllnt.net> In-Reply-To: <201211041147.11076.hselasky@c2i.net> References: <5D9BFA84-4B90-4769-BE02-F771C3AE5441@xcllnt.net> <201211041147.11076.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_59387DA8-901B-40FC-9105-7D0F3BC6C8FB Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On Nov 4, 2012, at 2:47 AM, Hans Petter Selasky <hselasky@c2i.net> wrote: > On Saturday 03 November 2012 22:42:33 Marcel Moolenaar wrote: >> 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, > > Hi, > > You also need to update this table in usb_quirk.c: > > static const char *usb_quirk_str[USB_QUIRK_MAX] = { > [UQ_NONE] = "UQ_NONE", > > Can you do that and send a new patch for review? See attached. FYI, -- Marcel Moolenaar marcel@xcllnt.net --Apple-Mail=_59387DA8-901B-40FC-9105-7D0F3BC6C8FB Content-Disposition: attachment; filename=usb.diff Content-Type: application/octet-stream; name="usb.diff" Content-Transfer-Encoding: 7bit Index: sys/dev/usb/quirk/usb_quirk.c =================================================================== --- sys/dev/usb/quirk/usb_quirk.c (revision 242577) +++ sys/dev/usb/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, @@ -523,6 +524,7 @@ [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", Index: sys/dev/usb/quirk/usb_quirk.h =================================================================== --- sys/dev/usb/quirk/usb_quirk.h (revision 242577) +++ sys/dev/usb/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: sys/dev/usb/storage/umass.c =================================================================== --- sys/dev/usb/storage/umass.c (revision 242577) +++ sys/dev/usb/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: sys/dev/usb/usbdevs =================================================================== --- sys/dev/usb/usbdevs (revision 242577) +++ sys/dev/usb/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=_59387DA8-901B-40FC-9105-7D0F3BC6C8FB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1DCEF6B8-5917-49F0-90AE-072835A8E595>