Bug 253855 - Add quirk entries for Kingston DataTraveler
Summary: Add quirk entries for Kingston DataTraveler
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-25 19:59 UTC by vidwer+fbsdbugs
Modified: 2021-05-10 14:33 UTC (History)
1 user (show)

See Also:


Attachments
diff (1.19 KB, text/plain)
2021-02-25 19:59 UTC, vidwer+fbsdbugs
no flags Details
diff (1.19 KB, patch)
2021-02-27 13:15 UTC, vidwer+fbsdbugs
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vidwer+fbsdbugs 2021-02-25 19:59:51 UTC
Created attachment 222832 [details]
diff
Comment 1 Hans Petter Selasky freebsd_committer 2021-02-25 20:35:01 UTC
Can you show some dmesg and usbconfig output?

Is it possible to automagically apply such quirks?
Comment 2 vidwer+fbsdbugs 2021-02-25 20:43:14 UTC
(In reply to Hans Petter Selasky from comment #1)
What do you mean with automagically?

Ideally the kernel or some script that has yet to be written should predict or hint which QUIRKs to utilise.
Comment 3 Hans Petter Selasky freebsd_committer 2021-02-25 20:50:11 UTC
We have a piece of code which test some well known quirks already, ./sys/dev/usb/usb_msctest.c . Maybe you could design a test for the quirk in question?

--HPS
Comment 4 vidwer+fbsdbugs 2021-02-25 21:07:54 UTC
(In reply to Hans Petter Selasky from comment #1)
Without quirk entries:

ugen1.3: <Kingston DataTraveler 3.0> at usbus1
umass0 on uhub6
umass0: <Kingston DataTraveler 3.0, class 0/0, rev 3.10/1.10, addr 2> on usbus1
umass0:  SCSI over Bulk-Only; quirks = 0x8100
umass0:2:0: Attached to scbus2
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00 
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 3 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00 
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 2 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00 
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 1 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00 
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 0 more tries remain
pass2 at umass-sim0 bus 0 scbus2 target 0 lun 0
pass2: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
pass2: Serial Number 50E549C6930DE0C1694EA302
pass2: 400.000MB/s transfers
GEOM: new disk da0
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
da0: Serial Number 50E549C6930DE0C1694EA302
da0: 400.000MB/s transfers
da0: 14772MB (30253056 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>
da0: Delete methods: <NONE(*),ZERO>

With UQ_MSC_NO_SYNC_CACHE:
ugen1.3: <Kingston DataTraveler 3.0> at usbus1
umass0 on uhub6
umass0: <Kingston DataTraveler 3.0, class 0/0, rev 3.10/1.10, addr 2> on usbus1
umass0:  SCSI over Bulk-Only; quirks = 0x4000
umass0:2:0: Attached to scbus2
pass2 at umass-sim0 bus 0 scbus2 target 0 lun 0
pass2: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
pass2: Serial Number 50E549C6930DE0C1694EA302
pass2: 400.000MB/s transfers
GEOM: new disk da0
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
da0: Serial Number 50E549C6930DE0C1694EA302
da0: 400.000MB/s transfers
da0: 14772MB (30253056 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>
da0: Delete methods: <NONE(*),ZERO>
(da0:umass-sim0:0:0:0): PREVENT ALLOW MEDIUM REMOVAL not supported.

With UQ_MSC_NO_SYNC_CACHE and UQ_MSC_NO_PREVENT_ALLOW:
ugen1.3: <Kingston DataTraveler 3.0> at usbus1
umass0 on uhub6
umass0: <Kingston DataTraveler 3.0, class 0/0, rev 3.10/1.10, addr 2> on usbus1
umass0:  SCSI over Bulk-Only; quirks = 0xc000
umass0:2:0: Attached to scbus2
pass2 at umass-sim0 bus 0 scbus2 target 0 lun 0
pass2: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
pass2: Serial Number 50E549C6930DE0C1694EA302
pass2: 400.000MB/s transfers
GEOM: new disk da0
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
da0: Serial Number 50E549C6930DE0C1694EA302
da0: 400.000MB/s transfers
da0: 14772MB (30253056 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>
da0: Delete methods: <NONE(*),ZERO>
Comment 5 vidwer+fbsdbugs 2021-02-25 21:07:59 UTC
# usbconfig -d 1.3 dump_device_desc
ugen1.3: <Kingston DataTraveler 3.0> at usbus1, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (126mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0310 
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0009 
  idVendor = 0x0951 
  idProduct = 0x1666 
  bcdDevice = 0x0110 
  iManufacturer = 0x0001  <Kingston>
  iProduct = 0x0002  <DataTraveler 3.0>
  iSerialNumber = 0x0003  <50E549C6930DE0C1694EA302>
  bNumConfigurations = 0x0001
Comment 6 vidwer+fbsdbugs 2021-02-26 00:08:47 UTC
(In reply to Hans Petter Selasky from comment #3)
I had a look at freebsd-src, and code ( usb_msc_auto_quirk() ) surrounded with USB_HAVE_MSCTEST is expected to run while the opposite is true?

https://github.com/freebsd/freebsd-src/blob/main/sys/dev/usb/usb_device.c#L2048
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/usb/usb_freebsd.h#L45
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/usb/usb_freebsd_loader.h#L45
Comment 7 Hans Petter Selasky freebsd_committer 2021-02-26 10:58:25 UTC
usb_freebsd.h is for the kernel.

The others are for boot-loaders.

When USB_HAVE_MSCTEST is defined to 1, then all automagic mass storage quirk detection is activated.

You can basically send a USB SCSI commands there and get a reply back. Maybe you can add code to taste the quirky commands early on, and then just set the USB MSC quirk flag, if you don't get the expected result, for example.

--HPS
Comment 8 vidwer+fbsdbugs 2021-02-27 13:15:47 UTC
Created attachment 222862 [details]
diff
Comment 9 commit-hook freebsd_committer 2021-04-22 10:42:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=47bc8fc9ae6ba7aa708e0d4ee059a377ae707e5a

commit 47bc8fc9ae6ba7aa708e0d4ee059a377ae707e5a
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-04-22 10:40:17 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-04-22 10:40:29 +0000

    Add more USB quirks for Kingston devices.

    PR:             253855
    MFC after:      1 week
    Sponsored by:   Mellanox Technologies // NVIDIA Networking

 sys/dev/usb/quirk/usb_quirk.c | 1 +
 sys/dev/usb/usbdevs           | 1 +
 2 files changed, 2 insertions(+)
Comment 10 commit-hook freebsd_committer 2021-05-10 14:33:06 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=74ef3f740dcfe4c660e192fda7a81a87cf0c67c2

commit 74ef3f740dcfe4c660e192fda7a81a87cf0c67c2
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-04-22 10:40:17 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-05-10 14:11:19 +0000

    Add more USB quirks for Kingston devices.

    PR:             253855
    Sponsored by:   Mellanox Technologies // NVIDIA Networking

    (cherry picked from commit 47bc8fc9ae6ba7aa708e0d4ee059a377ae707e5a)

 sys/dev/usb/quirk/usb_quirk.c | 1 +
 sys/dev/usb/usbdevs           | 1 +
 2 files changed, 2 insertions(+)