Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 May 2025 21:37:15 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ec3cc37bd938 - main - umass: Bring in small fix from NetBSD's umass
Message-ID:  <202505072137.547LbFOt092254@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

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

commit ec3cc37bd938446839a34ab9eca79c75257383e1
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-05-07 16:07:50 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-05-07 21:36:55 +0000

    umass: Bring in small fix from NetBSD's umass
    
    When completing a request for UFI, don't fail the request on
    non-zero asc/ascq values if we've done a request sense.
    
    This idea is from umass.c 1.100 by mycroft. He used it to help
    elminate the INQUIRY_SHORT quirk that we still have. However, it will
    make little difference because we treat both return values the same
    for CBI. And it appears we have (maybe bogusly) some devices that
    specify this quirk that aren't CBI.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D49475
---
 sys/dev/usb/storage/umass.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c
index c3a5028f5726..cacf4ddf8f16 100644
--- a/sys/dev/usb/storage/umass.c
+++ b/sys/dev/usb/storage/umass.c
@@ -431,6 +431,7 @@ struct umass_softc {
 	uint8_t	sc_maxlun;		/* maximum LUN number, inclusive */
 	uint8_t	sc_last_xfer_index;
 	uint8_t	sc_status_try;
+	bool sc_sending_sense;
 };
 
 struct umass_probe_proto {
@@ -2013,16 +2014,20 @@ umass_t_cbi_status_callback(struct usb_xfer *xfer, usb_error_t error)
 			/*
 			 * Section 3.4.3.1.3 specifies that the UFI command
 			 * protocol returns an ASC and ASCQ in the interrupt
-			 * data block.
+			 * data block. However, we might also be fetching the
+			 * sense explicitly, where they are likely to be
+			 * non-zero, in which case we should succeed.
 			 */
 
 			DPRINTF(sc, UDMASS_CBI, "UFI CCI, ASC = 0x%02x, "
 			    "ASCQ = 0x%02x\n", sc->sbl.ufi.asc,
 			    sc->sbl.ufi.ascq);
 
-			status = (((sc->sbl.ufi.asc == 0) &&
-			    (sc->sbl.ufi.ascq == 0)) ?
-			    STATUS_CMD_OK : STATUS_CMD_FAILED);
+			if ((sc->sbl.ufi.asc == 0 && sc->sbl.ufi.ascq == 0) ||
+			    sc->sc_transfer.cmd_data[0] == REQUEST_SENSE)
+				status = STATUS_CMD_OK;
+			else
+				status = STATUS_CMD_FAILED;
 
 			sc->sc_transfer.ccb = NULL;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505072137.547LbFOt092254>