Linux USB
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"quic_jackp@quicinc.com" <quic_jackp@quicinc.com>,
	"quic_ugoswami@quicinc.com" <quic_ugoswami@quicinc.com>
Subject: Re: [PATCH v3 3/3] usb: dwc3: gadget: Execute gadget stop after halting the controller
Date: Tue, 11 Apr 2023 01:14:03 +0000	[thread overview]
Message-ID: <20230411011400.ukcr6khhkzi5hkac@synopsys.com> (raw)
In-Reply-To: <20230410231954.437-4-quic_wcheng@quicinc.com>

On Mon, Apr 10, 2023, Wesley Cheng wrote:
> Do not call gadget stop until the poll for controller halt is
> completed.  DEVTEN is cleared as part of gadget stop, so the intention to
> allow ep0 events to continue while waiting for controller halt is not
> happening.
> 
> Fixes: c96683798e27 ("usb: dwc3: ep0: Don't prepare beyond Setup stage")
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
>  drivers/usb/dwc3/gadget.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 91768f1bdbaf..9715de8e99bc 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2566,7 +2566,6 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
>  	 * bit.
>  	 */
>  	dwc3_stop_active_transfers(dwc);
> -	__dwc3_gadget_stop(dwc);
>  	spin_unlock_irqrestore(&dwc->lock, flags);
>  
>  	/*
> @@ -2596,7 +2595,19 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
>  	 * remaining event generated by the controller while polling for
>  	 * DSTS.DEVCTLHLT.
>  	 */
> -	return dwc3_gadget_run_stop(dwc, false, false);
> +	ret = dwc3_gadget_run_stop(dwc, false, false);
> +
> +	/*
> +	 * Stop the gadget after controller is halted, so that if needed, the
> +	 * events to update EP0 state can still occur while the run/stop
> +	 * routine polls for the halted state.  DEVTEN is cleared as part of
> +	 * gadget stop.
> +	 */
> +	spin_lock_irqsave(&dwc->lock, flags);
> +	__dwc3_gadget_stop(dwc);
> +	spin_unlock_irqrestore(&dwc->lock, flags);
> +
> +	return ret;
>  }
>  
>  static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

      reply	other threads:[~2023-04-11  1:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10 23:19 [PATCH v3 0/3] Avoid having pending end transfers on soft disconnect Wesley Cheng
2023-04-10 23:19 ` [PATCH v3 1/3] usb: dwc3: gadget: Refactor EP0 forced stall/restart into a separate API Wesley Cheng
2023-04-11  1:13   ` Thinh Nguyen
2023-04-10 23:19 ` [PATCH v3 2/3] usb: dwc3: gadget: Stall and restart EP0 if host is unresponsive Wesley Cheng
2023-04-11  1:13   ` Thinh Nguyen
2023-04-13  7:47   ` Greg KH
2023-04-10 23:19 ` [PATCH v3 3/3] usb: dwc3: gadget: Execute gadget stop after halting the controller Wesley Cheng
2023-04-11  1:14   ` Thinh Nguyen [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=20230411011400.ukcr6khhkzi5hkac@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_jackp@quicinc.com \
    --cc=quic_ugoswami@quicinc.com \
    --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