Bug 222659 - Add quirk UQ_MSC_NO_PREVENT_ALLOW to SMI USB DISK 3000
Summary: Add quirk UQ_MSC_NO_PREVENT_ALLOW to SMI USB DISK 3000
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-usb mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-09-28 07:48 UTC by Ricardo Fraile
Modified: 2017-10-12 08:43 UTC (History)
6 users (show)

See Also:


Attachments
Patch file for SMI USB Flash Drive (1.55 KB, patch)
2017-10-02 06:48 UTC, Ricardo Fraile
no flags Details | Diff
Patch file for SMI USB Flash Drive scsi_da.c (530 bytes, patch)
2017-10-12 08:30 UTC, Ricardo Fraile
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo Fraile 2017-09-28 07:48:54 UTC
Plugin the following usb storage device (usbconfig report):

ugen0.2: <USB DISK SMI Corporation> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0200 
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x090c 
  idProduct = 0x1000 
  bcdDevice = 0x3000 
  iManufacturer = 0x0001  <SMI Corporation>
  iProduct = 0x0002  <USB DISK>
  iSerialNumber = 0x0003  <2010121200000149>
  bNumConfigurations = 0x0001 


Produces the following errors:

(da0:umass-sim0:0:0:0): Retrying command
(da0:umass-sim0:0:0:0): READ(10). CDB: 28 00 00 ee ff fe 00 00 01 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Retrying command
(da0:umass-sim0:0:0:0): READ(10). CDB: 28 00 00 ee ff fe 00 00 01 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Error 5, Retries exhausted


Which makes it impossible to mount and use it.
After adding the following lines to the loader.conf file, the problem was fixed:

usb_quirk_load="YES"
hw.usb.quirk.0="0x090c 0x1000 0 0xffff UQ_MSC_NO_PREVENT_ALLOW"


And the dmesg log don't have any issue registered:

uhub0: 2 ports with 2 removable, self powered
ugen0.2: <SMI Corporation> at usbus0
umass0: <SMI Corporation USB DISK, class 0/0, rev 2.00/30.00, addr 2> on usbus0
umass0:  SCSI over Bulk-Only; quirks = 0xc000
umass0:2:0: Attached to scbus2
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <SMI USB DISK 3000> Removable Direct Access SCSI device
da0: Serial Number 2010121200000149
da0: 1.000MB/s transfers
da0: 7648MB (15663104 512 byte sectors)
da0: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>


Thanks,
Comment 1 Hans Petter Selasky freebsd_committer 2017-09-28 07:53:00 UTC
Hi,

Please make a patch for:

sys/dev/usb/quirk/usb_quirk.c and
sys/dev/usb/usbdevs

--HPS
Comment 2 Robert Welain 2017-09-28 14:06:16 UTC
MARKED AS SPAM
Comment 3 Ricardo Fraile 2017-10-02 06:48:57 UTC
Created attachment 186852 [details]
Patch file for SMI USB Flash Drive

Hi,

Here is the patch. I tested it and works without issue.

Thanks,
Comment 4 Hans Petter Selasky freebsd_committer 2017-10-05 07:59:27 UTC
Patch looks good to me. Approved.

--HPS
Comment 5 Hans Petter Selasky freebsd_committer 2017-10-05 08:04:17 UTC
Can you try adding UQ_MSC_NO_SYNC_CACHE to the list of quirks? I see it is already listed.

--HPS
Comment 6 Ricardo Fraile 2017-10-05 09:13:30 UTC
Hi Hans,

Sorry but where is the list of quirks? The usb_quirk.c already have UQ_MSC_NO_SYNC_CACHE:

+       USB_QUIRK(FEIYA, USB_DISK, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE,
+           UQ_MSC_NO_PREVENT_ALLOW),

Thanks,
Comment 7 Hans Petter Selasky freebsd_committer 2017-10-05 09:20:19 UTC
Hi,

If you look at this line you see your device already has some quirks. Try looking in sys/cam/* for those:

da0: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>

Yes, try adding the NO_SYNCHRONIZE_CACHE quirk aswell at USB level.

--HPS
Comment 8 Ricardo Fraile 2017-10-12 08:30:02 UTC
Created attachment 187093 [details]
Patch file for SMI USB Flash Drive scsi_da.c

Hi,

Here is the patch.

The device is not listed, but is catched by the following lines:

	/*
	 * PNY USB Flash keys
	 * PR: usb/75578, usb/72344, usb/65436 
	 */
	{T_DIRECT, SIP_MEDIA_REMOVABLE, "*" , "USB DISK*",
	"*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE

Which is something weird because it relies only in the device name across all vendors.
If I add my lines under these ones, it doesn't work.

The patch is tested and working.


Thanks,
Comment 9 Hans Petter Selasky freebsd_committer 2017-10-12 08:37:41 UTC
eadler, mav, flz and more:

USB disk quirks should not be added to:

https://svnweb.freebsd.org/base/head/sys/cam/scsi/scsi_da.c

But instead the USB quirk database. We might need to revisit some old PR's because the existing quirks are starting to false-trigger.

--HPS
Comment 10 Alexander Motin freebsd_committer 2017-10-12 08:43:25 UTC
(In reply to Hans Petter Selasky from comment #9)
I agree.  My general position is that quirks like DA_Q_NO_SYNC_CACHE should not be used unless absolutely necessary due to device is completely broken and crashes for them or responds incorrectly, otherwise CAM should complain on it only once and disable it automatically.