Linux USB
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
	"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>
Subject: Re: [PATCH v4 6/9] usb: dwc3: Remove DWC3 locking during gadget suspend/resume
Date: Tue, 23 Aug 2022 01:14:29 +0000	[thread overview]
Message-ID: <20220823011415.6df3tbdcaoof3rbz@synopsys.com> (raw)
In-Reply-To: <20220817182359.13550-7-quic_wcheng@quicinc.com>

On Wed, Aug 17, 2022 at 11:23:56AM -0700, Wesley Cheng wrote:
> Remove the need for making dwc3_gadget_suspend() and dwc3_gadget_resume()
> to be called in a spinlock, as dwc3_gadget_run_stop() could potentially
> take some time to complete.
> 
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
>  drivers/usb/dwc3/core.c   | 4 ----
>  drivers/usb/dwc3/gadget.c | 5 +++++
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index c5c238ab3083..23e123a1ab5f 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1976,9 +1976,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
>  	case DWC3_GCTL_PRTCAP_DEVICE:
>  		if (pm_runtime_suspended(dwc->dev))
>  			break;
> -		spin_lock_irqsave(&dwc->lock, flags);
>  		dwc3_gadget_suspend(dwc);
> -		spin_unlock_irqrestore(&dwc->lock, flags);
>  		synchronize_irq(dwc->irq_gadget);
>  		dwc3_core_exit(dwc);
>  		break;
> @@ -2039,9 +2037,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
>  			return ret;
>  
>  		dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
> -		spin_lock_irqsave(&dwc->lock, flags);
>  		dwc3_gadget_resume(dwc);
> -		spin_unlock_irqrestore(&dwc->lock, flags);
>  		break;
>  	case DWC3_GCTL_PRTCAP_HOST:
>  		if (!PMSG_IS_AUTO(msg) && !device_can_wakeup(dwc->dev)) {
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 7b66a54250a0..57d83b3b4967 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -4520,12 +4520,17 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
>  
>  int dwc3_gadget_suspend(struct dwc3 *dwc)
>  {
> +	unsigned long flags;
> +
>  	if (!dwc->gadget_driver)
>  		return 0;
>  
>  	dwc3_gadget_run_stop(dwc, false, false);
> +
> +	spin_lock_irqsave(&dwc->lock, flags);
>  	dwc3_disconnect_gadget(dwc);
>  	__dwc3_gadget_stop(dwc);
> +	spin_unlock_irqrestore(&dwc->lock, flags);
>  
>  	return 0;
>  }

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

Thanks,
Thinh

  reply	other threads:[~2022-08-23  1:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 18:23 [PATCH v4 0/9] Fix controller halt and endxfer timeout issues Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 1/9] usb: dwc3: Do not service EP0 and conndone events if soft disconnected Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 2/9] usb: dwc3: gadget: Force sending delayed status during soft disconnect Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 3/9] usb: dwc3: gadget: Synchronize IRQ between soft connect/disconnect Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 4/9] usb: dwc3: gadget: Continue handling EP0 xfercomplete events Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 5/9] usb: dwc3: Avoid unmapping USB requests if endxfer is not complete Wesley Cheng
2022-08-30 14:08   ` Greg KH
2022-08-30 18:13     ` Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 6/9] usb: dwc3: Remove DWC3 locking during gadget suspend/resume Wesley Cheng
2022-08-23  1:14   ` Thinh Nguyen [this message]
2022-08-17 18:23 ` [PATCH v4 7/9] usb: dwc3: Increase DWC3 controller halt timeout Wesley Cheng
2022-08-23  1:04   ` Thinh Nguyen
2022-08-17 18:23 ` [PATCH v4 8/9] usb: dwc3: gadget: Skip waiting for CMDACT cleared during endxfer Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 9/9] usb: dwc3: gadget: Submit endxfer command if delayed during disconnect Wesley Cheng

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=20220823011415.6df3tbdcaoof3rbz@synopsys.com \
    --to=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_jackp@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