mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Revert "usb: dwc3: gadget: always decrement by 1"
@ 2016-08-27  1:43 John Youn
  0 siblings, 0 replies; only message in thread
From: John Youn @ 2016-08-27  1:43 UTC (permalink / raw)
  To: John Youn, Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel

This reverts commit 6f8245b4e37c ("usb: dwc3: gadget: always decrement
by 1").

We can't always decrement this value.

We should decrement only if the calculation of free slots results in a
LINK TRB being among one of the free slots (dequeue < enqueue).

Otherwise, if the LINK TRB is not among the free slots then it should
not be decremented.

Signed-off-by: John Youn <johnyoun@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7a8d3d8..122e64d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -884,9 +884,12 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
 		return DWC3_TRB_NUM - 1;
 	}
 
-	trbs_left = dep->trb_dequeue - dep->trb_enqueue - 1;
+	trbs_left = dep->trb_dequeue - dep->trb_enqueue;
 	trbs_left &= (DWC3_TRB_NUM - 1);
 
+	if (dep->trb_dequeue < dep->trb_enqueue)
+		trbs_left--;
+
 	return trbs_left;
 }
 
-- 
2.9.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-27  1:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-27  1:43 [PATCH] Revert "usb: dwc3: gadget: always decrement by 1" John Youn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®