LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Wesley Cheng <wcheng@codeaurora.org>,
	"balbi@kernel.org" <balbi@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jackp@codeaurora.org" <jackp@codeaurora.org>
Subject: Re: [PATCH v4] usb: dwc3: gadget: Stop EP0 transfers during pullup disable
Date: Tue, 24 Aug 2021 02:18:40 +0000	[thread overview]
Message-ID: <fc529936-d290-c102-1f2d-82dd5ff9cc2f@synopsys.com> (raw)
In-Reply-To: <20210823222458.3760-1-wcheng@codeaurora.org>

Wesley Cheng wrote:
> During a USB cable disconnect, or soft disconnect scenario, a pending
> SETUP transaction may not be completed, leading to the following
> error:
> 
>     dwc3 a600000.dwc3: timed out waiting for SETUP phase
> 
> If this occurs, then the entire pullup disable routine is skipped and
> proper cleanup and halting of the controller does not complete.
> 
> Instead of returning an error (which is ignored from the UDC
> perspective), allow the pullup disable routine to continue, which
> will also handle disabling of EP0/1.  This will end any active
> transfers as well.  Ensure to clear any delayed_status also, as the
> timeout could happen within the STATUS stage.
> 
> Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
> ---
> Changes in v4:
>  - Fixed formatting and typos in commit text
>  - Removed braces due to the removal of the return statement
> 
> Changes in v3:
>  - Added suggestion by Thinh to change dev_err to dev_warn
> 
> Changes in v2:
>  - Removed calls to dwc3_ep0_end_control_data() and just allow the ep disables
>    on EP0 handle the proper ending of transfers.
>  - Ensure that delayed_status is cleared, as ran into enumeration issues if the
>    SETUP transaction fails on a STATUS stage.  Saw delayed_status == TRUE on the
>    next connect, which blocked further SETUP transactions to be handled.
> 
>  drivers/usb/dwc3/gadget.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 5d084542718d..63f6d9f2a692 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2428,10 +2428,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
>  
>  		ret = wait_for_completion_timeout(&dwc->ep0_in_setup,
>  				msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT));
> -		if (ret == 0) {
> -			dev_err(dwc->dev, "timed out waiting for SETUP phase\n");
> -			return -ETIMEDOUT;
> -		}
> +		if (ret == 0)
> +			dev_warn(dwc->dev, "timed out waiting for SETUP phase\n");
>  	}
>  
>  	/*
> @@ -2643,6 +2641,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
>  	/* begin to receive SETUP packets */
>  	dwc->ep0state = EP0_SETUP_PHASE;
>  	dwc->link_state = DWC3_LINK_STATE_SS_DIS;
> +	dwc->delayed_status = false;
>  	dwc3_ep0_out_start(dwc);
>  
>  	dwc3_gadget_enable_irq(dwc);
> 

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

Thanks,
Thinh

  reply	other threads:[~2021-08-24  2:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 22:24 Wesley Cheng
2021-08-24  2:18 ` Thinh Nguyen [this message]
2021-08-24  8:17 ` Felipe Balbi

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=fc529936-d290-c102-1f2d-82dd5ff9cc2f@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackp@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=wcheng@codeaurora.org \
    --subject='Re: [PATCH v4] usb: dwc3: gadget: Stop EP0 transfers during pullup disable' \
    /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

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).