From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScZ4E-0000SF-Qr for qemu-devel@nongnu.org; Thu, 07 Jun 2012 05:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScZ41-0004HO-SJ for qemu-devel@nongnu.org; Thu, 07 Jun 2012 05:31:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScZ41-0004Fw-Kf for qemu-devel@nongnu.org; Thu, 07 Jun 2012 05:31:33 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q579VWkd024171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Jun 2012 05:31:32 -0400 From: Gerd Hoffmann Date: Thu, 7 Jun 2012 11:31:26 +0200 Message-Id: <1339061486-28513-38-git-send-email-kraxel@redhat.com> In-Reply-To: <1339061486-28513-1-git-send-email-kraxel@redhat.com> References: <1339061486-28513-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 37/37] ehci: rework frame skipping List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Move the framecount check out of the loop and use the new ehci_update_frindex function to skip frames if needed. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 25 ++++++++++--------------- 1 files changed, 10 insertions(+), 15 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index d97c539..5298204 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2315,9 +2315,8 @@ static void ehci_frame_timer(void *opaque) int schedules = 0; int64_t expire_time, t_now; uint64_t ns_elapsed; - int frames; + int frames, skipped_frames; int i; - int skipped_frames = 0; t_now = qemu_get_clock_ns(vm_clock); ns_elapsed = t_now - ehci->last_run_ns; @@ -2327,15 +2326,17 @@ static void ehci_frame_timer(void *opaque) schedules++; expire_time = t_now + (get_ticks_per_sec() / FRAME_TIMER_FREQ); + if (frames > ehci->maxframes) { + skipped_frames = frames - ehci->maxframes; + ehci_update_frindex(ehci, skipped_frames); + ehci->last_run_ns += FRAME_TIMER_NS * skipped_frames; + frames -= skipped_frames; + DPRINTF("WARNING - EHCI skipped %d frames\n", skipped_frames); + } + for (i = 0; i < frames; i++) { ehci_update_frindex(ehci, 1); - - if (frames - i > ehci->maxframes) { - skipped_frames++; - } else { - ehci_advance_periodic_state(ehci); - } - + ehci_advance_periodic_state(ehci); ehci->last_run_ns += FRAME_TIMER_NS; } } else { @@ -2348,12 +2349,6 @@ static void ehci_frame_timer(void *opaque) ehci->last_run_ns += FRAME_TIMER_NS * frames; } -#if 0 - if (skipped_frames) { - DPRINTF("WARNING - EHCI skipped %d frames\n", skipped_frames); - } -#endif - /* Async is not inside loop since it executes everything it can once * called */ -- 1.7.1