From: Shantanu Goel <sgoel01@yahoo.com>
To: Oliver Neukum <oneukum@suse.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: [PATCH] uas: set host status byte on data completion error
Date: Wed, 5 Jun 2024 21:52:00 +0000 (UTC) [thread overview]
Message-ID: <675774215.2024605.1717624320352@mail.yahoo.com> (raw)
In-Reply-To: 675774215.2024605.1717624320352.ref@mail.yahoo.com
[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]
Hi,
I have a disk enclosure which is prone to data completion errors during initialization and because the UAS driver
only sets the resid on a data completion error and not the host status byte, the SD driver ends up using invalid zero'ed data.
The attached patch against v6.6.32 fixes this by setting the host status byte to DID_ERROR so the SD driver will notice
the error and retry the command.
This bug is present in all stable kernels (4.19, 5.4, 5.15, 6.1, 6,6) and the current 6.9.3 kernel.
This is the behavior prior to applying the patch.
[ 11.872824] sd 0:0:0:1: [sdf] tag#9 data cmplt err -75 uas-tag 1 inflight:
[ 11.872826] sd 0:0:0:1: [sdf] tag#9 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.872830] sd 0:0:0:1: [sdf] Sector size 0 reported, assuming 512.
[ 11.872995] sd 2:0:0:1: [sdn] Preferred minimum I/O size 4096 bytes
[ 11.872996] sd 2:0:0:1: [sdn] Optimal transfer size 33553920 bytes not a multiple of preferred minimum block size (4096 bytes)
[ 11.873466] sd 1:0:0:0: [sdd] tag#29 data cmplt err -75 uas-tag 1 inflight:
[ 11.873468] sd 1:0:0:0: [sdd] tag#29 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.873472] sd 1:0:0:0: [sdd] Sector size 0 reported, assuming 512.
[ 11.873824] sd 7:0:0:0: [sde] Attached SCSI disk
[ 11.874064] sd 3:0:0:1: [sdk] tag#16 data cmplt err -75 uas-tag 1 inflight:
[ 11.874065] sd 3:0:0:1: [sdk] tag#16 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.874070] sd 3:0:0:1: [sdk] Sector size 0 reported, assuming 512.
[ 11.874465] sd 5:0:0:0: [sdo] tag#10 data cmplt err -75 uas-tag 1 inflight:
[ 11.874466] sd 5:0:0:0: [sdo] tag#10 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.874474] sd 5:0:0:0: [sdo] Sector size 0 reported, assuming 512.
[ 11.876151] sd 4:0:0:1: [sdj] tag#10 data cmplt err -75 uas-tag 2 inflight:
[ 11.876153] sd 4:0:0:1: [sdj] tag#10 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.876158] sd 4:0:0:1: [sdj] Sector size 0 reported, assuming 512.
After applying the patch I no longer see the zero sector sizes above and all sizes are detected correctly despite
the presence of completion errors.
Thanks
Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-6.6.32-uas-set-data-result.diff --]
[-- Type: text/x-patch, Size: 426 bytes --]
--- .orig/drivers/usb/storage/uas.c 2024-06-02 11:46:49.144457253 -0400
+++ linux-6.6.32-1.sg.1.el9.x86_64/drivers/usb/storage/uas.c 2024-06-02 11:44:21.523375517 -0400
@@ -422,6 +422,7 @@
uas_log_cmd_state(cmnd, "data cmplt err", status);
/* error: no data transfered */
scsi_set_resid(cmnd, sdb->length);
+ set_host_byte(cmnd, DID_ERROR);
} else {
scsi_set_resid(cmnd, sdb->length - urb->actual_length);
}
next parent reply other threads:[~2024-06-05 22:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <675774215.2024605.1717624320352.ref@mail.yahoo.com>
2024-06-05 21:52 ` Shantanu Goel [this message]
2024-06-06 6:30 ` [PATCH] uas: set host status byte on data completion error Oliver Neukum
2024-06-07 3:20 ` Shantanu Goel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=675774215.2024605.1717624320352@mail.yahoo.com \
--to=sgoel01@yahoo.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox