From: Luca Cecchi <luca.cecchi.info@gmail.com>
To: linux-usb@vger.kernel.org
Cc: linux-scsi@vger.kernel.org, oneukum@suse.com,
Luca Cecchi <luca.cecchi.info@gmail.com>
Subject: [PATCH] usb: uas: implement .change_queue_depth to allow per-device queue depth override
Date: Thu, 8 Oct 2026 13:26:45 +0200 [thread overview]
Message-ID: <20261008112645.1820678-1-luca.cecchi.info@gmail.com> (raw)
In-Reply-To: <f82a72b7-6122-4bbc-adf4-2d08706344a2@suse.com>
uas_host_template does not implement .change_queue_depth. Because of
that, the standard sysfs queue_depth attribute stays read-only for
every UAS device, not just mine: scsi_sysfs.c:sdev_store_queue_depth()
requires sht->change_queue_depth to be non-NULL before it allows a
write.
uas_probe() already defaults can_queue to qdepth - 2, with a comment
acknowledging that "some bridge firmwares" need extra margin. That
margin isn't enough for every bridge. Right now the only way to work
around a bridge that needs more headroom is the IGNORE_UAS quirk,
which disables UAS entirely and falls back to BOT/usb-storage - a
large performance cost for a queue-depth problem.
This patch wires up .change_queue_depth so affected users can lower
the depth for just their device (e.g. via a udev rule matching
idVendor/idProduct), without disabling UAS altogether. Default
behaviour (qdepth - 2) is unchanged unless userspace asks for less.
Tested against a Lexar ES3 external SSD enclosure (VID:PID 21c4:0003)
that locks up under sustained heavy concurrent random writes at the
default queue depth. Capping the depth to 24 via this interface
eliminated the lockup across 6 consecutive test runs, including a
continuous 1-hour soak test (1.36TB written, ~822MB/s, no
uas_eh_abort_handler events).
Signed-off-by: Luca Cecchi <luca.cecchi.info@gmail.com>
---
drivers/usb/storage/uas.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 2651629..74fc438 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -910,6 +910,27 @@ static int uas_sdev_configure(struct scsi_device *sdev,
return 0;
}
+/*
+ * uas does not implement .change_queue_depth, so the standard sysfs
+ * queue_depth attribute stays read-only for every UAS device (see
+ * scsi_sysfs.c:sdev_store_queue_depth(), which requires
+ * sht->change_queue_depth != NULL). Some bridge chips become
+ * unstable under deep command queueing; wiring this up lets affected
+ * users lower the depth for just their device (e.g. via a udev rule
+ * matching idVendor/idProduct), without disabling UAS altogether.
+ * Default behaviour (qdepth - 2) is unchanged unless userspace asks
+ * for less.
+ */
+static int uas_change_queue_depth(struct scsi_device *sdev, int depth)
+{
+ struct uas_dev_info *devinfo = (struct uas_dev_info *)sdev->host->hostdata;
+ int max_depth = devinfo->qdepth - 2;
+
+ if (depth > max_depth)
+ depth = max_depth;
+ return scsi_change_queue_depth(sdev, depth);
+}
+
static const struct scsi_host_template uas_host_template = {
.module = THIS_MODULE,
.name = "uas",
@@ -917,6 +938,7 @@ static const struct scsi_host_template uas_host_template = {
.target_alloc = uas_target_alloc,
.sdev_init = uas_sdev_init,
.sdev_configure = uas_sdev_configure,
+ .change_queue_depth = uas_change_queue_depth,
.eh_abort_handler = uas_eh_abort_handler,
.eh_host_reset_handler = uas_eh_host_reset_handler,
.this_id = -1,
--
2.55.0
next prev parent reply other threads:[~2026-10-08 11:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 11:41 [RFC] usb: uas: implement .change_queue_depth to allow per-device queue depth override Luca Cecchi
2026-10-08 11:00 ` Oliver Neukum
2026-10-08 11:26 ` Luca Cecchi [this message]
2026-10-08 11:36 ` [PATCH] " sashiko-bot
2026-10-08 12:26 ` [PATCH v2 1/2] " Luca Cecchi
2026-10-08 12:26 ` [PATCH v2 2/2] usb: uas: add US_FL_QDEPTH_075 quirk to cap queue depth at probe time Luca Cecchi
2026-10-08 12:33 ` sashiko-bot
2026-10-08 12:32 ` [PATCH v2 1/2] usb: uas: implement .change_queue_depth to allow per-device queue depth override sashiko-bot
2026-10-08 13:32 ` Oliver Neukum
2026-10-08 14:21 ` Alan Stern
2026-10-08 20:19 ` Luca Cecchi
2026-10-09 8:03 ` Luca Cecchi
2026-10-09 8:12 ` [PATCH v3 " Luca Cecchi
2026-10-09 8:12 ` [PATCH v3 2/2] usb: uas: add US_FL_QDEPTH_075 quirk to cap queue depth at probe time Luca Cecchi
2026-10-09 8:20 ` sashiko-bot
2026-10-09 8:29 ` [PATCH v3 1/2] usb: uas: implement .change_queue_depth to allow per-device queue depth override sashiko-bot
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=20261008112645.1820678-1-luca.cecchi.info@gmail.com \
--to=luca.cecchi.info@gmail.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