]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: dwc2: host: If using uframe scheduler, end splits better
authorDouglas Anderson <dianders@chromium.org>
Fri, 29 Jan 2016 02:20:13 +0000 (18:20 -0800)
committerFelipe Balbi <balbi@kernel.org>
Fri, 4 Mar 2016 13:14:45 +0000 (15:14 +0200)
The microframe scheduler figured out exactly how many transfers we need
for a split transaction.  Let's use this knowledge to know when to end
things.

Without this I found that certain devices would just keep responding
with tons of NYET resonses on their INT_IN endpoint.  These would just
keep going and going and eventually we'd decide to terminate the
transfer (because the whole frame changed), but by that time the
scheduler would decide that we "missed" the start of the next transfer.
I can also imagine that if we blow past the end of our scheduled time we
may mess up other things that were scheduled to happen.

No known test cases are improved by this patch except that the scheduler
code doesn't yell about MISSES constantly anymore.

Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/dwc2/hcd_intr.c

index 5fc024f2092aa4d38735793e1af2c76bf7314f69..906f223542ee6436edb5680af1bd100529cb5d2a 100644 (file)
@@ -1371,14 +1371,50 @@ static void dwc2_hc_nyet_intr(struct dwc2_hsotg *hsotg,
 
                if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
                    chan->ep_type == USB_ENDPOINT_XFER_ISOC) {
-                       int frnum = dwc2_hcd_get_frame_number(hsotg);
+                       struct dwc2_qh *qh = chan->qh;
+                       bool past_end;
+
+                       if (hsotg->core_params->uframe_sched <= 0) {
+                               int frnum = dwc2_hcd_get_frame_number(hsotg);
+
+                               /* Don't have num_hs_transfers; simple logic */
+                               past_end = dwc2_full_frame_num(frnum) !=
+                                    dwc2_full_frame_num(qh->next_active_frame);
+                       } else {
+                               int end_frnum;
 
-                       if (dwc2_full_frame_num(frnum) !=
-                           dwc2_full_frame_num(chan->qh->next_active_frame)) {
                                /*
-                                * No longer in the same full speed frame.
-                                * Treat this as a transaction error.
-                                */
+                               * Figure out the end frame based on schedule.
+                               *
+                               * We don't want to go on trying again and again
+                               * forever.  Let's stop when we've done all the
+                               * transfers that were scheduled.
+                               *
+                               * We're going to be comparing start_active_frame
+                               * and next_active_frame, both of which are 1
+                               * before the time the packet goes on the wire,
+                               * so that cancels out.  Basically if had 1
+                               * transfer and we saw 1 NYET then we're done.
+                               * We're getting a NYET here so if next >=
+                               * (start + num_transfers) we're done. The
+                               * complexity is that for all but ISOC_OUT we
+                               * skip one slot.
+                               */
+                               end_frnum = dwc2_frame_num_inc(
+                                       qh->start_active_frame,
+                                       qh->num_hs_transfers);
+
+                               if (qh->ep_type != USB_ENDPOINT_XFER_ISOC ||
+                                   qh->ep_is_in)
+                                       end_frnum =
+                                              dwc2_frame_num_inc(end_frnum, 1);
+
+                               past_end = dwc2_frame_num_le(
+                                       end_frnum, qh->next_active_frame);
+                       }
+
+                       if (past_end) {
+                               /* Treat this as a transaction error. */
 #if 0
                                /*
                                 * Todo: Fix system performance so this can