git: cb68867ec7bb - stable/13 - usb: Respect NO_INQUIRY quirk during device enumeration

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Sun, 30 Apr 2023 06:57:46 UTC
The branch stable/13 has been updated by hselasky:

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

commit cb68867ec7bba4d296cedb73c09f4256086cff32
Author:     Kornel Duleba <mindal@semihalf.com>
AuthorDate: 2022-04-26 12:07:21 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2023-04-30 06:56:16 +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
    
    (cherry picked from commit 3ee943868c74ce917820fe9ddbcfeab338704d90)
---
 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: