public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@kernel.org
To: linux-usb@vger.kernel.org
Subject: [Bug 221184] mouse/keyboard (connected via hub) usb reset under system load with weak cpu
Date: Wed, 11 Mar 2026 09:23:18 +0000	[thread overview]
Message-ID: <bug-221184-208809-MclyuKTjFQ@https.bugzilla.kernel.org/> (raw)
In-Reply-To: <bug-221184-208809@https.bugzilla.kernel.org/>

https://bugzilla.kernel.org/show_bug.cgi?id=221184

--- Comment #37 from Michał Pecio (michal.pecio@gmail.com) ---
(In reply to Liam Mitchell from comment #34)
> In Documentation/driver-api/usb/error-codes.rst:

This documentation is quite old, not necessarily matches evolving landscape,
and nobody is updating it. It's not even entirely clear how to handle the mess.

Discussion on linux-usb from 2024, nothing has changed since then.
https://lore.kernel.org/linux-usb/20241121001138.23a45f6c@foxbook/T/

You may need to read some USB 2.0 spec chapters to understand those things.
8.6: the toggle protocol and retries (usually done by HW)
11.14: the horrors of low/full speed devices behind high speed (also 3.x) hubs
5.3.2: how host HW and SW were envisioned to work together
5.7.5: interrupt endpoint halts due to STALL or "transmission error"

Simple errors (corrupted packet) on bulk/int cause three retries in HW, and
then the HW halts and SW should intervene. USB 2.0 transaction translators
appear to introduce a new problem - the HC failing to fetch interrupt IN data
in time. AFAIU such packet is lost, but the device considers it delivered and
won't resend.

(Not sure how it could happen at all? Maybe DMA too slow? Perhaps Roman's
problem isn't really CPU load but RAM traffic? Not much difference, though.)

If I'm not mistaken, there is no sensible recovery from *this*. The idea was
that SW intervention would use class-specific control requests to learn true
state of the device and put things back in order. And reset toggle on both
ends, which is usb_clear_halt() in Linux.

I don't know how/if the HID spec recommends to deal with errors. Ideally, there
would be a way to query the state of all keys, but maybe there isn't.


Retries are an option too (though AFAIU they can't help with a packet lost in
TT) and xHCI is very helpful and makes them easy, but only if we don't give
back the URB. Maybe we could have a flag to never give back on EPROTO and just
keep hammering until the URB is unlinked (due to disconnection or otherwise).

The alternative is to fully reset the endpoint and clear its toggle state, at
which point the device toggle should be cleared too or there is risk of
silently losing one more packet. That's what xhci-hcd does on every EPIPE *and*
EPROTO.

In theory we could do a "transfer state preserving" reset as if before a retry,
and instead of restarting the endpoint skip the failed URB and proceed to the
next one submitted by the driver. This would match EHCI behavior AFAIU, but
it's gray area - not obviously forbidden, not discussed as an option. Chances
are some xHCI HW would get it wrong. Some HW can't even get basic retries
right. I thought about it but never really tried it.


So existing usbhid behavior seems to risk losing one more packet after EPROTO
on xHCI. You could probably see it - when a key is stuck, it could be necessary
to not only press but also release another key to fix it. Though I admit that I
tried and failed to reproduce this case. It seems I'm still missing some
detail.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

  parent reply	other threads:[~2026-03-11  9:23 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07 11:55 [Bug 221184] New: mouse/keyboard (connected via hub) usb reset under system load with weak cpu bugzilla-daemon
2026-03-07 11:56 ` [Bug 221184] " bugzilla-daemon
2026-03-07 11:58 ` bugzilla-daemon
2026-03-07 16:51 ` bugzilla-daemon
2026-03-07 18:56 ` bugzilla-daemon
2026-03-07 18:57 ` bugzilla-daemon
2026-03-07 19:03 ` bugzilla-daemon
2026-03-07 22:44 ` bugzilla-daemon
2026-03-08  4:24 ` bugzilla-daemon
2026-03-08  5:49 ` bugzilla-daemon
2026-03-08 11:47 ` bugzilla-daemon
2026-03-08 15:02 ` bugzilla-daemon
2026-03-08 15:19 ` bugzilla-daemon
2026-03-08 15:39 ` bugzilla-daemon
2026-03-08 16:16 ` bugzilla-daemon
2026-03-08 21:28 ` bugzilla-daemon
2026-03-09  3:43 ` bugzilla-daemon
2026-03-09  5:04 ` bugzilla-daemon
2026-03-09  5:08 ` bugzilla-daemon
2026-03-09 11:32 ` bugzilla-daemon
2026-03-09 14:13 ` bugzilla-daemon
2026-03-09 15:31 ` bugzilla-daemon
2026-03-09 15:46 ` bugzilla-daemon
2026-03-09 15:58 ` bugzilla-daemon
2026-03-09 16:02 ` bugzilla-daemon
2026-03-09 16:08 ` bugzilla-daemon
2026-03-09 17:24 ` bugzilla-daemon
2026-03-09 18:56 ` bugzilla-daemon
2026-03-09 22:02 ` bugzilla-daemon
2026-03-10  5:31 ` bugzilla-daemon
2026-03-10  5:59 ` bugzilla-daemon
2026-03-10  9:54 ` bugzilla-daemon
2026-03-10 10:09 ` bugzilla-daemon
2026-03-10 14:48 ` bugzilla-daemon
2026-03-10 19:42 ` bugzilla-daemon
2026-03-10 21:41 ` bugzilla-daemon
2026-03-11  8:06 ` bugzilla-daemon
2026-03-11  9:23 ` bugzilla-daemon [this message]
2026-03-11 11:04 ` bugzilla-daemon
2026-03-11 12:54 ` bugzilla-daemon
2026-03-11 14:38 ` bugzilla-daemon
2026-03-11 18:37 ` bugzilla-daemon

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=bug-221184-208809-MclyuKTjFQ@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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