linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Pham <quic_jackp@quicinc.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: <balbi@kernel.org>, <gregkh@linuxfoundation.org>,
	<linux-kernel@vger.kernel.org>, <linux-usb@vger.kernel.org>,
	<Thinh.Nguyen@synopsys.com>
Subject: Re: [PATCH v2 5/5] usb: dwc3: gadget: Increase DWC3 controller halt timeout
Date: Tue, 12 Jul 2022 19:56:43 -0700	[thread overview]
Message-ID: <20220713025643.GC8200@jackp-linux.qualcomm.com> (raw)
In-Reply-To: <20220713003523.29309-6-quic_wcheng@quicinc.com>

Hi Wesley,

On Tue, Jul 12, 2022 at 05:35:23PM -0700, Wesley Cheng wrote:
> Since EP0 transactions need to be completed before the controller halt
> sequence is finished, this may take some time depending on the host and the
> enabled functions.  Increase the controller halt timeout, so that we give
> the controller sufficient time to handle EP0 transfers.
> 
> Fixes: 861c010a2ee1 ("usb: dwc3: gadget: Refactor pullup()")
> Suggested-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
> Link:
>   https://lore.kernel.org/linux-usb/4988ed34-04a4-060a-ccef-f57790f76a2b@synopsys.com/
> 
>  drivers/usb/dwc3/gadget.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 41b7007358de..e32d7293c447 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2476,6 +2476,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
>  	dwc3_gadget_dctl_write_safe(dwc, reg);
>  
>  	do {
> +		msleep(1);

Be aware that this probably won't sleep for *just* 1ms.  From
Documentation/timers/timers-howto.rst:

	msleep(1~20) may not do what the caller intends, and
	will often sleep longer (~20 ms actual sleep for any
	value given in the 1~20ms range). In many cases this
	is not the desired behavior.

So with timeout==500 this loop could very well end up iterating for up
to 10 seconds.  Granted this shouldn't be called from any atomic context
but just wanted to make sure that the effective increase in timeout as
$SUBJECT intends is made clear here and that it's not overly generous.

>  		reg = dwc3_readl(dwc->regs, DWC3_DSTS);
>  		reg &= DWC3_DSTS_DEVCTRLHLT;
>  	} while (--timeout && !(!is_on ^ !reg));

Jack

  reply	other threads:[~2022-07-13  2:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13  0:35 [PATCH v2 0/5] Fix controller halt and endxfer timeout issues Wesley Cheng
2022-07-13  0:35 ` [PATCH v2 1/5] usb: dwc3: Do not service EP0 and conndone events if soft disconnected Wesley Cheng
2022-07-13  0:35 ` [PATCH v2 2/5] usb: dwc3: gadget: Force sending delayed status during soft disconnect Wesley Cheng
2022-07-13  0:35 ` [PATCH v2 3/5] usb: dwc3: gadget: Adjust IRQ management during soft disconnect/connect Wesley Cheng
2022-07-14 17:38   ` Thinh Nguyen
2022-07-14 17:41     ` Wesley Cheng
2022-07-15 11:45       ` gregkh
2022-07-20 18:50     ` Wesley Cheng
2022-07-21  0:26       ` Thinh Nguyen
2022-07-13  0:35 ` [PATCH v2 4/5] usb: dwc3: Allow end transfer commands to be sent during soft disconnect Wesley Cheng
2022-07-21 22:08   ` Thinh Nguyen
2022-07-21 22:13     ` Wesley Cheng
2022-07-21 22:20       ` Thinh Nguyen
2022-07-21 22:40         ` Wesley Cheng
2022-07-22  0:00           ` Thinh Nguyen
2022-07-22  0:04             ` Wesley Cheng
2022-07-22  2:27               ` Wesley Cheng
2022-07-22 19:59                 ` Thinh Nguyen
2022-07-13  0:35 ` [PATCH v2 5/5] usb: dwc3: gadget: Increase DWC3 controller halt timeout Wesley Cheng
2022-07-13  2:56   ` Jack Pham [this message]
2022-07-13 11:40     ` John Keeping
2022-07-13 21:53       ` Jack Pham
2022-07-14  0:56         ` Thinh Nguyen

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=20220713025643.GC8200@jackp-linux.qualcomm.com \
    --to=quic_jackp@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_wcheng@quicinc.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;
as well as URLs for NNTP newsgroup(s).