All of lore.kernel.org
 help / color / mirror / Atom feed
From: Henry Tseng <henrytseng@qnap.com>
To: Michal Pecio <michal.pecio@gmail.com>
Cc: Henry Tseng <henrytseng@qnap.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: xhci: return an error if the host is not halted
Date: Fri,  4 Sep 2026 18:08:17 +0800	[thread overview]
Message-ID: <20260904100818.6752-1-henrytseng@qnap.com> (raw)
In-Reply-To: <20260902135016.19d4c3fa.michal.pecio@gmail.com>

On Wed, 2 Sep 2026 13:50:16 +0200, Michal Pecio <michal.pecio@gmail.com> wrote:
> That's probably how it should be, but I wonder how did you find this
> bug and are you aware of any cases where it makes a difference?

I noticed it while debugging a downstream kernel (based on v6.6) for
an embedded NAS platform, which carries an xHC error recovery routine
doing the same sequence as the reset_registers path in xhci_resume().

Since the NAS platform doesn't run a mainline kernel easily, I did the
testing on a separate machine. On this machine (Intel Meteor Lake-P
xHC, 8086:7e7d) STS_HALT is set by the time xhci_resume() runs, so I
added a fault injection flag to xhci_reset() on mainline to force the
abort path, making it return 0 without doing the reset. Resume then
restarts the HCD on a host that was never reset. Every command
afterwards times out and gets aborted, and devices loop on failed
re-enumeration for minutes:

  [  100.109411] xhci_hcd 0000:00:14.0: Host controller not halted, aborting reset.
  [  100.110025] xhci_hcd 0000:00:14.0: Start the primary HCD
  [  100.110132] xhci_hcd 0000:00:14.0: Start the secondary HCD
  [  100.194666] xhci_hcd 0000:00:14.0: The device to be reset with slot ID 0 does not exist. Re-allocate the device
  [  107.573055] xhci_hcd 0000:00:14.0: Error while assigning device slot ID: Command Aborted
  [  107.573059] xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 64.
  ...
  [  259.125506] xhci_hcd 0000:00:14.0: Error while assigning device slot ID: Command Aborted
  [  259.125509] xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 64.
  [  259.548200] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with unaddressed device
  [  259.549751] xhci_hcd 0000:00:14.0: xHCI xhci_free_dev called with unaddressed device

On the test machine I couldn't reproduce the not-halted case through a
normal xhci_suspend()/xhci_resume() cycle. But the reset_registers path
is taken exactly when the host state is not trusted (power lost, broken
suspend, HCE, RESET_ON_RESUME), so making sure xhci_reset() actually
completed seems right regardless.

> There is apparently one caller (xhci_resume()) which cares about
> xhci_reset() return value but not about the preceding xhci_halt().

Yes, xhci_resume() is exactly the caller I had in mind. Since it doesn't
check xhci_halt(), the reset return value is the only thing standing
between a host that failed to halt and the reinit.

Thanks,
Henry

      reply	other threads:[~2026-09-04 10:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 10:15 [PATCH] usb: xhci: return an error if the host is not halted Henry Tseng
2026-09-02 11:50 ` Michal Pecio
2026-09-04 10:08   ` Henry Tseng [this message]

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=20260904100818.6752-1-henrytseng@qnap.com \
    --to=henrytseng@qnap.com \
    --cc=gregkh@linuxfoundation.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 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.