Browse Source

usb: dwc3: optimize interrupt loop

There is no point in calling dwc3_thread_interrupt() if no event is
pending. There is also no point in flushing event cache in EVERY loop
iteration.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Marek Szyprowski 10 years ago
parent
commit
137f7c590d
2 changed files with 13 additions and 9 deletions
  1. 0 7
      drivers/usb/dwc3/core.c
  2. 13 2
      drivers/usb/dwc3/gadget.c

+ 0 - 7
drivers/usb/dwc3/core.c

@@ -769,18 +769,11 @@ void dwc3_uboot_exit(int index)
 void dwc3_uboot_handle_interrupt(int index)
 void dwc3_uboot_handle_interrupt(int index)
 {
 {
 	struct dwc3 *dwc = NULL;
 	struct dwc3 *dwc = NULL;
-	int i;
-	struct dwc3_event_buffer *evt;
 
 
 	list_for_each_entry(dwc, &dwc3_list, list) {
 	list_for_each_entry(dwc, &dwc3_list, list) {
 		if (dwc->index != index)
 		if (dwc->index != index)
 			continue;
 			continue;
 
 
-		for (i = 0; i < dwc->num_event_buffers; i++) {
-			evt = dwc->ev_buffs[i];
-			dwc3_flush_cache((int)evt->buf, evt->length);
-		}
-
 		dwc3_gadget_uboot_handle_interrupt(dwc);
 		dwc3_gadget_uboot_handle_interrupt(dwc);
 		break;
 		break;
 	}
 	}

+ 13 - 2
drivers/usb/dwc3/gadget.c

@@ -2683,6 +2683,17 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
  */
  */
 void dwc3_gadget_uboot_handle_interrupt(struct dwc3 *dwc)
 void dwc3_gadget_uboot_handle_interrupt(struct dwc3 *dwc)
 {
 {
-	dwc3_interrupt(0, dwc);
-	dwc3_thread_interrupt(0, dwc);
+	int ret = dwc3_interrupt(0, dwc);
+
+	if (ret == IRQ_WAKE_THREAD) {
+		int i;
+		struct dwc3_event_buffer *evt;
+
+		for (i = 0; i < dwc->num_event_buffers; i++) {
+			evt = dwc->ev_buffs[i];
+			dwc3_flush_cache((int)evt->buf, evt->length);
+		}
+
+		dwc3_thread_interrupt(0, dwc);
+	}
 }
 }