stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejas Joglekar <tejas.joglekar@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>, <linux-usb@vger.kernel.org>
Cc: John Youn <john.youn@synopsys.com>,
	Tejas Joglekar <tejas.joglekar@synopsys.com>,
	<stable@vger.kernel.org>, <thinh.nguyen@synopsys.com>
Subject: [PATCH v3] usb: dwc3: gadget: Handle 0 xfer length for OUT EP
Date: Tue, 22 Jan 2019 13:26:51 +0530	[thread overview]
Message-ID: <7bbca67a-1508-4c35-b231-a3bcc8c2f714@US01WEHTC1.internal.synopsys.com> (raw)

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.

Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
Cc: stable@vger.kernel.org

Signed-off-by: Tejas Joglekar <joglekar@synopsys.com>
---
Changes in v3:
 - Enclose summary for fixes with " " and no wrap

Changes in v2:
 - Remove sg patch hunk
 - Added fixes and stable tag

 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index bed2ff4..6c9b76b 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1119,7 +1119,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)) {
 		struct dwc3	*dwc = dep->dwc;
 		struct dwc3_trb	*trb;
 
-- 
2.7.4


             reply	other threads:[~2019-01-22  7:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22  7:56 Tejas Joglekar [this message]
2019-01-28 12:24 ` [PATCH v3] 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=7bbca67a-1508-4c35-b231-a3bcc8c2f714@US01WEHTC1.internal.synopsys.com \
    --to=tejas.joglekar@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=john.youn@synopsys.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --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).