mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Selvarasu Ganesan <selvarasu.g@samsung.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: "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: Thu, 8 Oct 2026 10:07:46 +0530	[thread overview]
Message-ID: <bc43e3f5-ba0c-4f91-b765-ee35021bf089@samsung.com> (raw)
In-Reply-To: <asbJfaj5OIhHBunD@vbox>


On 10/8/2026 5:29 AM, Thinh Nguyen wrote:
> On Wed, Oct 07, 2026, Selvarasu Ganesan wrote:
>> Sorry for the format issue. The updated answers as below,
>>
>> No, the endpoint completion event is not seen after the -ETIMEDOUT error.
>>
>> The proposed fix works well for the __dwc3_gadget_ep_set_halt sequence,
>> where DWC3_EP_END_TRANSFER_PENDING must be set to prevent dwc3_ep_queue
>> from starting a new transfer during a EP transfer timeout.
>>
>> But, this is unnecessary for __dwc3_gadget_ep_disable. Since there's no
>> way to clear the pending flag if the interrupt is missed and no
>> dwc3_ep_queue calls occur until the EP is re-enabled, preserving
>> DWC3_EP_END_TRANSFER_PENDING here provides no benefit.
>>
>> So, the below changes is not necessary in ep disable,
>>
> We still need to keep DWC3_EP_END_TRANSFER_PENDING in ep_disable. That's
> for the normal case where the End Transfer completes after ep_disable
> returns, which is the original issue. If the command never completes,
> the endpoint resource is stuck regardless. Clearing the flag only lead
> to a NO_RESOURCE error later.

Agreed.

>
> As for the dwc3_gadget_ep_queue() race during giveback, keeping
> DWC3_EP_TRANSFER_STARTED isn't right. We should reject the queue when
> the endpoint is disabled. This should be a separate patch:

Agreed.

>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index ee837235630a..eb6666b7bb98 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1084,6 +1084,8 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
>   	reg &= ~DWC3_DALEPENA_EP(dep->number);
>   	dwc3_writel(dwc, DWC3_DALEPENA, reg);
>   
> +	dep->flags &= ~DWC3_EP_ENABLED;
> +
>   	dwc3_remove_requests(dwc, dep, -ESHUTDOWN);
>   
>   	dep->stream_capable = false;
> @@ -1990,7 +1992,8 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
>   {
>   	struct dwc3		*dwc = dep->dwc;
>   
> -	if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) {
> +	if (!(dep->flags & DWC3_EP_ENABLED) || !dep->endpoint.desc ||
> +	    !dwc->pullups_connected || !dwc->connected) {
>   		dev_dbg(dwc->dev, "%s: can't queue to disabled endpoint\n",
>   				dep->name);
>   		return -ESHUTDOWN;
>
Thanks for suggestion. We will test this patch to confirm no resource 
issue in race condition.

> The End Transfer command not completing is also a separate issue. I
> asked you to check whether the command would eventually complete with
> the additional code, and it appears it doesn't.
  We have confirmed that the completion event is never seen, once the 
timeout occurs for end transfer. It appears the command is indeed 
hanging in the hardware, as you suspected.

>
> Can you provide some more info on your setup:
>   * IP and version
>   * connected speed
>   * endpoint direction (is it always OUT?)
>   * Is there any active transfer
>   * tracepoints
* IP and version : 0xc120:   0x33313130
* connected speed : HS mode
* endpoint direction (is it always OUT?) : Yes its always OUT
* Is there any active transfer : No, There is evidences from the log to 
say there is a active transfer.
* tracepoints: There is no dwc3 traces for this issue as of now due to 
its low reproduction rate in the customer's setup.


Thanks,
Selva
> Thanks,
> Thinh

      reply	other threads:[~2026-10-08  4:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260227121338epcas5p4baebb406db37f07223545b2f85751bf2@epcas5p4.samsung.com>
2026-02-27 12:12 ` 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
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 [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=bc43e3f5-ba0c-4f91-b765-ee35021bf089@samsung.com \
    --to=selvarasu.g@samsung.com \
    --cc=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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®