git: 3ee943868c74 - main - usb: Respect NO_INQUIRY quirk during device enumeration

From: Wojciech Macek <wma_at_FreeBSD.org>
Date: Thu, 28 Apr 2022 06:42:39 UTC
The branch main has been updated by wma:

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

commit 3ee943868c74ce917820fe9ddbcfeab338704d90
Author:     Kornel Duleba <mindal@semihalf.com>
AuthorDate: 2022-04-26 12:07:21 +0000
Commit:     Wojciech Macek <wma@FreeBSD.org>
CommitDate: 2022-04-28 06:42:26 +0000

    usb: Respect NO_INQUIRY quirk during device enumeration
    
    Both usb_iface_is_cdrom and usb_msc_auto_quirk functions use SCSI INQUIRY
    command to probe various properties of usb mass storage devices.
    The problem here is that some very broken devices don't like this command.
    Check if UQ_MSC_NO_INQUIRY quirk is set and skip cdrom and quirk
    autodetection in that case.
    
    Sponsored by: Stormshield
    Obtained from: Semihalf
    Reviewed by: hps, wma
    Differential Revision: https://reviews.freebsd.org/D35075
---
 sys/dev/usb/usb_device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index 6564182a97b0..b5e51cbdc7a7 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -2031,7 +2031,8 @@ repeat_set_config:
 			goto repeat_set_config;
 		}
 #if USB_HAVE_MSCTEST
-		if (config_index == 0) {
+		if (config_index == 0 &&
+		    usb_test_quirk(&uaa, UQ_MSC_NO_INQUIRY) == 0) {
 			/*
 			 * Try to figure out if we have an
 			 * auto-install disk there:
@@ -2051,7 +2052,8 @@ repeat_set_config:
 	    usb_test_quirk(&uaa, UQ_MSC_NO_PREVENT_ALLOW) == 0 &&
 	    usb_test_quirk(&uaa, UQ_MSC_NO_SYNC_CACHE) == 0 &&
 	    usb_test_quirk(&uaa, UQ_MSC_NO_TEST_UNIT_READY) == 0 &&
-	    usb_test_quirk(&uaa, UQ_MSC_NO_GETMAXLUN) == 0) {
+	    usb_test_quirk(&uaa, UQ_MSC_NO_GETMAXLUN) == 0 &&
+	    usb_test_quirk(&uaa, UQ_MSC_NO_INQUIRY) == 0) {
 		/*
 		 * Try to figure out if there are any MSC quirks we
 		 * should apply automatically: