mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Michal Pecio <michal.pecio@gmail.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: xhci: Assume that endpoints halt as specified
Date: Tue, 11 Nov 2025 14:13:05 +0200	[thread overview]
Message-ID: <a5119a19-8660-4f0c-bedd-0a9a0301ef85@linux.intel.com> (raw)
In-Reply-To: <20251107111317.69be45a5.michal.pecio@gmail.com>

On 11/7/25 12:13, Michal Pecio wrote:
> xHCI 4.8.3 recommends that software should simply assume endpoints to
> halt after certain events, without looking at the Endpoint Context for
> confirmation, because HCs may be slow to update that.
> 
> While no cases of such "slowness" appear to be known, different problem
> exists on AMD Promontory chipsets: they may halt and generate a transfer
> event, but fail to ever update the Endpoint Context at all, at least not
> until some command is queued and fails with Context State Error. This is
> easily triggered by disconnecting D- of a full speed serial device.
> 
> Possibly similar bug in non-AMD hardware has been reported to linux-usb.
> 
> In such case, failed TD is given back without erasing from the ring and
> endpoint isn't reset. If some URB is unlinked later, Stop Endpoint fails
> and its handler resets the endpoint. On next submission it will restart
> on the stale TD. Outcome is UAF on success, or another halt on error and
> then Dequeue doesn't move and URBs are stuck. Unlinking and resubmitting
> the URBs causes unlimited ring expansion if the situation repeats.
> 
> This can be solved by ignoring Endpoint Context State and trusting that
> endpoints halt when required, except one known case in ancient hardware.
> The check for "Already resolving halted ep" becomes redundant, because
> for these completion codes we now jump to xhci_handle_halted_endpoint()
> which deals with pending EP_HALTED internally.
> 
> Link: https://lore.kernel.org/linux-usb/20250311234139.0e73e138@foxbook/
> Link: https://lore.kernel.org/linux-usb/20250918055527.4157212-1-zhangjinpeng@kylinos.cn/
> Signed-off-by: Michal Pecio <michal.pecio@gmail.com>

Makes sense, I guess we can only trust hardware to update the state in
the endpoint context on specific command completions, not transfer events.

Added to queue, thanks
Mathias


  reply	other threads:[~2025-11-11 12:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 10:13 Michal Pecio
2025-11-11 12:13 ` Mathias Nyman [this message]
2025-11-14 12:32   ` Michal Pecio

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=a5119a19-8660-4f0c-bedd-0a9a0301ef85@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --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

all inboxes | Powered by JetHome®