From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Thinh Nguyen" <Thinh.Nguyen@synopsys.com>,
"Michal Pecio" <michal.pecio@gmail.com>,
"Oliver Neukum" <oneukum@suse.com>, "Bjørn Mork" <bjorn@mork.no>,
"USB list" <linux-usb@vger.kernel.org>
Subject: Re: correctly handling EPROTO
Date: Sat, 21 Mar 2026 02:14:46 +0000 [thread overview]
Message-ID: <20260321021439.7pmcdrpb5oxbivct@synopsys.com> (raw)
In-Reply-To: <2929d47c-fc02-49d2-873e-758f24c43071@rowland.harvard.edu>
On Fri, Mar 20, 2026, Alan Stern wrote:
> On Thu, Mar 19, 2026 at 11:16:22PM +0000, Thinh Nguyen wrote:
> > On Wed, Mar 18, 2026, Alan Stern wrote:
> > > On Wed, Mar 18, 2026 at 11:59:21PM +0000, Thinh Nguyen wrote:
> > > > I've seen Windows drivers handling UAS transaction error recovery
> > > > through clear-halt and retry SCSI command, and it works well. I hope to
> > > > see this type of recovery implemented for usb storage and uas devices in
> > > > the future.
> > >
> > > I don't know about uas, but usb-storage handles transaction error
> > > recovery in approximately the same way. A clear-halt is issued only if
> > > the device sent a halt token -- but that's not considered a transaction
> >
> > That's -EPIPE right? With this, the storage driver knows that it needs to
> > perform clear-halt because the bulk endpoint is STALL, not -EPROTO.
>
> Correct. As for Michal's caveats regarding TTs, they don't really apply
> to USB mass-storage devices because almost all of them can connect at
> high speed or even at SuperSpeed. Besides, even if there was a device
> behind a TT and the TT messed up recovery from a -EPIPE, usb-storage
> would simply proceed with a port reset.
>
> (There may be a few oddball devices out there which can only run at full
> speed. For instance, at one time when Linus reported that his wife was
> having a problem with some low-end mass-storage device she used for
> knitting or crochet. It turned out not to be any sort of protocol
> error; the problem was caused by the userspace utilities that probe each
> newly added disk looking for partition and LVM information -- this
> device was extremely slow and had a total storage capacity something
> like a mere 100 KB (not MB!), and the utilities were trying to read all
> of it repeatedly, which took a long time.)
Yikes, with that device, -EPROTO probably is the least of the concern.
It better serve in certain tech museum.
>
> > > error. Otherwise, for things like -EPROTO, usb-storage does a device
> > > reset and the SCSI command is retried. Possibly skipping some initial
> >
> > The recovery I'm thinking of doesn't involve a port reset. A port reset
> > is very disruptive and will impact performance greatly. I'm referring to
> > an intermediate recovery step at the usb storage driver without
> > delegating to the SCSI layer.
>
> I don't know what other sort of intermediate reset could be carried out.
> The Bulk-Only-Transport protocol _does_ include a class-specific reset
> request, but usb-storage doesn't use it because experience has shown
> that practically no USB mass-storage devices implement it properly
> (which was probably a consequence of the fact that Windows did not use
> it).
>
> In fact, the error recovery sequence used by usb-storage is as similar
> to what Windows does -- or did, since this goes back quite a few years
> -- as I could make it.
Just to be clear, I'm not suggesting to replace the current recovery
mechanism, but potentially we can introduce more.
>
> Naturally, UAS may be a totally different situation.
Windows has a clever way to handle this for UAS. It sends a command/task
with the same tag as the failing transfer on the command endpoint,
triggering an overlap tag response and causing the device side to cancel
the command along with the pending data transfer. This puts the host and
device in sync again.
All compliant UAS devices must support overlap tag detection.
(We can go into more detail should we want to pursue this)
>
> > Currently we _have_ to do a port reset because the bulk sequence can be
> > out of sync and the xhci doesn't synchronize against the device for the
> > storage driver to retry the command directly.
>
> The same is true for EHCI.
>
> > What I'd like to see is that the endpoint can be put in a state where
> > the class driver can submit a new URB without unbind/reset/power cycle.
> > With the current implementation of the xhci driver, we cannot do that
> > for bulk endpoints with -EPROTO error.
>
> Which means unlinking queued URBs (either automatically by the core or
> else by hand in the class driver), waiting for them to complete, and
> issuing a clear-halt. Once that is done, submission of new URBs should
The clear-halt doesn't have to be done after the unlinking of URBs. The
xhci endpoint is in stopped state after a reset ep command. As
long as the class driver doesn't submit a new URB to trigger a doorbell
ring, the xhci driver can send a clear-halt after a reset ep command and
no transfer will start.
> work, if the cause of the error was transient and has gone away.
>
> I don't make any distinction here between resubmitting the URB that
> failed (a retry) or submitting a new, completely different URB. But
> Michal is right that under some circumstances, when communicating with a
> low- or full-speed device (which is common with HID), data may get lost
> or duplicated. I don't see anything we can do about that.
>
Of course, as I mentioned, there needs to be synchronization mechanism
at the class driver or higher layer.
The xhci spec actually suggests to perform clear-halt after a reset for
this type of scenario. Whether there will be any class driver to take
advantage of retrying without port reset is a different matter.
I can see that this kind of recovery can be done, and it seems to be an
improvement. So I just want to put it out there.
BR,
Thinh
next prev parent reply other threads:[~2026-03-21 2:15 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 13:55 correctly handling EPROTO Oliver Neukum
2026-03-12 14:21 ` Alan Stern
2026-03-12 15:57 ` Oliver Neukum
2026-03-13 7:53 ` Michal Pecio
2026-03-13 10:33 ` Oliver Neukum
2026-03-13 15:28 ` Alan Stern
2026-03-13 22:45 ` Thinh Nguyen
2026-03-14 2:39 ` Alan Stern
2026-03-16 12:58 ` Oliver Neukum
2026-03-16 14:02 ` Alan Stern
2026-03-16 14:47 ` Oliver Neukum
2026-03-16 17:33 ` Alan Stern
2026-03-16 19:32 ` Oliver Neukum
2026-03-17 9:05 ` Mathias Nyman
2026-03-17 14:31 ` Alan Stern
2026-03-17 16:20 ` Oliver Neukum
2026-03-17 18:03 ` Alan Stern
2026-03-18 9:54 ` Oliver Neukum
2026-03-18 17:46 ` Alan Stern
2026-03-18 21:38 ` Michal Pecio
2026-03-18 23:59 ` Thinh Nguyen
2026-03-19 2:07 ` Alan Stern
2026-03-19 23:16 ` Thinh Nguyen
2026-03-20 9:58 ` Michal Pecio
2026-03-20 16:20 ` Alan Stern
2026-03-20 17:49 ` Oliver Neukum
2026-03-21 2:14 ` Thinh Nguyen [this message]
2026-03-21 5:54 ` Michal Pecio
2026-03-21 15:58 ` Alan Stern
2026-03-28 21:22 ` Michal Pecio
2026-03-29 1:52 ` Alan Stern
2026-03-29 16:46 ` Michal Pecio
2026-03-30 1:32 ` Alan Stern
2026-03-30 12:36 ` Michal Pecio
2026-04-01 21:50 ` Michal Pecio
2026-04-02 2:20 ` Alan Stern
2026-03-23 10:26 ` Oliver Neukum
2026-03-24 1:06 ` Thinh Nguyen
2026-03-24 9:28 ` Oliver Neukum
2026-03-24 13:25 ` Alan Stern
2026-03-25 1:44 ` Thinh Nguyen
2026-03-19 1:56 ` Alan Stern
2026-03-19 8:40 ` Mathias Nyman
2026-03-19 23:34 ` Thinh Nguyen
2026-03-19 8:55 ` Michal Pecio
2026-03-19 14:24 ` Alan Stern
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=20260321021439.7pmcdrpb5oxbivct@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=bjorn@mork.no \
--cc=linux-usb@vger.kernel.org \
--cc=michal.pecio@gmail.com \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.