The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: fix miss isoc issue introduced by IRQ latency
@ 2018-12-14 16:32 Zeng Tao
  2018-12-14  8:51 ` Felipe Balbi
  2018-12-14 11:17 ` Sergei Shtylyov
  0 siblings, 2 replies; 9+ messages in thread
From: Zeng Tao @ 2018-12-14 16:32 UTC (permalink / raw)
  To: balbi; +Cc: liangshengjun, Zeng Tao, Greg Kroah-Hartman, linux-usb,
	linux-kernel

If it's a busy system, some times when we start an isoc transfer, the
framenumber get from the event buffer may be already elasped, in this
 case, we will get all the packets dropped due to miss isoc. And we turn
into transfer nothing, to fix this issue, we need to fix the framenumber
to make sure that it's not out of date.

Signed-off-by: Liang Shengjun <liangshengjun@hisilicon.com>
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
---
 drivers/usb/dwc3/core.h   |  3 +++
 drivers/usb/dwc3/gadget.c | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 5bfb625..8742d96 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -452,6 +452,9 @@
 
 #define DWC3_DSTS_RXFIFOEMPTY		BIT(17)
 
+#define DWC3_EVENT_PRAM_MAX_SOFFN      0x3fff
+#define DWC3_EVENT_PRAM_SOFFN_MASK     0x3fff
+
 #define DWC3_DSTS_SOFFN_MASK		(0x3fff << 3)
 #define DWC3_DSTS_SOFFN(n)		(((n) & DWC3_DSTS_SOFFN_MASK) >> 3)
 
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 9f92ee0..b63bd72 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1263,6 +1263,15 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)
 	return DWC3_DSTS_SOFFN(reg);
 }
 
+static bool __dwc3_gadget_target_frame_elapsed(struct dwc3_ep *dep)
+{
+	u16 cframe =  __dwc3_gadget_get_frame(dep->dwc);
+	u16 eframe = dep->frame_number & DWC3_EVENT_PRAM_SOFFN_MASK;
+
+	return (((eframe - cframe) & DWC3_EVENT_PRAM_SOFFN_MASK)
+		> DWC3_EVENT_PRAM_MAX_SOFFN / 2);
+}
+
 static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
 {
 	if (list_empty(&dep->pending_list)) {
@@ -1272,6 +1281,9 @@ static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
 		return;
 	}
 
+	while (__dwc3_gadget_target_frame_elapsed(dep))
+		dep->frame_number = DWC3_ALIGN_FRAME(dep);
+
 	dep->frame_number = DWC3_ALIGN_FRAME(dep);
 	__dwc3_gadget_kick_transfer(dep);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-12-17 20:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-14 16:32 [PATCH] usb: dwc3: gadget: fix miss isoc issue introduced by IRQ latency Zeng Tao
2018-12-14  8:51 ` Felipe Balbi
2018-12-14  9:11   ` Zengtao (B)
2018-12-14 11:23     ` Felipe Balbi
2018-12-14 21:42       ` Thinh Nguyen
2018-12-17  1:45         ` Zengtao (B)
2018-12-17 20:12           ` Thinh Nguyen
2018-12-14 11:17 ` Sergei Shtylyov
2018-12-17  1:54   ` Zengtao (B)

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