qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/8] ehci: Lower timer freq when there are no iso pa


From: Hans de Goede
Subject: [Qemu-devel] [PATCH 5/8] ehci: Lower timer freq when there are no iso packets in the periodic schedule
Date: Tue, 6 Nov 2012 15:08:18 +0100

If there are no iso packets in the periodic schedule, then there can only
be interrupt packets there, and for these usb-devices either return nak,
meaning that the executing state will get passed every frame, causing
async_stepdown to stay 0, or they are handled async, and then ehci_frame_timer
will get called immediately from a bh, thus not introducing any latency
to async handled interrupt packets.

The advantage of this is that when we only have async handled interrupt
packets in the periodic schedule, async_stepdown can do its work and
significantly lower the frequency at which the frame_timer runs.

Signed-off-by: Hans de Goede <address@hidden>
---
 hw/usb/hcd-ehci.c | 18 ++++++++++++++----
 hw/usb/hcd-ehci.h |  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index ee6c9ae..b804474 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -114,6 +114,7 @@
 #define BUFF_SIZE        5*4096   // Max bytes to transfer per transaction
 #define MAX_QH           100      // Max allowable queue heads in a chain
 #define MIN_FR_PER_TICK  3        // Min frames to process when catching up
+#define ISO_ACTIVE_COUNT 64
 
 /*  Internal periodic / asynchronous schedule state machine states
  */
@@ -1325,6 +1326,8 @@ static int ehci_process_itd(EHCIState *ehci,
     uint32_t i, len, pid, dir, devaddr, endp;
     uint32_t pg, off, ptr1, ptr2, max, mult;
 
+    ehci->iso_active_counter = ISO_ACTIVE_COUNT;
+
     dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
     devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
     endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
@@ -2157,9 +2160,12 @@ static void ehci_frame_timer(void *opaque)
     ns_elapsed = t_now - ehci->last_run_ns;
     frames = ns_elapsed / FRAME_TIMER_NS;
 
+    if (ehci->async_stepdown < ehci->maxframes / 2) {
+        ehci->async_stepdown++;
+    }
+
     if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) {
         need_timer++;
-        ehci->async_stepdown = 0;
 
         if (frames > ehci->maxframes) {
             skipped_frames = frames - ehci->maxframes;
@@ -2183,14 +2189,18 @@ static void ehci_frame_timer(void *opaque)
                     break;
                 }
             }
+            if (ehci->iso_active_counter) {
+                ehci->iso_active_counter--;
+            }
             ehci_update_frindex(ehci, 1);
             ehci_advance_periodic_state(ehci);
             ehci->last_run_ns += FRAME_TIMER_NS;
         }
-    } else {
-        if (ehci->async_stepdown < ehci->maxframes / 2) {
-            ehci->async_stepdown++;
+
+        if (ehci->iso_active_counter) {
+            ehci->async_stepdown = 0;
         }
+    } else {
         ehci_update_frindex(ehci, frames);
         ehci->last_run_ns += FRAME_TIMER_NS * frames;
     }
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index d8078f4..ed9d89c 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -311,6 +311,7 @@ struct EHCIState {
 
     uint64_t last_run_ns;
     uint32_t async_stepdown;
+    uint32_t iso_active_counter;
     bool int_req_by_async;
 };
 
-- 
1.7.12.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]