linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	linux-usb@vger.kernel.org
Cc: John Youn <John.Youn@synopsys.com>
Subject: [PATCH v2 7/7] usb: dwc3: ep0: Skip ZLP setup for OUT
Date: Thu, 06 Aug 2020 19:47:00 -0700	[thread overview]
Message-ID: <fd66c5d1c9f0f5f1d50c021f7ea122851e846fdc.1596767991.git.thinhn@synopsys.com> (raw)
In-Reply-To: <cover.1596767991.git.thinhn@synopsys.com>

The current implementation for ZLP handling of usb_request->zero for ep0
is only for control IN requests. For OUT direction, DWC3 needs to check
and set up for MPS boundary alignment, and it doesn't do that at the
moment.

Usually, control OUT requests can indicate its transfer size via the
wLength field of the control message. So usb_request->zero is usually
not needed for OUT direction. To handle ZLP OUT for control endpoint,
we'd need to allocate at least 3 TRBs for control requests (we have 2 at
the moment). For now, let's just make sure the current ZLP setup is only
for IN direction.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 Changes in v2:
 - None

 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 59f2e8c31bd1..ade9503cf876 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -979,7 +979,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
 					 false);
 		ret = dwc3_ep0_start_trans(dep);
 	} else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) &&
-		   req->request.length && req->request.zero) {
+		   req->request.length && req->request.zero && req->direction) {
 
 		ret = usb_gadget_map_request_by_dev(dwc->sysdev,
 				&req->request, dep->number);
-- 
2.28.0


      parent reply	other threads:[~2020-08-07  2:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07  2:46 [PATCH v2 0/7] usb: dwc3: gadget: Fix TRB preparation Thinh Nguyen
2020-08-07  2:46 ` [PATCH v2 1/7] usb: dwc3: gadget: Don't setup more than requested Thinh Nguyen
2020-08-07  2:46 ` [PATCH v2 2/7] usb: dwc3: gadget: Fix handling ZLP Thinh Nguyen
2020-08-07  2:46 ` [PATCH v2 3/7] usb: dwc3: gadget: Handle ZLP for sg requests Thinh Nguyen
2020-08-07  2:46 ` [PATCH v2 4/7] usb: dwc3: gadget: Refactor preparing TRBs Thinh Nguyen
2020-08-17 13:42   ` Felipe Balbi
2020-08-17 17:35     ` Thinh Nguyen
2020-08-07  2:46 ` [PATCH v2 5/7] usb: dwc3: gadget: Account for extra TRB Thinh Nguyen
2020-08-07  2:46 ` [PATCH v2 6/7] usb: dwc3: gadget: Rename misleading function names Thinh Nguyen
2020-09-24  7:47   ` Felipe Balbi
2020-09-24  7:54     ` Thinh Nguyen
2020-09-24  8:53       ` Felipe Balbi
2020-09-24  9:06         ` Felipe Balbi
2020-08-07  2:47 ` 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=fd66c5d1c9f0f5f1d50c021f7ea122851e846fdc.1596767991.git.thinhn@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=John.Youn@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@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;
as well as URLs for NNTP newsgroup(s).