From: Oliver Neukum <oneukum@suse.com>
To: Michal Pecio <michal.pecio@gmail.com>, Julian Oes <julian@oes.ch>
Cc: oneukum@suse.com, gregkh@linuxfoundation.org, johan@kernel.org,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] USB: serial: generic: recover from a stalled bulk-in endpoint
Date: Wed, 2 Sep 2026 10:40:36 +0200 [thread overview]
Message-ID: <51d22cfc-eb16-41cc-b27f-3bdad4460463@suse.com> (raw)
In-Reply-To: <20260902064204.1a47cd73.michal.pecio@gmail.com>
On 02.09.26 06:42, Michal Pecio wrote:
> On Wed, 2 Sep 2026 11:13:53 +1200, Julian Oes wrote:
>> On Tue, Sep 01, 2026 at 10:28:08AM +0200, Oliver Neukum wrote:
> What you are probably seeing is USB 2.0 hub(s) returning STALL
> handshake when a transaction attempt with downstream low/full-speed
> device fails three times. See USB 2.0 section 11.17.1 page 364.
Nasty.
> If that's the case, the device endpoint isn't actually halted and you
> would see the traffic resume if you simply ignored the error and kept
> resubmitting until communication is restored.
>
> That being said, calling usb_clear_halt() is indeed the only recovery
> supported by USB specs, both for -EPIPE and -EPROTO or similar. Linux
> has traditionally ignored this and things are quite broken sometimes,
> particularly with xhci-hcd, even if you call usb_clear_halt().
I think our record is better with -EPIPE.
The question is what we have to lose. Frankly, compared to the
status quo, nothing.
[..]
I don't have popcorn, but I do have cooled, sugar-free beverages ready.
> It seems there is only one risk of usb_clear_halt() in such cases:
> - you send a packet to an OUT endpoint
> - and the device accepts it but you never receive the ACK
> - even after re-sending three times
> - you call usb_clear_halt() and queue the same packet again
> - the device may accept the packet twice
I am afraid this is the time to be pedantic, because I don't
see the connection to usb_clear_halt().
The fundamental disagreement is on whether a packet has arrived
or not, isn't it? So the fundamental issue is whether IO should
be retried, not whether you clear a halt in between.
If you guess wrong you either transmit data twice or not at all.
And there is no generic mechanism to remedy that. Do you have
a proposal how one would look like?
However, eventually new data will need to be transmitted
or the device queried for newly received data. If that is to work,
we'll need to, well, do IO.
Our choices are whether
a) we retry IO before we do so
b) whether we try to clear a halt before that
Technically these decisions are independent of one another.
However, the spec says that we should clear a halt.
So I need to ask: Is there a situation in which we would
make matters worse by clearing the halt?
> One note about rate limiting: it would perhaps make sense to perform
> the first attempt ASAP and only slow down for retries. But arguably
> anything at all is better than just giving up like now.
And again, you make me ask whether a helper for that should
go into usbcore.
Regards
Oliver
next prev parent reply other threads:[~2026-09-02 8:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 3:49 [PATCH v2] USB: serial: generic: recover from a stalled bulk-in endpoint Julian Oes
2026-09-01 4:33 ` Greg Kroah-Hartman
2026-09-01 22:44 ` Julian Oes
2026-09-01 8:28 ` Oliver Neukum
2026-09-01 23:13 ` Julian Oes
2026-09-02 4:42 ` Michal Pecio
2026-09-02 8:40 ` Oliver Neukum [this message]
2026-09-02 14:33 ` 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=51d22cfc-eb16-41cc-b27f-3bdad4460463@suse.com \
--to=oneukum@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=julian@oes.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michal.pecio@gmail.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