From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
stable <stable@kernel.org>
Subject: [PATCH 1/5] xhci: keep port link_inactive and connected flags in sync when polled
Date: Thu, 5 Nov 2026 19:51:02 +0200 [thread overview]
Message-ID: <20261105175106.241182-2-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20261105175106.241182-1-mathias.nyman@linux.intel.com>
Update port 'link_inactive' and 'connected' flags even if xHC isn't
generating port change events.
xHC only generates port change events on port changes after old port
change bits are cleared. Hub driver is often kept up to date
by polling the port status.
Sashiko reported a possible case where all port changes after a port
reset take place before hub driver clears the reset change bit.
This way the port can end up connected and fully running with link
in u0 without a port event clearing the 'link_inactive' or setting
the 'connected' flags.
A protocol STALL in this state would set EP_DROP_PENDING, and
prevent all future URBs for the endpoint.
Fix this by also updating the flags during get_port_status(), when
hub driver is polling the port state.
Fixes: 6895dbdc19d9 ("xhci: give back TDs and clean up ep0 after disconnect")
Link: https://lore.kernel.org/linux-usb/sashiko-outbox-190046@kernel.org/
Cc: stable <stable@kernel.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-hub.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 470bafe1802b..55430b673f1e 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1166,6 +1166,12 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, struct xhci_bus_state *bus_
if (portsc & PORT_RESET)
status |= USB_PORT_STAT_RESET;
+ /* track connect and link error status when hub is polling */
+ if (!(portsc & PORT_RESET)) {
+ port->link_inactive = (portsc & PORT_PLS_MASK) == XDEV_INACTIVE;
+ port->connected = !!(portsc & PORT_CONNECT);
+ }
+
/* USB2 and USB3 specific bits, including Port Link State */
if (hcd->speed >= HCD_USB3)
xhci_get_usb3_port_status(port, &status, portsc);
--
2.43.0
next prev parent reply other threads:[~2026-11-05 17:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 17:51 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
2026-11-05 17:51 ` Mathias Nyman [this message]
2026-11-05 17:56 ` [PATCH 1/5] xhci: keep port link_inactive and connected flags in sync when polled sashiko-bot
2026-11-06 8:15 ` Xu Yang
2026-11-05 17:51 ` [PATCH 2/5] usb: xhci: disable the correct slot on alloc_dev failure Mathias Nyman
2026-11-05 18:06 ` sashiko-bot
2026-11-05 17:51 ` [PATCH 3/5] usb: pci-quirks: always assert xHCI OS ownership Mathias Nyman
2026-11-05 17:54 ` sashiko-bot
2026-11-05 17:51 ` [PATCH 4/5] usb: xhci: clear stale bandwidth data after hibernation Mathias Nyman
2026-11-05 17:56 ` sashiko-bot
2026-11-05 17:51 ` [PATCH 5/5] usb: xhci: fix 'num_active_eps' accounting on allocation failure Mathias Nyman
2026-11-05 17:55 ` sashiko-bot
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=20261105175106.241182-2-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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