All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Michal Pecio <michal.pecio@gmail.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: "Oliver Neukum" <oneukum@suse.com>,
	"Thinh Nguyen" <Thinh.Nguyen@synopsys.com>,
	"Bjørn Mork" <bjorn@mork.no>,
	"USB list" <linux-usb@vger.kernel.org>
Subject: Re: correctly handling EPROTO
Date: Wed, 18 Mar 2026 23:59:21 +0000	[thread overview]
Message-ID: <20260318235920.ioek26hdr25rkksp@synopsys.com> (raw)
In-Reply-To: <20260318223851.1f6d07d7.michal.pecio@gmail.com>

On Wed, Mar 18, 2026, Michal Pecio wrote:
> On Wed, 18 Mar 2026 13:46:26 -0400, Alan Stern wrote:
> > On Wed, Mar 18, 2026 at 10:54:20AM +0100, Oliver Neukum wrote:
> > > On 17.03.26 19:03, Alan Stern wrote:
> > > > You know, with a USB-2 host controller, transaction errors don't
> > > > make an endpoint unusable, and clear-halt isn't necessary.
> 
> Depends on what you mean by "usable". If you get EPROTO reading from
> a Transaction Translator and the TT discards the packet (because of
> timeout on Int or by explicit SW request on Bulk) then not only is the
> particular packet lost because the device got its ACK and moved on, but
> I suspect the next packet will be dropped too due to toggle mismatch.
> 
> Granted, EPROTO outside of disconnections is apparently rare enough
> that a horde of users demanging this to be fixed hasn't materialized.

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 found simple ways to produce recoverable EPROTO at low/full speed,
> but no such luck with higher speeds so far. It would be helpful.

Get a bad cable, that should help triggering transaction errors. Back
when I was doing more hardware testing, we were able to trigger this
more easily when testing BOT and UAS devices behind certain hubs and
docks.

> 
> > > > I wonder if xhci-hcd couldn't be adjusted to behave the same way
> > > > (issuing its own clear-halt internally, if that is needed). That
> > > > would make things simpler.
> > > 
> > > It could be. But do you want a HCD to generate requests to endpoint
> > > 0 on its own without coordination with usbcore or drivers bound to
> > > interfaces of the device?
> 
> I believe the intent is to maintain the illusion that drivers can just
> resubmit the failed URB and have that become a proper retry.
> 
> It likely could be done, but it's still not the same thing as old HCDs
> are doing because it opens the possibility of double delivery, while
> closing the possibility of further packet loss speculated about above.
> 
> Question is if this illusion is worth fighting for, when
> 1. it hasn't been 100% reliable since at least USB 2.0 and TTs
> 2. USB-IF keeps creating problems for software trying to be like that
> 3. xhci-hcd has been this mess for 15 years without loud complaints
> 
> What should an HCD do if such request fails? Just refuse URBs?
> 
> > Michal should be the person to answer these questions.  I guess that
> > a clear-halt is necessary for synchronizing an xHCI host controller
> > with the device's endpoint after an error, but I don't really know.
> > Maybe it's necessary only for USB-3 devices?
> 
> Strictly, it's the opposite - synchronize the device with the host
> having already zeroed its toggle or SuperSpeed sequence number.
> 
> Such toggle mismatch at USB2 speeds results in loss of next packet.
> 
> AFAIU, SuperSpeed sequence mismatch is covered by USB3 8.11, which says
> "discard with no response", so maybe we would keep getting EPROTO due
> to timeouts while wrong number is being retried, but not sure.
> 
> Resetting host sequence state is not mandatory, but the alternative is
> intended for retrying the same URB, not another identical one. That
> would be an edge case possibly exercised by no SW other than Linux.
> 

The retrying of the URB or sending a new set of URBs should be a
decision by the class driver where synchronization at the higher
protocol may be needed. An URB failed with -EPROTO may mean some
previous successful transfers need to be discarded and retried also.

What we do know is that an -EPROTO means that the xhci endpoint state
was halted, the xhci would need to reset (not soft retry) the endpoint
before it can be used again. Since the bulk sequence is reset from reset
ep command, we'd need clear-halt to synchronize with the device side.
The reset ep command behavior (and when to use it) is xhci specific, so
IMHO, it should the xhci driver to handle the clear-halt. Which URB(s)
need to be retried should be a decision by the upperlayer drivers.

BR,
Thinh

  reply	other threads:[~2026-03-18 23:59 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 [this message]
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
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=20260318235920.ioek26hdr25rkksp@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.