public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Pecio <michal.pecio@gmail.com>
To: Oliver Neukum <oneukum@suse.com>
Cc: "Alan Stern" <stern@rowland.harvard.edu>,
	"Bjørn Mork" <bjorn@mork.no>,
	"USB list" <linux-usb@vger.kernel.org>
Subject: Re: correctly handling EPROTO
Date: Fri, 13 Mar 2026 08:53:54 +0100	[thread overview]
Message-ID: <20260313085354.71a6dbf1.michal.pecio@gmail.com> (raw)
In-Reply-To: <64dc9c5d-d662-41e3-898f-71587b940a2c@suse.com>

On Thu, 12 Mar 2026 16:57:18 +0100, Oliver Neukum wrote:
> On 12.03.26 15:21, Alan Stern wrote:
>   
> > There's a discussion about the same issue here:
> > 
> > 	https://bugzilla.kernel.org/show_bug.cgi?id=221184
> > 
> > See especially the later parts, starting with comment #28.  
> 
> Well, that is fascinating, but not necessarily in a comfortable
> way. It seems to me that for all drivers to care about the
> exact details of getting which toggle back into sync is not
> a viable strategy. This I'd say, when in doubt, clear a halt.

The official USB philosophy appears to be:
- remove any remaining URBs from the endpoint
- clear halt (even if not halted)
- use class control requests to bring the HW and SW to a valid state
- submit new URBs

Some thoughts:

1. Giving up on EPROTO may be overly pessimistic. Bit flips happen.

   But EPROTO may also mean disconnection. Parent hub should notice,
   then disconnect() will be called at some point and usb_submit_urb()
   will begin returning ENODEV.

   Some cable failures cause persistent EPROTO without disconnection
   being detected, e.g. D+ or D- discontinuity at low or full speed.

2. The idea that a driver can retry a transfer by resubmitting the
   failed URB encounters certain problems.

 a Resubmitting a multi-packet URB is tricky - part of it may have
   already been transferred, so the URB may need to be modified.

 b With transaction translators (LS/FS behind a HS hub) one IN packet
   may already be lost forever when you see the first EPROTO. The
   interrupt case seems impossible to fix due to HW timings. Fixing the
   bulk case would take actions different than ordinary URB submission.
   No API nor EHCI support seems to exist, xHCI can't do it at all.

   Note: even a high-speed capable device may sometimes work like that.

 c If you usb_clear_halt() before resubmitting, a previously delivered
   packet may be resent and accepted again (if its ACK was lost). Both
   IN and OUT seem potentially affected. Some classe may not care.

3. EHCI/OHCI/UHCI can do proper retries, except case 2b, simply by
   resubmitting while minding points 2a and 2c (so no clear halt).

   The same action on xHCI currently results in 50% chance of the next
   packet being dropped by HW and the URB waiting for another packet.

   Tricking xHCI to behave like EHCI is uncharted territory. It seems
   to stray away from offical USB recommendations.

4. xHCI can support retries cleanly and painlessly (except for the
   impossible case of TT) if the URB isn't given back or is given back
   with the understanding that it is still present in the HW queue and
   can only be unlinked or resumed at the point it got stuck. Issues:

 a No API exists for either option. However, a few retries are already
   made before completing with EPROTO status (except for TT).

 b This doesn't work 100% right and is disabled on some controllers.

5. If you have more URBs queued in advance, you may encounter bugs due
   to race conditions (or outright broken logic in case of xHCI).


Summary:

Retrying may or may not be productive - see 1.

Drivers written for EHCI encounter problems on xHCI - see 3.

Existing API is awkward/insufficient for retries - see 2a and 4.

In certain cases retries are impossible anyway - see 2b and 4b.
Extra work by class specific means is inevitable. See "USB philosophy".

Regards,
Michal



  reply	other threads:[~2026-03-13  7:54 UTC|newest]

Thread overview: 42+ 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 [this message]
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
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-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=20260313085354.71a6dbf1.michal.pecio@gmail.com \
    --to=michal.pecio@gmail.com \
    --cc=bjorn@mork.no \
    --cc=linux-usb@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox