From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Selvarasu Ganesan <selvarasu.g@samsung.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jh0801.jung@samsung.com" <jh0801.jung@samsung.com>,
"dh10.jung@samsung.com" <dh10.jung@samsung.com>,
"akash.m5@samsung.com" <akash.m5@samsung.com>,
"hongpooh.kim@samsung.com" <hongpooh.kim@samsung.com>,
"eomji.oh@samsung.com" <eomji.oh@samsung.com>,
"h10.kim@samsung.com" <h10.kim@samsung.com>,
"shijie.cai@samsung.com" <shijie.cai@samsung.com>,
"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
"muhammed.ali@samsung.com" <muhammed.ali@samsung.com>,
"thiagu.r@samsung.com" <thiagu.r@samsung.com>,
"pritam.sutar@samsung.com" <pritam.sutar@samsung.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v3] usb: dwc3: gadget: Prevent EP resource conflicts during StartTransfer
Date: Wed, 7 Oct 2026 02:06:36 +0000 [thread overview]
Message-ID: <asWmW1jmzedIV5SP@vbox> (raw)
In-Reply-To: <3fdda532-8181-48e9-b58d-cad7289408e7@samsung.com>
On Tue, Oct 06, 2026, Selvarasu Ganesan wrote:
>
> > /* Clear out the ep descriptors for non-ep0 */
> > @@ -1792,9 +1815,9 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
> >
> > dep->resource_index = 0;
> >
> > - if (!interrupt)
> > + if (!interrupt || ret)
>
>
> Hi Thinh,
>
> Thanks for your code changes. The given code changes look good to me and
> are working as expected.
>
> There is one more concern about an uncovered endpoint resource failure
> in some corner cases where END TRANSFER timeout is observed (ret = -110).
>
> The sequence is explained below,
>
> Step 1:
> __dwc3_gadget_ep_set_halt(dep, value=0)
> ->dwc3_stop_active_transfer(dep, true, true)
Looks like you still do ForceRM=true. Can you apply this patch:
b58e6200450d ("usb: dwc3: clear forceRM when issuing EndTransfer")
> ->END(e.g, ep2out, resource_index=7) issued, but timeout occurs
> -> resource_index cleared to 0
> ->dwc3_send_clear_stall_ep_cmd(dep)
> -> failed to clear STALL on ep2out
>
>
> Step 2:
> __dwc3_gadget_ep_set_halt(dep, value=0) ->Re triggered clear stall for
> same EP
> -> dwc3_stop_active_transfer(dep, true, true)
> -> END(ep2out, resource_index=0) issued (wrong resource!)
> -> Command succeeds, DWC3_EP_TRANSFER_STARTED cleared in
> completion handler
>
> Step 3:
> usb_ep_queue()
> -> dwc3_gadget_ep_queue()
> -> __dwc3_gadget_kick_transfer()
> -> starting = !(dep->flags & DWC3_EP_TRANSFER_STARTED) -> starting=0
> -> Issues STARTTRANSFER (because DWC3_EP_TRANSFER_STARTED is not
> set)
> -> Hardware rejects with NO_RESOURCE (resource 7 still held)
>
>
> Could you please give your suggestions on this issue case?
>
Thanks for testing. Can you check whether the End Transfer command ever
completes with the endpoint completion event after the -ETIMEDOUT error?
Try with the below.
Thanks,
Thinh
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 1f973e546219..bac0328423cd 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1819,7 +1819,11 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
dep->resource_index = 0;
- if (!interrupt || ret)
+ if (!interrupt || (ret && ret != -ETIMEDOUT))
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
else
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
@@ -3895,6 +3899,8 @@ static void dwc3_gadget_endpoint_command_complete(struct dwc3_ep *dep,
if (dep->stream_capable)
dep->flags |= DWC3_EP_IGNORE_NEXT_NOSTREAM;
+ dep->flags &= ~DWC3_EP_DELAY_STOP;
dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING;
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
dwc3_gadget_ep_cleanup_cancelled_requests(dep);
next prev parent reply other threads:[~2026-10-07 2:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260227121338epcas5p4baebb406db37f07223545b2f85751bf2@epcas5p4.samsung.com>
2026-02-27 12:12 ` [PATCH v3] usb: dwc3: gadget: Prevent EP resource conflicts during StartTransfer Selvarasu Ganesan
2026-02-28 0:27 ` Thinh Nguyen
2026-03-03 0:39 ` Thinh Nguyen
2026-03-06 13:06 ` Selvarasu Ganesan
2026-03-06 21:41 ` Thinh Nguyen
2026-09-24 12:05 ` Selvarasu Ganesan
2026-09-24 12:24 ` Selvarasu Ganesan
2026-09-29 3:08 ` Thinh Nguyen
2026-09-29 7:04 ` Selvarasu Ganesan
2026-10-03 1:59 ` Thinh Nguyen
2026-10-06 15:52 ` Selvarasu Ganesan
2026-10-07 2:06 ` Thinh Nguyen [this message]
2026-10-07 13:57 ` Selvarasu Ganesan
2026-10-07 14:14 ` Selvarasu Ganesan
2026-10-07 23:59 ` Thinh Nguyen
2026-10-08 4:37 ` Selvarasu Ganesan
2026-10-09 0:27 ` Thinh Nguyen
2026-10-12 16:52 ` Selvarasu Ganesan
2026-10-13 1:52 ` Thinh Nguyen
2026-10-13 3:08 ` Selvarasu Ganesan
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=asWmW1jmzedIV5SP@vbox \
--to=thinh.nguyen@synopsys.com \
--cc=akash.m5@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=dh10.jung@samsung.com \
--cc=eomji.oh@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=h10.kim@samsung.com \
--cc=hongpooh.kim@samsung.com \
--cc=jh0801.jung@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=muhammed.ali@samsung.com \
--cc=pritam.sutar@samsung.com \
--cc=selvarasu.g@samsung.com \
--cc=shijie.cai@samsung.com \
--cc=stable@vger.kernel.org \
--cc=thiagu.r@samsung.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.