Commit d5370106 authored by Felipe Balbi's avatar Felipe Balbi

usb: dwc3: gadget: check if dep->frame_number is still valid

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.

If we fail to start a transfer for isochronous endpoint, let's try
queueing to a future interval and see if that helps. We will stop trying
if we fail a start transfer for 5 intervals in the future.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 3451f6af
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#define DWC3_EP0_SETUP_SIZE 512 #define DWC3_EP0_SETUP_SIZE 512
#define DWC3_ENDPOINTS_NUM 32 #define DWC3_ENDPOINTS_NUM 32
#define DWC3_XHCI_RESOURCES_NUM 2 #define DWC3_XHCI_RESOURCES_NUM 2
#define DWC3_ISOC_MAX_RETRIES 5
#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ #define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */
#define DWC3_EVENT_BUFFERS_SIZE 4096 #define DWC3_EVENT_BUFFERS_SIZE 4096
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "gadget.h" #include "gadget.h"
#include "io.h" #include "io.h"
#define DWC3_ALIGN_FRAME(d) (((d)->frame_number + (d)->interval) \ #define DWC3_ALIGN_FRAME(d, n) (((d)->frame_number + ((d)->interval * (n))) \
& ~((d)->interval - 1)) & ~((d)->interval - 1))
/** /**
...@@ -1384,6 +1384,8 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) ...@@ -1384,6 +1384,8 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep)
static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
{ {
struct dwc3 *dwc = dep->dwc; struct dwc3 *dwc = dep->dwc;
int ret;
int i;
if (list_empty(&dep->pending_list)) { if (list_empty(&dep->pending_list)) {
dep->flags |= DWC3_EP_PENDING_REQUEST; dep->flags |= DWC3_EP_PENDING_REQUEST;
...@@ -1400,8 +1402,15 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) ...@@ -1400,8 +1402,15 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
return dwc3_gadget_start_isoc_quirk(dep); return dwc3_gadget_start_isoc_quirk(dep);
} }
dep->frame_number = DWC3_ALIGN_FRAME(dep); for (i = 0; i < DWC3_ISOC_MAX_RETRIES; i++) {
return __dwc3_gadget_kick_transfer(dep); dep->frame_number = DWC3_ALIGN_FRAME(dep, i + 1);
ret = __dwc3_gadget_kick_transfer(dep);
if (ret != -EAGAIN)
break;
}
return ret;
} }
static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment