qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 10/12] ehci: Add support for input queuing


From: Hans de Goede
Subject: [Qemu-devel] [PATCH 10/12] ehci: Add support for input queuing
Date: Mon, 8 Oct 2012 09:51:34 +0200

Signed-off-by: Hans de Goede <address@hidden>
---
 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);
-- 
1.7.12.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]