mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Elson Roy Serrao <quic_eserrao@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_wcheng@quicinc.com" <quic_wcheng@quicinc.com>,
	"quic_jackp@quicinc.com" <quic_jackp@quicinc.com>
Subject: Re: [PATCH v2] usb: dwc3: gadget: Reset num TRBs before giving back the request
Date: Thu, 1 Jun 2023 22:19:11 +0000	[thread overview]
Message-ID: <20230601221909.eh7tbq6nr7lsv53e@synopsys.com> (raw)
In-Reply-To: <1685654850-8468-1-git-send-email-quic_eserrao@quicinc.com>

On Thu, Jun 01, 2023, Elson Roy Serrao wrote:
> Consider a scenario where cable disconnect happens when there is an active
> usb reqest queued to the UDC. As part of the disconnect we would issue an
> end transfer with no interrupt-on-completion before giving back this
> request. Since we are giving back the request without skipping TRBs the
> num_trbs field of dwc3_request still holds the stale value previously used.
> Function drivers re-use same request for a given bind-unbind session and
> hence their dwc3_request context gets preserved across cable
> disconnect/connect. When such a request gets re-queued after cable connect,
> we would increase the num_trbs field on top of the previous stale value
> thus incorrectly representing the number of TRBs used. Fix this by
> resetting num_trbs field before giving back the request.
> 
> Fixes: 09fe1f8d7e2f ("usb: dwc3: gadget: track number of TRBs per request")
> Signed-off-by: Elson Roy Serrao <quic_eserrao@quicinc.com>
> ---
> Changes in v2:
>  - Addressed Thinh's comment to reset num_trbs in dwc3_gadget_del_and_unmap_request
>    rather than calling skip_trbs.
>  - Modify the commit message to match the modification.
> 
>  drivers/usb/dwc3/gadget.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 578804d..0ded919 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -198,6 +198,7 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep,
>  	list_del(&req->list);
>  	req->remaining = 0;
>  	req->needs_extra_trb = false;
> +	req->num_trbs = 0;
>  
>  	if (req->request.status == -EINPROGRESS)
>  		req->request.status = status;
> -- 
> 2.7.4
> 

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

Thanks,
Thinh

      reply	other threads:[~2023-06-01 22:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 21:27 Elson Roy Serrao
2023-06-01 22:19 ` 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=20230601221909.eh7tbq6nr7lsv53e@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_eserrao@quicinc.com \
    --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

all inboxes | Powered by JetHome®