From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXr4S-0000yR-GL for qemu-devel@nongnu.org; Fri, 25 May 2012 05:44:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXr4N-0000bu-3x for qemu-devel@nongnu.org; Fri, 25 May 2012 05:44:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXr4M-0000b6-Se for qemu-devel@nongnu.org; Fri, 25 May 2012 05:44:27 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4P9iOQX015062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 May 2012 05:44:24 -0400 From: Gerd Hoffmann Date: Fri, 25 May 2012 11:44:13 +0200 Message-Id: <1337939061-13629-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1337939061-13629-1-git-send-email-kraxel@redhat.com> References: <1337939061-13629-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 02/10] uhci: use bottom half List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Schedule bottom half on completion of async packets instead of calling uhci_process_frame directly. This way we run uhci_process_frame only once in case multiple packets finish in a row. Also check whenever there is bandwidth left before scheduling uhci_process_frame. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 48ad35c..91bcc7e 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -131,6 +131,7 @@ struct UHCIState { uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */ int64_t expire_time; QEMUTimer *frame_timer; + QEMUBH *bh; uint32_t frame_bytes; UHCIPort ports[NB_PORTS]; @@ -370,6 +371,7 @@ static void uhci_reset(void *opaque) } uhci_async_cancel_all(s); + qemu_bh_cancel(s->bh); uhci_update_irq(s); } @@ -906,7 +908,9 @@ static void uhci_async_complete(USBPort *port, USBPacket *packet) uhci_async_free(async); } else { async->done = 1; - uhci_process_frame(s); + if (s->frame_bytes < 1280) { + qemu_bh_schedule(s->bh); + } } } @@ -1113,6 +1117,12 @@ out: s->pending_int_mask |= int_mask; } +static void uhci_bh(void *opaque) +{ + UHCIState *s = opaque; + uhci_process_frame(s); +} + static void uhci_frame_timer(void *opaque) { UHCIState *s = opaque; @@ -1120,6 +1130,7 @@ static void uhci_frame_timer(void *opaque) /* prepare the timer for the next frame */ s->expire_time += (get_ticks_per_sec() / FRAME_TIMER_FREQ); s->frame_bytes = 0; + qemu_bh_cancel(s->bh); if (!(s->cmd & UHCI_CMD_RS)) { /* Full stop */ @@ -1206,6 +1217,7 @@ static int usb_uhci_common_initfn(PCIDevice *dev) USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); } } + s->bh = qemu_bh_new(uhci_bh, s); s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s); s->num_ports_vmstate = NB_PORTS; QTAILQ_INIT(&s->queues); -- 1.7.1