mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Prashanth K <quic_prashk@quicinc.com>
Cc: Greg Kroah-Hartman <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>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc3: Wait for EndXfer completion before restoring GUSB2PHYCFG
Date: Tue, 8 Oct 2024 21:15:08 +0000	[thread overview]
Message-ID: <20241008211506.kbszzkbfk33ozgxp@synopsys.com> (raw)
In-Reply-To: <20240924093208.2524531-1-quic_prashk@quicinc.com>

On Tue, Sep 24, 2024, Prashanth K wrote:
> DWC3 programming guide mentions that when operating in USB2.0 speeds,
> if GUSB2PHYCFG[6] or GUSB2PHYCFG[8] is set, it must be cleared prior
> to issuing commands and may be set again  after the command completes.
> But currently while issuing EndXfer command without CmdIOC set, we
> wait for 1ms after GUSB2PHYCFG is restored. This results in cases
> where EndXfer command doesn't get completed and causes SMMU faults
> since requests are unmapped afterwards. Hence restore GUSB2PHYCFG
> after waiting for EndXfer command completion.
> 
> Cc: stable@vger.kernel.org
> Fixes: 1d26ba0944d3 ("usb: dwc3: Wait unconditionally after issuing EndXfer command")
> Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
> ---
>  drivers/usb/dwc3/gadget.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 291bc549935b..50772d611582 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -438,6 +438,10 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>  			dwc3_gadget_ep_get_transfer_index(dep);
>  	}
>  
> +	if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER &&
> +	    !(cmd & DWC3_DEPCMD_CMDIOC))
> +		mdelay(1);
> +
>  	if (saved_config) {
>  		reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
>  		reg |= saved_config;
> @@ -1715,12 +1719,10 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
>  	WARN_ON_ONCE(ret);
>  	dep->resource_index = 0;
>  
> -	if (!interrupt) {
> -		mdelay(1);
> +	if (!interrupt)
>  		dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
> -	} else if (!ret) {
> +	else if (!ret)
>  		dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
> -	}
>  
>  	dep->flags &= ~DWC3_EP_DELAY_STOP;
>  	return ret;
> -- 
> 2.25.1
> 

Looks good to me!

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

Thanks for the fix,
Thinh

      parent reply	other threads:[~2024-10-08 21:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24  9:32 Prashanth K
2024-10-08  4:24 ` Prashanth K
2024-10-08 20:58   ` Thinh Nguyen
2024-10-08 21:15 ` 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=20241008211506.kbszzkbfk33ozgxp@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_prashk@quicinc.com \
    --cc=stable@vger.kernel.org \
    /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®