Linux USB
 help / color / mirror / Atom feed
From: Kuangyi Chiang <ki.chiang65@gmail.com>
To: mathias.nyman@intel.com, gregkh@linuxfoundation.org
Cc: michal.pecio@gmail.com, stern@rowland.harvard.edu,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	ki.chiang65@gmail.com
Subject: [PATCH v2] xhci: Handle missing USB2 resume events on Etron hosts
Date: Fri, 27 Nov 2026 09:54:07 +0800	[thread overview]
Message-ID: <20261127015407.3937-1-ki.chiang65@gmail.com> (raw)

On Etron xHCs, a USB2 remote wakeup may also move other suspended
USB2 ports into the resume state without generating individual Port
Status Change Events.

The issue can be reproduced as follows:

1. Disable autosuspend for the USB2 root hub by setting its
   power/control to "on".
2. Connect two USB2 hubs to the Etron xHC.
3. Wait for both USB2 hubs to autosuspend.
4. Connect a mouse to one of the USB2 hubs.
5. Connect another mouse to the other hub. The second mouse
   does not work.

The affected USB2 ports may remain in the resume state, preventing
newly connected devices from enumerating. Reconnecting an affected
hub or mouse does not help. Reloading the xHCI driver restores
normal operation.

When handling a USB2 resume event on an Etron xHC, check whether
other USB2 ports are also in the resume state and track them so
normal resume handling can complete.

Before the patch, the root hub status bitmap reported only port 2
(evt 0004), leaving port 1 in the resume state.

[ 4928.200011] xhci_hcd 0000:02:00.0: Port change event, 5-2, id 2, portsc: 0x400fe3
[ 4928.200087] xhci_hcd 0000:02:00.0: port resume event for port 2
[ 4928.200095] xhci_hcd 0000:02:00.0: resume HS port 2
[ 4928.241196] hub 5-0:1.0: state 7 ports 4 chg 0000 evt 0004
[ 4928.369244] usb usb5-port2: resume, status 0

After the patch, the bitmap includes both ports (evt 0006), allowing
port 1 to complete the normal resume process.

[ 6277.946923] xhci_hcd 0000:02:00.0: Port change event, 5-2, id 2, portsc: 0x400fe3
[ 6277.946998] xhci_hcd 0000:02:00.0: port resume event for port 2
[ 6277.947005] xhci_hcd 0000:02:00.0: resume HS port 2
[ 6277.947013] xhci_hcd 0000:02:00.0: HS port 1 in resume without event, portsc: 0xfe3
[ 6277.987265] hub 5-0:1.0: state 7 ports 4 chg 0000 evt 0006
[ 6278.010733] usb usb5-port1: resume, status 0
[ 6278.145273] usb usb5-port2: resume, status 0

Tested on Etron EJ168 (1b6f:7023) and EJ188 (1b6f:7052) with root hub
autosuspend disabled.

Signed-off-by: Kuangyi Chiang <ki.chiang65@gmail.com>
---
Changes in v2:
- Update the reproduction steps and logs in the commit message.
  The issue can be reproduced with root hub autosuspend disabled,
  as reported by Michal Pecio.
- No code changes.
- Link to v1: https://lore.kernel.org/all/20261123072320.5967-1-ki.chiang65@gmail.com/

 drivers/usb/host/xhci-ring.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index fffd901..c640952 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1997,6 +1997,39 @@ static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci)
 	} while (!(pll_lock_check & 0x1) && --retry_count);
 }
 
+/*
+ * Etron xHCs may resume other suspended USB2 ports without generating
+ * individual Port Status Change Events. Track those ports so the normal
+ * USB2 resume handling can finish.
+ */
+static void xhci_handle_etron_usb2_resume(struct xhci_hcd *xhci)
+{
+	struct xhci_hub *rhub = &xhci->usb2_rhub;
+	struct xhci_bus_state *bus_state = &rhub->bus_state;
+	struct xhci_port *port;
+	unsigned int i;
+	u32 portsc;
+
+	for (i = 0; i < rhub->num_ports; i++) {
+		if (test_bit(i, &bus_state->resuming_ports))
+			continue;
+
+		port = rhub->ports[i];
+		portsc = xhci_portsc_readl(port);
+		if ((portsc & PORT_RESET) || !(portsc & PORT_PE))
+			continue;
+
+		if ((portsc & PORT_PLS_MASK) == XDEV_RESUME) {
+			xhci_dbg(xhci, "HS port %d in resume without event, portsc: 0x%x\n",
+				 port->hw_portnum + 1, portsc);
+			port->resume_timestamp = jiffies +
+				msecs_to_jiffies(USB_RESUME_TIMEOUT);
+			set_bit(i, &bus_state->resuming_ports);
+			usb_hcd_start_port_resume(&rhub->hcd->self, i);
+		}
+	}
+}
+
 static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
 {
 	struct xhci_virt_device *vdev = NULL;
@@ -2103,6 +2136,8 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
 			mod_timer(&hcd->rh_timer,
 				  port->resume_timestamp);
 			usb_hcd_start_port_resume(&hcd->self, hcd_portnum);
+			if (xhci->quirks & XHCI_ETRON_HOST)
+				xhci_handle_etron_usb2_resume(xhci);
 			bogus_port_status = true;
 		}
 	}
-- 
2.25.1


             reply	other threads:[~2026-11-27  1:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  1:54 Kuangyi Chiang [this message]
2026-11-27  1:59 ` [PATCH v2] xhci: Handle missing USB2 resume events on Etron hosts 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=20261127015407.3937-1-ki.chiang65@gmail.com \
    --to=ki.chiang65@gmail.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 \
    --cc=stern@rowland.harvard.edu \
    /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