mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Uttkarsh Aggarwal <quic_uaggarwa@quicinc.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"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: [RFC] usb: dwc: ep0: Use -ESHUTDOWN in dwc3_ep0_stall_restart
Date: Tue, 5 Dec 2023 01:43:37 +0000	[thread overview]
Message-ID: <20231205014328.j2xpojjqbeafsfii@synopsys.com> (raw)
In-Reply-To: <20231122091127.3636-1-quic_uaggarwa@quicinc.com>

On Wed, Nov 22, 2023, Uttkarsh Aggarwal wrote:
> Current implementation blocks the running operations when Plug-out and
> Plug-In is performed continuously, process gets stuck in
> dwc3_thread_interrupt().
> 
> Code Flow:
> 
> 	CPU1
> 
> 	->Gadget_start
> 	->dwc3_interrupt
> 	->dwc3_thread_interrupt
> 	->dwc3_process_event_buf
> 	->dwc3_process_event_entry
> 	->dwc3_endpoint_interrupt
> 	->dwc3_ep0_interrupt
> 	->dwc3_ep0_inspect_setup
> 	->dwc3_ep0_stall_and_restart
> 
> By this time if pending_list is not empty, it will get the next request
> on the given list and calls dwc3_gadget_giveback which will unmap request
> and call its complete() callback to notify upper layers that it has
> completed. Currently  dwc3_gadget_giveback status is set to-ECONNRESET,
> whereas it should be -ESHUTDOWN.
> 
> Cc: <stable@vger.kernel.org>
> Fixes: d742220b3577 ("usb: dwc3: ep0: giveback requests on stall_and_restart")
> Signed-off-by: Uttkarsh Aggarwal <quic_uaggarwa@quicinc.com>
> ---
>  drivers/usb/dwc3/ep0.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index b94243237293..8317fedda1c0 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -238,7 +238,7 @@ void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
>  		struct dwc3_request	*req;
>  
>  		req = next_request(&dep->pending_list);
> -		dwc3_gadget_giveback(dep, req, -ECONNRESET);
> +		dwc3_gadget_giveback(dep, req, -ESHUTDOWN);

There are other conditions which should return -ECONNRESET (e.g. invalid
length, direction, got cancelled). For the particular condition that you
want for -ESHUTDOWN, I think you can use the dwc->connected field to
check for that.

BR,
Thinh

>  	}
>  
>  	dwc->eps[0]->trb_enqueue = 0;
> -- 
> 2.17.1
> 

      reply	other threads:[~2023-12-05  1:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22  9:11 Uttkarsh Aggarwal
2023-12-05  1:43 ` 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=20231205014328.j2xpojjqbeafsfii@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_uaggarwa@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®