From: "Peter Chen (CIX)" <peter.chen@kernel.org>
To: Yongchao Wu <yongchao.wu@autochips.com>
Cc: pawell@cadence.com, rogerq@kernel.org,
gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: cdns3: gadget: fix request skipping after clearing halt
Date: Thu, 14 May 2026 09:45:37 +0800 [thread overview]
Message-ID: <agUpQURk02hAYz2Z@nchen-desktop> (raw)
In-Reply-To: <20260513160012.2547894-1-yongchao.wu@autochips.com>
On 26-05-14 00:00:12, Yongchao Wu wrote:
> 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@vger.kernel.org
> Cc: Peter Chen <peter.chen@kernel.org>
> Signed-off-by: Yongchao Wu <yongchao.wu@autochips.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Peter
> ---
> Changes in v2:
> - Clarified in description that the DMA pointer jumps to the next TD,
> skipping the entire request.
> - No code changes.
> ---
> drivers/usb/cdns3/cdns3-gadget.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index d59a60a16ec770..96653c7d18f202 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2814,9 +2814,19 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
> 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);
> }
>
>
> base-commit: 46b513250491a7bfc97d98791dbe6a10bcc8129d
> --
> 2.43.0
>
--
Best regards,
Peter
prev parent reply other threads:[~2026-05-14 1:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 16:06 [PATCH] usb: cdns3: gadget: fix request skipping after clearing halt Yongchao Wu
2026-04-27 1:22 ` Peter Chen (CIX)
2026-04-27 9:01 ` Pawel Laszczak
2026-04-27 22:59 ` Peter Chen (CIX)
2026-04-27 23:59 ` Yongchao Wu
2026-04-28 9:58 ` Pawel Laszczak
2026-04-28 14:48 ` Yongchao Wu
2026-05-04 9:15 ` Pawel Laszczak
2026-05-06 9:27 ` [PATCH] usb: cdns3: gadget: fix request skipping after clearing halt Yongchao Wu
2026-05-13 16:00 ` [PATCH v2] " Yongchao Wu
2026-05-14 1:45 ` Peter Chen (CIX) [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=agUpQURk02hAYz2Z@nchen-desktop \
--to=peter.chen@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=rogerq@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yongchao.wu@autochips.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.