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>
Subject: [PATCH 3/5] usb: dwc3: gadget: Continue to process pending requests
Date: Mon, 27 Apr 2020 15:27:53 -0700	[thread overview]
Message-ID: <1ce5c2e0e810fee962e43b954d8defe30a819e3d.1588025916.git.thinhn@synopsys.com> (raw)
In-Reply-To: <cover.1588025916.git.thinhn@synopsys.com>

If there are still pending requests because no TRB was available,
prepare more when started requests are completed.

Introduce dwc3_gadget_ep_should_continue() to check for incomplete and
pending requests to resume updating new TRBs to the controller's TRB
cache.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 4ca3e197bee4..865e6fbb7360 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2605,10 +2605,8 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
 
 	req->request.actual = req->request.length - req->remaining;
 
-	if (!dwc3_gadget_ep_request_completed(req)) {
-		__dwc3_gadget_kick_transfer(dep);
+	if (!dwc3_gadget_ep_request_completed(req))
 		goto out;
-	}
 
 	dwc3_gadget_giveback(dep, req, status);
 
@@ -2632,6 +2630,24 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep,
 	}
 }
 
+static bool dwc3_gadget_ep_should_continue(struct dwc3_ep *dep)
+{
+	struct dwc3_request	*req;
+
+	if (!list_empty(&dep->pending_list))
+		return true;
+
+	/*
+	 * We only need to check the first entry of the started list. We can
+	 * assume the completed requests are removed from the started list.
+	 */
+	req = next_request(&dep->started_list);
+	if (!req)
+		return false;
+
+	return !dwc3_gadget_ep_request_completed(req);
+}
+
 static void dwc3_gadget_endpoint_frame_from_event(struct dwc3_ep *dep,
 		const struct dwc3_event_depevt *event)
 {
@@ -2661,6 +2677,8 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
 
 	if (stop)
 		dwc3_stop_active_transfer(dep, true, true);
+	else if (dwc3_gadget_ep_should_continue(dep))
+		__dwc3_gadget_kick_transfer(dep);
 
 	/*
 	 * WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround.
-- 
2.11.0


  parent reply	other threads:[~2020-04-27 22:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 22:27 [PATCH 0/5] usb: dwc3: gadget: Handle streams Thinh Nguyen
2020-04-27 22:27 ` [PATCH 1/5] usb: gadget: Introduce usb_request->is_last field Thinh Nguyen
2020-04-29  3:15   ` Peter Chen
2020-04-30  1:00     ` Thinh Nguyen
2020-04-30  3:57       ` Peter Chen
2020-04-30  4:54         ` Thinh Nguyen
2020-04-30 14:21           ` Alan Stern
2020-04-30 17:17             ` Thinh Nguyen
2020-04-30 18:22               ` Alan Stern
2020-04-30 18:36                 ` Thinh Nguyen
2020-04-27 22:27 ` [PATCH 2/5] usb: gadget: f_tcm: Inform last transfer request Thinh Nguyen
2020-04-27 22:27 ` Thinh Nguyen [this message]
2020-04-27 22:27 ` [PATCH 4/5] usb: dwc3: gadget: Handle transfer completion Thinh Nguyen
2020-04-29  7:48   ` Felipe Balbi
2020-04-30  1:16     ` Thinh Nguyen
2020-05-14 10:38       ` Felipe Balbi
2020-05-15  1:23         ` Thinh Nguyen
2020-04-27 22:28 ` [PATCH 5/5] usb: dwc3: gadget: Handle stream transfers 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=1ce5c2e0e810fee962e43b954d8defe30a819e3d.1588025916.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 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.