From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB22F309F02 for ; Wed, 17 Sep 2025 14:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758118265; cv=none; b=oy46sxqUTTwAS6vYP0Qw5d0Kevo0ee10kHRESqn3WUTTeBNK2rx+WPpiK7J1zwABAFW8Wq9jLiTChj3cAZOHi2M6nT0KU0jhJGPaTPOnUdmB5gqzTnM/dGYbflOmcesO7okOT51GBg8MxWg+xpG4HDrOdJMbUTBOaVdDdKnV+Y4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758118265; c=relaxed/simple; bh=VrSUNevlSqZ8ycmskyUodqs5OxSIuprhPpTyON2gF24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cmnpoHo21fnF1sdp+NU9l/r/yPDg5pzhCp9AmfjTTrzhzSmupBcNXCgWycXWhdUGiY+05jTCbMewDnAOT8aPiFK73aS0arftVbM1lYWKou22UNiHVuMrB7arXuiDwVItLv+pKe2Qt+bx8JRTJ4oNkXUQVfJqnJP7CzDkc/oZSBQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GwbV1WYm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GwbV1WYm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1789C4CEF0; Wed, 17 Sep 2025 14:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758118265; bh=VrSUNevlSqZ8ycmskyUodqs5OxSIuprhPpTyON2gF24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GwbV1WYmSr/KIkasrxgD5R0/K4WNM+5xw/TghGRXxx6Dka7xGjooYAMSszCXlX0Ax Yc5zt4uBjvEs/Qvs81btH1Nsg5cdS7F0MUfmYMEb//RfguzM3AsRxYPjycahiHMUv0 f4/YdlN1gFNFy2GhbF/dw5+Ni5zdiwZ3xzW4H+kSW4gNvFyl8HkvzoS9Y2ksH1Nn+z IHWdbc18C8qAnZvbAIUTI2R6pVAxvjcHxfsevmvHYeOzEb8KnPpFQWY1ZxSyusDFID Jm27msl4yPza0LssxbRabRLPLgI/8pt8V3F3aoGA1aP0GnYwwz4qWSZ4aijwDFE44X DA6o+LbG+zTvg== From: Sasha Levin To: stable@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.10.y 2/2] xhci: dbc: Fix full DbC transfer ring after several reconnects Date: Wed, 17 Sep 2025 10:11:01 -0400 Message-ID: <20250917141101.578289-2-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250917141101.578289-1-sashal@kernel.org> References: <2025091731-subtotal-outcome-6092@gregkh> <20250917141101.578289-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mathias Nyman [ Upstream commit a5c98e8b1398534ae1feb6e95e2d3ee5215538ed ] Pending requests will be flushed on disconnect, and the corresponding TRBs will be turned into No-op TRBs, which are ignored by the xHC controller once it starts processing the ring. If the USB debug cable repeatedly disconnects before ring is started then the ring will eventually be filled with No-op TRBs. No new transfers can be queued when the ring is full, and driver will print the following error message: "xhci_hcd 0000:00:14.0: failed to queue trbs" This is a normal case for 'in' transfers where TRBs are always enqueued in advance, ready to take on incoming data. If no data arrives, and device is disconnected, then ring dequeue will remain at beginning of the ring while enqueue points to first free TRB after last cancelled No-op TRB. s Solve this by reinitializing the rings when the debug cable disconnects and DbC is leaving the configured state. Clear the whole ring buffer and set enqueue and dequeue to the beginning of ring, and set cycle bit to its initial state. Cc: stable@vger.kernel.org Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver") Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20250902105306.877476-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-dbgcap.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 43106b5840b2d..64fdaf468eda1 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -447,6 +447,25 @@ static void xhci_dbc_ring_init(struct xhci_ring *ring) xhci_initialize_ring_info(ring, 1); } +static int xhci_dbc_reinit_ep_rings(struct xhci_dbc *dbc) +{ + struct xhci_ring *in_ring = dbc->eps[BULK_IN].ring; + struct xhci_ring *out_ring = dbc->eps[BULK_OUT].ring; + + if (!in_ring || !out_ring || !dbc->ctx) { + dev_warn(dbc->dev, "Can't re-init unallocated endpoints\n"); + return -ENODEV; + } + + xhci_dbc_ring_init(in_ring); + xhci_dbc_ring_init(out_ring); + + /* set ep context enqueue, dequeue, and cycle to initial values */ + xhci_dbc_init_ep_contexts(dbc); + + return 0; +} + static struct xhci_ring * xhci_dbc_ring_alloc(struct device *dev, enum xhci_ring_type type, gfp_t flags) { @@ -871,7 +890,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) dev_info(dbc->dev, "DbC cable unplugged\n"); dbc->state = DS_ENABLED; xhci_dbc_flush_requests(dbc); - + xhci_dbc_reinit_ep_rings(dbc); return EVT_DISC; } @@ -881,7 +900,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) writel(portsc, &dbc->regs->portsc); dbc->state = DS_ENABLED; xhci_dbc_flush_requests(dbc); - + xhci_dbc_reinit_ep_rings(dbc); return EVT_DISC; } -- 2.51.0