From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 60B933DD851; Tue, 16 Jun 2026 19:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636904; cv=none; b=ILWoPXFg2TD8bEB1NW4bwKBtCn7lffshYGi9veSqC0r3CrgdQ5B6iVxj1Ya8yEPfkxbkS/uLEcnBCfIZTqImY+vB+yGC9TXkxQY8A3+8kIDfEdvf+CcWkRg8QhwpEX77zVKHW4AjxRsaJct2dO8iJOc90IYMsXDpCneS+9CvFVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636904; c=relaxed/simple; bh=DhGBUJe5wD1AmL1hqAe3+A98cW0XGM3m9L4n6F6dHmU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cPvDwklyfdApldPoMNo949o9kUhfCjtIgHVIX8XAA3SLZkGWKDnXTQzGLRsYW2r7xVadRBQkpmO3X42SI6NTeTwQWi+1fBBkiNWvbc+8JUenSI3W0hrdnhdatoK0wIzbuCr7NHJT2jRz59/gREthtzrtyAJB4wHQkqpbSDxwzH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ufr/SlU4; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ufr/SlU4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 321381F000E9; Tue, 16 Jun 2026 19:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781636903; bh=M4i3Z6hid9SULvLBqJs91IyrThiJW4qAbeVmcQBbbkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ufr/SlU4gtPDgvl0GFq0QY2qDFg5Rds29hrKnzpxHb3njIQUCB8ZyX3epaI5QC5E0 i2j4OAUPwl2OhidhmlcNj/QCfreZHL3+vV+sOg6ouxFbvMfVmxdPT+XBb4lHFI9EuH iEtT3u1DgxJtPesu6W89etnjiaID5Cc1iXKB5iDo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Peter Chen , Yongchao Wu , Sasha Levin Subject: [PATCH 5.10 320/342] usb: cdns3: gadget: fix request skipping after clearing halt Date: Tue, 16 Jun 2026 20:30:16 +0530 Message-ID: <20260616145103.462766973@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yongchao Wu [ Upstream commit c8778ff817a7047d6848fefba99dcb27b1bf01fe ] According to the cdns3 datasheet, the EPRST (Endpoint Reset) command causes the DMA engine to reposition its internal pointer to the next Transfer Descriptor (TD) if it was already processing one. This issue is consistently observed during the ADB identification process on macOS hosts, where the host issues a Clear_Halt. Although commit 4bf2dd65135a ("usb: cdns3: gadget: toggle cycle bit before reset endpoint") attempted to avoid DMA advance by toggling the cycle bit, trace logs show that on certain hosts like macOS, the DMA pointer (EP_TRADDR) still shifts after EPRST: cdns3_ctrl_req: Clear Endpoint Feature(Halt ep1out) cdns3_doorbell_epx: ep1out, ep_trbaddr f9c04030 <-- Should be f9c04000 cdns3_gadget_giveback: ep1out: req: ... length: 16384/16384 As shown above, the DMA pointer jumped to the next TD, causing the controller to skip the initial TRBs of the request. This leads to data misalignment and ADB protocol hangs on macOS. Fix this by manually restoring the EP_TRADDR register to the starting physical address of the current request after the EPRST operation is complete. Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") Cc: stable Cc: Peter Chen Signed-off-by: Yongchao Wu Acked-by: Peter Chen Link: https://patch.msgid.link/20260513160012.2547894-1-yongchao.wu@autochips.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/gadget.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -2798,9 +2798,19 @@ int __cdns3_gadget_ep_clear_halt(struct priv_ep->flags &= ~(EP_STALLED | EP_STALL_PENDING); if (request) { - if (trb) + if (trb) { *trb = trb_tmp; + /* + * Per datasheet, EPRST causes DMA to reposition to the next TD. + * Manually reset EP_TRADDR to the current TRB to prevent + * the hardware from skipping the interrupted request. + */ + writel(EP_TRADDR_TRADDR(priv_ep->trb_pool_dma + + priv_req->start_trb * TRB_SIZE), + &priv_dev->regs->ep_traddr); + } + cdns3_rearm_transfer(priv_ep, 1); }