linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Tejas Joglekar <tejas.joglekar@synopsys.com>, linux-usb@vger.kernel.org
Cc: John Youn <john.youn@synopsys.com>, thinh.nguyen@synopsys.com
Subject: usb: dwc3: gadget: Handle 0 xfer length for OUT EP
Date: Mon, 10 Dec 2018 09:35:49 +0200	[thread overview]
Message-ID: <87mupd25re.fsf@linux.intel.com> (raw)

Hi,

Tejas Joglekar <tejas.joglekar@synopsys.com> writes:
> For OUT endpoints, zero-length transfers require MaxPacketSize buffer as
> per the DWC_usb3 programming guide 3.30a section 4.2.3.3.
>
> This patch fixes this by explicitly checking zero length
> transfer to correctly pad up to MaxPacketSize.
>
> Signed-off-by: Tejas Joglekar <joglekar@synopsys.com>

do you have tracepoints of the problem?

> ---
>  drivers/usb/dwc3/gadget.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index e2caf9e..f1089ec 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1069,7 +1069,8 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
>  		if (sg_is_last(s))
>  			chain = false;
>  
> -		if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
> +		if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)
> +		    && !chain) {

are you 100% certain we have scatter/gather for a zlp? That doesn't make
sense to me.

> @@ -1114,7 +1115,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
>  	unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
>  	unsigned int rem = length % maxp;
>  
> -	if (rem && usb_endpoint_dir_out(dep->endpoint.desc)) {
> +	if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) {

this is already taken care of:

> static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
> 		struct dwc3_request *req)
> {
> 	unsigned int length = req->request.length;
> 	unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
> 	unsigned int rem = length % maxp;
>
> 	if (rem && usb_endpoint_dir_out(dep->endpoint.desc)) {

[...]

> 	} else if (req->request.zero && req->request.length &&
> 		   (IS_ALIGNED(req->request.length, maxp))) {

why isn't this branch triggering for you? Please capture and share
tracepoints exposing the problem

> 		struct dwc3	*dwc = dep->dwc;
> 		struct dwc3_trb	*trb;
>
> 		req->needs_extra_trb = true;
>
> 		/* prepare normal TRB */
> 		dwc3_prepare_one_trb(dep, req, true, 0);
>
> 		/* Now prepare one extra TRB to handle ZLP */
> 		trb = &dep->trb_pool[dep->trb_enqueue];
> 		req->num_trbs++;
> 		__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
> 				false, 1, req->request.stream_id,
> 				req->request.short_not_ok,
> 				req->request.no_interrupt);
> 	} else {
> 		dwc3_prepare_one_trb(dep, req, false, 0);
> 	}
> }

             reply	other threads:[~2018-12-10  7:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10  7:35 Felipe Balbi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-12-10  7:23 usb: dwc3: gadget: Handle 0 xfer length for OUT EP Tejas Joglekar

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=87mupd25re.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=john.youn@synopsys.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=tejas.joglekar@synopsys.com \
    --cc=thinh.nguyen@synopsys.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;
as well as URLs for NNTP newsgroup(s).