From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpJ8V-0005vd-GQ for qemu-devel@nongnu.org; Thu, 12 Jul 2012 09:08:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpJ8N-0007iv-2n for qemu-devel@nongnu.org; Thu, 12 Jul 2012 09:08:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpJ8M-0007if-Pt for qemu-devel@nongnu.org; Thu, 12 Jul 2012 09:08:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6CD8ggC018973 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Jul 2012 09:08:42 -0400 From: Gerd Hoffmann Date: Thu, 12 Jul 2012 15:08:39 +0200 Message-Id: <1342098519-23261-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1342098519-23261-1-git-send-email-kraxel@redhat.com> References: <1342098519-23261-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 6/6] ehci: improve expire time calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Move down the expire time calculation down in the frame timer, to the point where the timer is actually reloaded. This way we'll notice any async_stepdown changes (especially resetting to 0 due to usb activity). Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 6040e86..b043e7c 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2372,7 +2372,7 @@ static void ehci_frame_timer(void *opaque) if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) { need_timer++; - expire_time = t_now + (get_ticks_per_sec() / FRAME_TIMER_FREQ); + ehci->async_stepdown = 0; if (frames > ehci->maxframes) { skipped_frames = frames - ehci->maxframes; @@ -2391,8 +2391,6 @@ static void ehci_frame_timer(void *opaque) if (ehci->async_stepdown < ehci->maxframes / 2) { ehci->async_stepdown++; } - expire_time = t_now + (get_ticks_per_sec() - * ehci->async_stepdown / FRAME_TIMER_FREQ); ehci_update_frindex(ehci, frames); ehci->last_run_ns += FRAME_TIMER_NS * frames; } @@ -2402,7 +2400,7 @@ static void ehci_frame_timer(void *opaque) */ if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) { need_timer++; - qemu_bh_schedule(ehci->async_bh); + ehci_advance_async_state(ehci); } ehci_commit_irq(ehci); @@ -2412,6 +2410,8 @@ static void ehci_frame_timer(void *opaque) } if (need_timer) { + expire_time = t_now + (get_ticks_per_sec() + * (ehci->async_stepdown+1) / FRAME_TIMER_FREQ); qemu_mod_timer(ehci->frame_timer, expire_time); } } -- 1.7.1