From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXtox-0008Rv-99 for qemu-devel@nongnu.org; Fri, 25 May 2012 08:40:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXtou-0001Bz-B2 for qemu-devel@nongnu.org; Fri, 25 May 2012 08:40:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXtou-0001AI-3B for qemu-devel@nongnu.org; Fri, 25 May 2012 08:40:40 -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 q4PCecKk025397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 May 2012 08:40:38 -0400 From: Gerd Hoffmann Date: Fri, 25 May 2012 14:40:34 +0200 Message-Id: <1337949634-5264-20-git-send-email-kraxel@redhat.com> In-Reply-To: <1337949634-5264-1-git-send-email-kraxel@redhat.com> References: <1337949634-5264-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 18/18] 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