@@ -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);
Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- hw/usb/hcd-ehci.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)