usb: dwc3: gadget: check if dep->frame_number is still valid
PATCH 2/4 usb: dwc3: gadget: check if dep->frame_number is still valid
Hi Felipe,
(CC'ing Kieran)
Thank you for the patch.
Quoted 44 lines · On Monday, 20 August 2018 13:29:59 EEST Felipe Balbi wrote:
Gadget driver may take an unbounded amount of time to queue requests after XferNotReady. This is important for isochronous endpoints which need to be started for a specific (micro-)frame.
Before kicking the transfer, let's check if current frame number is still less than our aligned frame number that we got from the previous XferNotReady. If it isn't, then we'll increment
dep->frame_numberto make sure it's ahead of current frame number.Signed-off-by Felipe Balbi <[email protected]>--- drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 11 +++++++++++ 2 files changed, 13 insertions(+)drivers/usb/dwc3/core.h +2
-0@@ -685,6 +685,8 @@ struct dwc3_ep {u8 type;u8 resource_index;u32 frame_number; +#define DWC3_EP_FRAME_NUMBER_MASK 0x3fff +u32 interval;char name[20 ];drivers/usb/dwc3/gadget.c +3
-0@@ -1257,6 +1257,9 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)static int __dwc3_gadget_start_isoc (struct dwc3_ep *dep) { +u16 current_frame_number; +u16 frame_number; +if (list_empty (&dep->pending_list)) {dev_info (dep->dwc->dev,"%s: ran out of requests\n" , dep->name);@@ -1265,6 +1268,14 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) }
drivers/usb/dwc3/gadget.c static int __dwc3_gadget_start_isoc(struct dwc3_ep · line 1278
Quoted 10 lines
drivers/usb/dwc3/gadget.c +8
-0dep->frame_number =DWC3_ALIGN_FRAME (dep); + current_frame_number =__dwc3_gadget_get_frame (dep->dwc); + frame_number = dep->frame_number &DWC3_EP_FRAME_NUMBER_MASK ; + +if (frame_number <= current_frame_number) { + dep->frame_number += current_frame_number - frame_number; + dep->frame_number =DWC3_ALIGN_FRAME (dep); + } +
This greatly improves the situation with the UVC function driver. However, we're still receiving errors from time to time related to missed transfer intervals, and those errors tend to occur in bursts. Kieran should be able to provide you with more information. Before acking this patch I would thus like to make sure that we're not missing part of the problem.
Quoted 2 lines
drivers/usb/dwc3/gadget.c +0
-0return __dwc3_gadget_kick_transfer (dep); }