From patchwork Fri Dec 14 13:35:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 206502 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 9A1852C00B1 for ; Sat, 15 Dec 2012 01:15:02 +1100 (EST) Received: from localhost ([::1]:46381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVPB-0004na-Iw for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2012 08:34:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVOd-0003kP-Tt for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:33:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjVOc-0005IS-R1 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:33:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVOc-0005IL-Hh for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:33:46 -0500 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 qBEDXjJB011895 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 08:33:46 -0500 Received: from shalem.localdomain.com (vpn1-6-137.ams2.redhat.com [10.36.6.137]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBEDXSSq028567; Fri, 14 Dec 2012 08:33:44 -0500 From: Hans de Goede To: Gerd Hoffmann Date: Fri, 14 Dec 2012 14:35:33 +0100 Message-Id: <1355492147-5023-13-git-send-email-hdegoede@redhat.com> In-Reply-To: <1355492147-5023-1-git-send-email-hdegoede@redhat.com> References: <1355492147-5023-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 12/26] uhci: Fix 1 ms delay in interrupt reporting to the guest 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 Re-arrange how we process frames / increase frnum / report pending interrupts, to avoid a 1 ms delay in interrupt reporting to the guest. This increases the packet throughput for cases where the guest submits a single packet, then waits for its completion then re-submits from 500 pkts / sec to 1000 pkts / sec. This impacts for example the use of redirected / virtual usb to serial convertors. Signed-off-by: Hans de Goede --- hw/usb/hcd-uhci.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index d053791..843927b 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1191,17 +1191,7 @@ static void uhci_frame_timer(void *opaque) return; } - /* Complete the previous frame */ - if (s->pending_int_mask) { - s->status2 |= s->pending_int_mask; - s->status |= UHCI_STS_USBINT; - uhci_update_irq(s); - } - s->pending_int_mask = 0; - - /* Start new frame */ - s->frnum = (s->frnum + 1) & 0x7ff; - + /* Process the current frame */ trace_usb_uhci_frame_start(s->frnum); uhci_async_validate_begin(s); @@ -1210,6 +1200,18 @@ static void uhci_frame_timer(void *opaque) uhci_async_validate_end(s); + /* The uhci spec says frnum reflects the frame currently being processed, + * and the guest must look at frnum - 1 on interrupt, so inc frnum now */ + s->frnum = (s->frnum + 1) & 0x7ff; + + /* Complete the previous frame */ + if (s->pending_int_mask) { + s->status2 |= s->pending_int_mask; + s->status |= UHCI_STS_USBINT; + uhci_update_irq(s); + } + s->pending_int_mask = 0; + qemu_mod_timer(s->frame_timer, s->expire_time); }