Bug 263868 - usb_msc_auto_quirk and usb memory card readers
Summary: usb_msc_auto_quirk and usb memory card readers
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Kyle Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-08 17:55 UTC by Mazin Fadl
Modified: 2024-01-10 03:35 UTC (History)
6 users (show)

See Also:
kevans: mfc-stable14?
kevans: mfc-stable13?
kevans: mfc-stable12-


Attachments
Genesys GL3220 AiO card reader usb quirk (1.30 KB, patch)
2022-05-08 19:46 UTC, Mazin Fadl
no flags Details | Diff
NOREL Systems NS1081 flash card reader usb quirk (1.53 KB, patch)
2022-05-08 19:49 UTC, Mazin Fadl
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mazin Fadl 2022-05-08 17:55:13 UTC
Patch D30919 broke a couple of USB card readers I use, a Genesys GL3220 USB3.1
AiO flash card reader, and a Norelsys NS1081 USB 3.0 flash card reader.

Using Patch D35075's hatch escape for the usb_msc_auto_quirk code I've been
able to get them working by setting UQ_MSC_NO_INQUIRY, and adding the specific
quirk they seem to need: UQ_MSC_NO_RS_CLEAR_UA. Without adding this quirk, flash card
hotplugging did not work on the Genesys, and the Norelsys did not work at all.

My loader conf for these devices:
# GENESYS GL3220 USB3.1 AiO Card Reader
hw.usb.quirk.0="0x05e3 0x0732 0 0xffff UQ_MSC_NO_INQUIRY"
hw.usb.quirk.1="0x05e3 0x0732 0 0xffff UQ_MSC_NO_RS_CLEAR_UA"
hw.usb.quirk.2="0x05e3 0x0732 0 0xffff UQ_MSC_NO_SYNC_CACHE"
# Norelsys NS1081 USB 3.0 Flash Card Reader
hw.usb.quirk.3="0x2537 0x1081 0 0xffff UQ_MS_NO_INQUIRY"
hw.usb.quirk.4="0x2537 0x1081 0 0xffff UQ_MSC_NO_RS_CLEAR_UA"

dmesg logs for the devices before manually setting UQ_MSC_NO_INQUIRY:
# Genesys
usb_msc_auto_quirk: UQ_MSC_NO_TEST_UNIT_READY set for USB mass storage device vendor 0x05e3 USB Storage (0x05e3:0x0732)
usb_msc_auto_quirk: UQ_MSC_NO_PREVENT_ALLOW set for USB mass storage device vendor 0x05e3 USB Storage (0x05e3:0x0732)
usb_msc_auto_quirk: UQ_MSC_NO_SYNC_CACHE set for USB mass storage device vendor 0x05e3 USB Storage (0x05e3:0x0732)
ugen2.5: <vendor 0x05e3 USB Storage> at usbus2
umass0 on uhub7
umass0: <vendor 0x05e3 USB Storage, class 0/0, rev 3.00/0.03, addr 4> on usbus2
umass0:  SCSI over Bulk-Only; quirks = 0xc001
umass0:7:0: Attached to scbus7
(probe0:umass-sim0:0:0:0): REPORT LUNS. CDB: a0 00 00 00 00 00 00 00 00 10 00 00
(probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:0): SCSI status: Check Condition
(probe0:umass-sim0:0:0:0): SCSI sense: NOT READY asc:3a,0 (Medium not present)
(probe0:umass-sim0:0:0:0): Error 6, Unretryable error
...
da2 at umass-sim0 bus 0 scbus7 target 0 lun 2
da2: <Generic STORAGE DEVICE DP03> Removable Direct Access SPC-3 SCSI device
da2: Serial Number 00000000DP03
da2: 400.000MB/s transfers
da2: Attempt to query device size failed: NOT READY, Medium not present
da2: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>
...

# Norelsys NS1081 USB 3.0 Flash Card Reader
usb_msc_auto_quirk: UQ_MSC_NO_PREVENT_ALLOW set for USB mass storage device UGR
EEN USB3.0 Card Reader (0x2537:0x1081)
ugen0.2: <UGREEN USB3.0 Card Reader> at usbus0
umass1 on uhub0
umass1: <UGREEN USB3.0 Card Reader, class 0/0, rev 3.00/1.00, addr 1> on usbus0
umass1:  SCSI over Bulk-Only; quirks = 0x8000
umass1:8:1: Attached to scbus8
(probe0:umass-sim1:1:0:0): REPORT LUNS. CDB: a0 00 00 00 00 00 00 00 00 10 00 0
0
(probe0:umass-sim1:1:0:0): CAM status: Auto-Sense Retrieval Failed
(probe0:umass-sim1:1:0:0): Error 5, Unretryable error
(da5:umass-sim1:1:0:0): got CAM status 0x450
(da5:umass-sim1:1:0:0): fatal error, failed to attach to device
g_dev_taste: g_dev_taste(da5) failed to g_attach, error=6
(da5:umass-sim1:1:0:1): got CAM status 0x450
(da5:umass-sim1:1:0:1): fatal error, failed to attach to device
g_dev_taste: g_dev_taste(da5) failed to g_attach, error=6
umass1: at uhub0, port 8, addr 1 (disconnected)
umass1: detached

dmesg logs for the devices after setting the above configuration:
# Norelsys NS1081 with one SD card plugged in the two available slots
ugen0.2: <UGREEN USB3.0 Card Reader> at usbus0
umass1 on uhub0
umass1: <UGREEN USB3.0 Card Reader, class 0/0, rev 3.00/1.00, addr 3> on usbus0
umass1:  SCSI over Bulk-Only; quirks = 0x440a
umass1:8:1: Attached to scbus8
da5 at umass-sim1 bus 1 scbus8 target 0 lun 0
da5: <  > Removable Direct Access SCSI-2 device
da5: 400.000MB/s transfers
da5: 244816MB (501383168 512 byte sectors)
da5: quirks=0x2<NO_6_BYTE>
(da6:umass-sim1:1:0:1): got CAM status 0x450 # empty card slot
(da6:umass-sim1:1:0:1): fatal error, failed to attach to device

# GENESYS GL3220 USB3.1 AiO Card Reader with one SD card plugged in
ugen2.5: <vendor 0x05e3 USB Storage> at usbus2
umass0 on uhub7
umass0: <vendor 0x05e3 USB Storage, class 0/0, rev 3.00/0.03, addr 4> on usbus2
umass0:  SCSI over Bulk-Only; quirks = 0x4000
umass0:7:0: Attached to scbus7
(probe0:umass-sim0:0:0:0): REPORT LUNS. CDB: a0 00 00 00 00 00 00 00 00 10 00 00 
(probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:0): SCSI status: Check Condition
(probe0:umass-sim0:0:0:0): SCSI sense: NOT READY asc:3a,0 (Medium not present)
(probe0:umass-sim0:0:0:0): Error 6, Unretryable error
....
da2 at umass-sim0 bus 0 scbus7 target 0 lun 2
da2: <Generic STORAGE DEVICE DP03> Removable Direct Access SPC-3 SCSI device
da2: Serial Number 00000000DP03
da2: 400.000MB/s transfers
da2: 244816MB (501383168 512 byte sectors)
da2: quirks=0x3<NO_SYNC_CACHE,NO_6_BYTE>
...
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2022-05-08 18:07:52 UTC
Which version of FreeBSD is this?

Feel free to attach a patch for usb_quirk.c in sys/dev/usb/quirk/

--HPS
Comment 2 Mazin Fadl 2022-05-08 19:46:50 UTC
Created attachment 233812 [details]
Genesys GL3220 AiO card reader usb quirk
Comment 3 Mazin Fadl 2022-05-08 19:49:26 UTC
Created attachment 233813 [details]
NOREL Systems NS1081 flash card reader usb quirk
Comment 4 Mazin Fadl 2022-05-08 19:51:29 UTC
This was on 14.0-CURRENT main-n255113-9b4c606b96ce.

I just verified that the broken behaviour is the same on main-n255391-c6df21760381.

I created usb_quirk.c (and usbdevs) patches for both devices.

Thank you
Comment 5 Lukas Turek 2022-06-15 21:49:32 UTC
I have a similar problem with D30919, for me it broke InnoDisk Nano USB stick. In 13.0 it was detected correctly:

ugen0.7: <InnoDisk Nano USB> at usbus0
umass1 on uhub0
umass1: <InnoDisk Nano USB, class 0/0, rev 2.00/2.50, addr 6> on usbus0
umass1:  SCSI over Bulk-Only; quirks = 0xc100
umass1:15:1: Attached to scbus15
da1 at umass-sim1 bus 1 scbus15 target 0 lun 0
da1: <InnoDisk Nano USB 0250> Removable Direct Access SCSI device
da1: Serial Number 16E24A000014
da1: 40.000MB/s transfers
da1: 976MB (2000895 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>

In 13.1 the USB stick freezes and won't reconnect even after reboot, it needs to be physically unplugged and plugged back:

usb_msc_auto_quirk: UQ_MSC_NO_GETMAXLUN set for USB mass storage device InnoDisk Nano USB (0x196d:0x0201)
usb_msc_auto_quirk: UQ_MSC_NO_PREVENT_ALLOW set for USB mass storage device InnoDisk Nano USB (0x196d:0x0201)
usb_msc_auto_quirk: UQ_MSC_NO_SYNC_CACHE set for USB mass storage device InnoDisk Nano USB (0x196d:0x0201)
ugen0.7: <InnoDisk Nano USB> at usbus0
umass1 on uhub0
umass1: <InnoDisk Nano USB, class 0/0, rev 2.00/2.50, addr 6> on usbus0
umass1:  SCSI over Bulk-Only; quirks = 0xc100
umass1:15:1: Attached to scbus15
(probe0:umass-sim1:1:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim1:1:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim1:1:0:0): Retrying command, 3 more tries remain
(probe0:umass-sim1:1:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim1:1:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim1:1:0:0): Retrying command, 2 more tries remain
(probe0:umass-sim1:1:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim1:1:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim1:1:0:0): Retrying command, 1 more tries remain
(probe0:umass-sim1:1:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim1:1:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim1:1:0:0): Retrying command, 0 more tries remain
(probe0:umass-sim1:1:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim1:1:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim1:1:0:0): Error 5, Retries exhausted

The device doesn't actually need any dynamic quirk. In fact it's the detected quirks that cause the device to stop responding because of this code:

        if (any_quirk) {
                /* Unconfigure device, to clear software data toggle. */
                usbd_set_config_index(udev, USB_UNCONFIG_INDEX);

                /* Need to re-enumerate the device to clear its state. */
                usbd_req_re_enumerate(udev, NULL);
                return (USB_ERR_STALLED);
        }

When I commented it out, the USB stick worked correctly:

usb_msc_auto_quirk: UQ_MSC_NO_GETMAXLUN set for USB mass storage device InnoDisk Nano USB (0x196d:0x0201)
usb_msc_auto_quirk: UQ_MSC_NO_PREVENT_ALLOW set for USB mass storage device InnoDisk Nano USB (0x196d:0x0201)
usb_msc_auto_quirk: UQ_MSC_NO_SYNC_CACHE set for USB mass storage device InnoDisk Nano USB (0x196d:0x0201)
ugen0.7: <InnoDisk Nano USB> at usbus0
umass1 on uhub0
umass1: <InnoDisk Nano USB, class 0/0, rev 2.00/2.50, addr 6> on usbus0
umass1:  SCSI over Bulk-Only; quirks = 0xc100
umass1:15:1: Attached to scbus15
da1 at umass-sim1 bus 1 scbus15 target 0 lun 0
da1: <InnoDisk Nano USB 0250> Removable Direct Access SCSI device
da1: Serial Number 16E24A000014
da1: 40.000MB/s transfers
da1: 976MB (2000895 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>
Comment 6 Hans Petter Selasky freebsd_committer freebsd_triage 2022-06-16 00:15:02 UTC
Changes look good.

--HPS
Comment 7 Max 2023-01-21 21:15:44 UTC
Hello,

I experienced a similar issue on 13.1 with the NS1081 device.
Could you please let me know which branch the above patch will be applied to?

Thanks
Max
Comment 8 Max 2023-01-21 21:36:11 UTC
I confirmed that the above patch for NS1081 worked for me on 13.1 and the device was successfully attached.

Thanks
Max
Comment 9 Kyle Evans freebsd_committer freebsd_triage 2023-10-11 03:37:21 UTC
(In reply to Lukas Turek from comment #5)

Hi Lukas,

Can you confirm that adding UQ_MSC_NO_INQUIRY for that particular device with a loader tunable is sufficient to make it work again, please?

e.g., something like:

hw.usb.quirk.0="0x196d 0x0201 0 0xffff UQ_MSC_NO_INQUIRY"

Thanks
Comment 10 Kyle Evans freebsd_committer freebsd_triage 2023-10-11 03:54:07 UTC
(In reply to Kyle Evans from comment #9)

Hmm, that's probably not a good general solution. That does kill off more than we want. =\
Comment 11 commit-hook freebsd_committer freebsd_triage 2023-10-11 21:09:30 UTC
A commit in branch main references this bug:

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

commit b332adfa96218148dfbb936a9c09d00484c868e3
Author:     Mazin Fadl <mazen@illumed.net>
AuthorDate: 2023-10-11 03:12:22 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-10-11 21:08:53 +0000

    usb: add necessary quirks for the NOREL Systems NS1081 SD reader

    Without these, the Norelsys NS1081 is completely defunct.

    PR:     263868
    Fixes:  520b88860d7a79 ("usb(4): Automagically apply all quirks [...]")

 sys/dev/usb/quirk/usb_quirk.c | 2 ++
 sys/dev/usb/usbdevs           | 4 ++++
 2 files changed, 6 insertions(+)
Comment 12 commit-hook freebsd_committer freebsd_triage 2023-10-11 21:09:32 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=94efe9f91be7f3aa501983716db5a4378282a734

commit 94efe9f91be7f3aa501983716db5a4378282a734
Author:     Mazin Fadl <mazen@illumed.net>
AuthorDate: 2023-10-11 03:22:12 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-10-11 21:08:53 +0000

    usb: add quirks for the Genesys GL3220 card reader

    Without these, card hotplugging does not work on the GL3220.

    PR:     263868
    Fixes:  520b88860d7a79 ("usb(4): Automagically apply all quirks [...]")

 sys/dev/usb/quirk/usb_quirk.c | 2 ++
 sys/dev/usb/usbdevs           | 1 +
 2 files changed, 3 insertions(+)
Comment 13 Lukas Turek 2023-10-16 23:58:35 UTC
(In reply to Kyle Evans from comment #9)

I'm actually already using this tunable, because reverting D30919 fixed "InnoDisk Nano USB", but broke "InnoDisk USB Drive 2SE", which worked fine before. Conversely, the tunable did not affect any other USB stick, so I now use it by default.
Comment 14 commit-hook freebsd_committer freebsd_triage 2023-11-26 04:07:59 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=93f1302dc6339bbf7e7ed42664a3e848b76eafcf

commit 93f1302dc6339bbf7e7ed42664a3e848b76eafcf
Author:     Mazin Fadl <mazen@illumed.net>
AuthorDate: 2023-10-11 03:22:12 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-11-26 04:07:11 +0000

    usb: add quirks for the Genesys GL3220 card reader

    Without these, card hotplugging does not work on the GL3220.

    PR:     263868
    Fixes:  7520b88860d7a79 ("usb(4): Automagically apply all quirks [...]")
    (cherry picked from commit 94efe9f91be7f3aa501983716db5a4378282a734)

 sys/dev/usb/quirk/usb_quirk.c | 2 ++
 sys/dev/usb/usbdevs           | 1 +
 2 files changed, 3 insertions(+)
Comment 15 commit-hook freebsd_committer freebsd_triage 2023-11-26 04:08:01 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6c22e9fa0c0f9f5b2052b493e4b64205695a0045

commit 6c22e9fa0c0f9f5b2052b493e4b64205695a0045
Author:     Mazin Fadl <mazen@illumed.net>
AuthorDate: 2023-10-11 03:12:22 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-11-26 04:07:11 +0000

    usb: add necessary quirks for the NOREL Systems NS1081 SD reader

    Without these, the Norelsys NS1081 is completely defunct.

    PR:     263868
    Fixes:  7520b88860d7a79 ("usb(4): Automagically apply all quirks [...]")
    (cherry picked from commit b332adfa96218148dfbb936a9c09d00484c868e3)

 sys/dev/usb/quirk/usb_quirk.c | 2 ++
 sys/dev/usb/usbdevs           | 4 ++++
 2 files changed, 6 insertions(+)
Comment 16 commit-hook freebsd_committer freebsd_triage 2023-11-26 04:09:02 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5330fb235ae6db376bc4ee09f8270f88c27256ca

commit 5330fb235ae6db376bc4ee09f8270f88c27256ca
Author:     Mazin Fadl <mazen@illumed.net>
AuthorDate: 2023-10-11 03:22:12 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-11-26 04:07:16 +0000

    usb: add quirks for the Genesys GL3220 card reader

    Without these, card hotplugging does not work on the GL3220.

    PR:     263868
    Fixes:  7520b88860d7a79 ("usb(4): Automagically apply all quirks [...]")
    (cherry picked from commit 94efe9f91be7f3aa501983716db5a4378282a734)

 sys/dev/usb/quirk/usb_quirk.c | 2 ++
 sys/dev/usb/usbdevs           | 1 +
 2 files changed, 3 insertions(+)
Comment 17 commit-hook freebsd_committer freebsd_triage 2023-11-26 04:09:04 UTC
A commit in branch stable/13 references this bug:

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

commit d0e771e2fd23ca65024ee3026584a020057c166b
Author:     Mazin Fadl <mazen@illumed.net>
AuthorDate: 2023-10-11 03:12:22 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-11-26 04:07:16 +0000

    usb: add necessary quirks for the NOREL Systems NS1081 SD reader

    Without these, the Norelsys NS1081 is completely defunct.

    PR:     263868
    Fixes:  7520b88860d7a79 ("usb(4): Automagically apply all quirks [...]")
    (cherry picked from commit b332adfa96218148dfbb936a9c09d00484c868e3)

 sys/dev/usb/quirk/usb_quirk.c | 2 ++
 sys/dev/usb/usbdevs           | 4 ++++
 2 files changed, 6 insertions(+)
Comment 18 Mark Linimon freebsd_committer freebsd_triage 2024-01-10 03:35:38 UTC
^Triage: now committed to all supported branches.