All of lore.kernel.org
 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>, stable@vger.kernel.org
Subject: [PATCH 01/10] usb: dwc3: gadget: Check MPS of the request length
Date: Thu, 24 Sep 2020 01:21:18 -0700	[thread overview]
Message-ID: <290cbf2ba0fee13ba37cf934bf413795d4bd9a04.1600935293.git.Thinh.Nguyen@synopsys.com> (raw)
In-Reply-To: <cover.1600935293.git.Thinh.Nguyen@synopsys.com>

When preparing for SG, not all the entries are prepared at once. When
resume, don't use the remaining request length to calculate for MPS
alignment. Use the entire request->length to do that.

Cc: stable@vger.kernel.org
Fixes: 5d187c0454ef ("usb: dwc3: gadget: Don't setup more than requested")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index cb19d682bbac..44351078f833 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1098,6 +1098,8 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
 	struct scatterlist *s;
 	int		i;
 	unsigned int length = req->request.length;
+	unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
+	unsigned int rem = length % maxp;
 	unsigned int remaining = req->request.num_mapped_sgs
 		- req->num_queued_sgs;
 
@@ -1109,8 +1111,6 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
 		length -= sg_dma_len(s);
 
 	for_each_sg(sg, s, remaining, i) {
-		unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
-		unsigned int rem = length % maxp;
 		unsigned int trb_length;
 		unsigned int chain = true;
 
-- 
2.28.0


  reply	other threads:[~2020-09-24  8:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24  8:21 [PATCH 00/10] usb: dwc3: gadget: Revise preparation for extra TRBs Thinh Nguyen
2020-09-24  8:21 ` Thinh Nguyen [this message]
2020-09-24  8:21 ` [PATCH 02/10] usb: dwc3: gadget: Reclaim extra TRBs after request completion Thinh Nguyen
2020-09-24  8:21 ` [PATCH 03/10] usb: dwc3: gadget: Refactor preparing extra TRB Thinh Nguyen
2020-09-24  8:21 ` [PATCH 04/10] usb: dwc3: gadget: Improve TRB ZLP setup Thinh Nguyen
2020-09-24  8:21 ` [PATCH 05/10] usb: dwc3: ep0: Fix ZLP for OUT ep0 requests Thinh Nguyen
2020-09-24  8:21 ` [PATCH 06/10] usb: dwc3: gadget: Return the number of prepared TRBs Thinh Nguyen
2020-09-24  8:21 ` [PATCH 07/10] usb: dwc3: gadget: Check for number of TRBs prepared Thinh Nguyen
2020-09-24  8:22 ` [PATCH 08/10] usb: dwc3: gadget: Set IOC if not enough for extra TRBs Thinh Nguyen
2020-09-24  8:22 ` [PATCH 09/10] usb: dwc3: gadget: Refactor preparing last TRBs Thinh Nguyen
2020-09-24  8:22 ` [PATCH 10/10] usb: dwc3: gadget: Rename misleading function names Thinh Nguyen

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=290cbf2ba0fee13ba37cf934bf413795d4bd9a04.1600935293.git.Thinh.Nguyen@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 \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.