From patchwork Mon Oct 8 07:51:34 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: 189925 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 244EE2C00BD for ; Mon, 8 Oct 2012 18:51:22 +1100 (EST) Received: from localhost ([::1]:49014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TL87R-0003oQ-I4 for incoming@patchwork.ozlabs.org; Mon, 08 Oct 2012 03:51:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TL86e-000255-1q for qemu-devel@nongnu.org; Mon, 08 Oct 2012 03:50:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TL86Y-0006Mp-0K for qemu-devel@nongnu.org; Mon, 08 Oct 2012 03:50:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TL86X-0006Lu-OI for qemu-devel@nongnu.org; Mon, 08 Oct 2012 03:50:21 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q987oKHw001601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 8 Oct 2012 03:50:21 -0400 Received: from shalem.localdomain.com (vpn1-7-79.ams2.redhat.com [10.36.7.79]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q987o59m012329; Mon, 8 Oct 2012 03:50:19 -0400 From: Hans de Goede To: Gerd Hoffmann Date: Mon, 8 Oct 2012 09:51:34 +0200 Message-Id: <1349682696-3046-11-git-send-email-hdegoede@redhat.com> In-Reply-To: <1349682696-3046-1-git-send-email-hdegoede@redhat.com> References: <1349682696-3046-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 10/12] ehci: Add support for input queuing 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 Signed-off-by: Hans de Goede --- hw/usb/hcd-ehci.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index d9d4918..444db15 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -353,13 +353,13 @@ enum async_state { }; struct EHCIPacket { + USBPacket packet; EHCIQueue *queue; QTAILQ_ENTRY(EHCIPacket) next; EHCIqtd qtd; /* copy of current QTD (being worked on) */ uint32_t qtdaddr; /* address QTD read from */ - USBPacket packet; QEMUSGList sgl; int pid; enum async_state async; @@ -990,6 +990,21 @@ static void ehci_wakeup(USBPort *port) qemu_bh_schedule(s->async_bh); } +static void ehci_remove_from_queue(USBPort *port, USBPacket *usb_p) +{ + EHCIState *s = port->opaque; + uint32_t portsc = s->portsc[port->index]; + EHCIPacket *p = DO_UPCAST(EHCIPacket, packet, usb_p); + + if (portsc & PORTSC_POWNER) { + USBPort *companion = s->companion_ports[port->index]; + companion->ops->remove_from_queue(companion, usb_p); + return; + } + + ehci_free_packet(p); +} + static int ehci_register_companion(USBBus *bus, USBPort *ports[], uint32_t portcount, uint32_t firstport) { @@ -1021,6 +1036,8 @@ static int ehci_register_companion(USBBus *bus, USBPort *ports[], s->companion_ports[firstport + i] = ports[i]; s->ports[firstport + i].speedmask |= USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL; + /* Only claim to support queuing if our companion does too */ + s->ports[firstport + i].supports_queuing = ports[i]->supports_queuing; /* Ensure devs attached before the initial reset go to the companion */ s->portsc[firstport + i] = PORTSC_POWNER; } @@ -1580,6 +1597,10 @@ static int ehci_execute(EHCIPacket *p, const char *action) usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr); usb_packet_map(&p->packet, &p->sgl); + if (p->pid == USB_TOKEN_IN && NLPTR_TBIT(p->qtd.altnext) == 0) { + p->packet.short_not_ok = true; + } + p->packet.int_req = ((p->qtd.token & QTD_TOKEN_IOC) != 0); p->async = EHCI_ASYNC_INITIALIZED; } @@ -2071,7 +2092,8 @@ static int ehci_fill_queue(EHCIPacket *p) uint32_t qtdaddr; for (;;) { - if (NLPTR_TBIT(qtd.altnext) == 0) { + if (!usb_ep_input_pipeline(p->packet.ep) && + NLPTR_TBIT(qtd.altnext) == 0) { break; } if (NLPTR_TBIT(qtd.next) != 0) { @@ -2094,6 +2116,9 @@ static int ehci_fill_queue(EHCIPacket *p) assert(p->usb_status == USB_RET_ASYNC); p->async = EHCI_ASYNC_INFLIGHT; } + if (p->usb_status != USB_RET_PROCERR) { + usb_ep_process_queue(p->packet.ep); + } return p->usb_status; } @@ -2548,6 +2573,7 @@ static USBPortOps ehci_port_ops = { .child_detach = ehci_child_detach, .wakeup = ehci_wakeup, .complete = ehci_async_complete_packet, + .remove_from_queue = ehci_remove_from_queue, }; static USBBusOps ehci_bus_ops = { @@ -2740,6 +2766,7 @@ static int usb_ehci_initfn(PCIDevice *dev) usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops, USB_SPEED_MASK_HIGH); s->ports[i].dev = 0; + s->ports[i].supports_queuing = true; } s->frame_timer = qemu_new_timer_ns(vm_clock, ehci_frame_timer, s);