From patchwork Fri May 25 12:40:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 161360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8633AB6EE6 for ; Sat, 26 May 2012 00:00:18 +1000 (EST) Received: from localhost ([::1]:33980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXtqS-0002mW-FT for incoming@patchwork.ozlabs.org; Fri, 25 May 2012 08:42:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXtp3-000064-Ix for qemu-devel@nongnu.org; Fri, 25 May 2012 08:40:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXtot-0001B7-IU for qemu-devel@nongnu.org; Fri, 25 May 2012 08:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXtot-00019q-AJ for qemu-devel@nongnu.org; Fri, 25 May 2012 08:40:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4PCeblP010872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 May 2012 08:40:38 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4PCeak0030812; Fri, 25 May 2012 08:40:37 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 24D4145753; Fri, 25 May 2012 14:40:35 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 25 May 2012 14:40:24 +0200 Message-Id: <1337949634-5264-10-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 08/18] ehci: move async schedule to bottom half X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This way we can kick the async schedule independant from the periodic frame timer. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index f363f14..16627d3 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -414,6 +414,7 @@ struct EHCIState { * Internal states, shadow registers, etc */ QEMUTimer *frame_timer; + QEMUBH *async_bh; int attach_poll_counter; int astate; // Current state in asynchronous schedule int pstate; // Current state in periodic schedule @@ -959,6 +960,7 @@ static void ehci_reset(void *opaque) ehci_queues_rip_all(s, 0); ehci_queues_rip_all(s, 1); qemu_del_timer(s->frame_timer); + qemu_bh_cancel(s->async_bh); } static uint32_t ehci_mem_readb(void *ptr, target_phys_addr_t addr) @@ -1111,6 +1113,7 @@ static void ehci_mem_writel(void *ptr, target_phys_addr_t addr, uint32_t val) if (!(val & USBCMD_RUNSTOP) && (s->usbcmd & USBCMD_RUNSTOP)) { qemu_del_timer(s->frame_timer); + qemu_bh_cancel(s->async_bh); ehci_queues_rip_all(s, 0); ehci_queues_rip_all(s, 1); ehci_set_usbsts(s, USBSTS_HALT); @@ -2290,11 +2293,16 @@ static void ehci_frame_timer(void *opaque) /* Async is not inside loop since it executes everything it can once * called */ - ehci_advance_async_state(ehci); + qemu_bh_schedule(ehci->async_bh); qemu_mod_timer(ehci->frame_timer, expire_time); } +static void ehci_async_bh(void *opaque) +{ + EHCIState *ehci = opaque; + ehci_advance_async_state(ehci); +} static const MemoryRegionOps ehci_mem_ops = { .old_mmio = { @@ -2430,6 +2438,7 @@ static int usb_ehci_initfn(PCIDevice *dev) } s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s); + s->async_bh = qemu_bh_new(ehci_async_bh, s); QTAILQ_INIT(&s->aqueues); QTAILQ_INIT(&s->pqueues);