diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2011-05-23 17:37:12 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2011-06-14 12:56:49 +0200 |
commit | 07771f6fcebdb12de6dca537423f56299ed9b4b9 (patch) | |
tree | 374f2b5049bf5dc38984921b76250c590ab65403 /hw/usb-ehci.c | |
parent | 8e4faf3de9d1a8bd3289e5cc69d4ed206e2ed0cf (diff) | |
download | qemu-07771f6fcebdb12de6dca537423f56299ed9b4b9.zip qemu-07771f6fcebdb12de6dca537423f56299ed9b4b9.tar.gz qemu-07771f6fcebdb12de6dca537423f56299ed9b4b9.tar.bz2 |
usb: cancel async packets on unplug
This patch adds USBBusOps struct with (for now) only a single callback
which is called when a device is about to be destroyed. The USB Host
adapters are implementing this callback and use it to cancel any async
requests which might be in flight before the device actually goes away.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb-ehci.c')
-rw-r--r-- | hw/usb-ehci.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index dd2752d..9051571 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -685,6 +685,18 @@ static void ehci_queues_rip_unused(EHCIState *ehci) } } +static void ehci_queues_rip_device(EHCIState *ehci, USBDevice *dev) +{ + EHCIQueue *q, *tmp; + + QTAILQ_FOREACH_SAFE(q, &ehci->queues, next, tmp) { + if (q->packet.owner != dev) { + continue; + } + ehci_free_queue(q); + } +} + static void ehci_queues_rip_all(EHCIState *ehci) { EHCIQueue *q, *tmp; @@ -2100,6 +2112,13 @@ static void ehci_map(PCIDevice *pci_dev, int region_num, cpu_register_physical_memory(addr, size, s->mem); } +static void ehci_device_destroy(USBBus *bus, USBDevice *dev) +{ + EHCIState *s = container_of(bus, EHCIState, bus); + + ehci_queues_rip_device(s, dev); +} + static int usb_ehci_initfn(PCIDevice *dev); static USBPortOps ehci_port_ops = { @@ -2108,6 +2127,10 @@ static USBPortOps ehci_port_ops = { .complete = ehci_async_complete_packet, }; +static USBBusOps ehci_bus_ops = { + .device_destroy = ehci_device_destroy, +}; + static PCIDeviceInfo ehci_info = { .qdev.name = "usb-ehci", .qdev.size = sizeof(EHCIState), @@ -2170,7 +2193,7 @@ static int usb_ehci_initfn(PCIDevice *dev) s->irq = s->dev.irq[3]; - usb_bus_new(&s->bus, &s->dev.qdev); + usb_bus_new(&s->bus, &ehci_bus_ops, &s->dev.qdev); for(i = 0; i < NB_PORTS; i++) { usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops, USB_SPEED_MASK_HIGH); |