From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOWVc-0003mg-68 for qemu-devel@nongnu.org; Mon, 23 May 2011 10:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOWVb-00046o-9Z for qemu-devel@nongnu.org; Mon, 23 May 2011 10:53:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOWVa-00046j-VS for qemu-devel@nongnu.org; Mon, 23 May 2011 10:53:27 -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 p4NErQoO010191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 May 2011 10:53:26 -0400 Message-ID: <4DDA74E2.4030401@redhat.com> Date: Mon, 23 May 2011 16:53:22 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1306143819-30287-1-git-send-email-kraxel@redhat.com> <1306143819-30287-18-git-send-email-kraxel@redhat.com> <4DDA6966.7050307@redhat.com> <4DDA7073.2060702@redhat.com> In-Reply-To: <4DDA7073.2060702@redhat.com> Content-Type: multipart/mixed; boundary="------------070204090008070706050406" Subject: Re: [Qemu-devel] [PATCH 17/18] usb: move cancel callback to USBDeviceInfo List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hans de Goede Cc: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------070204090008070706050406 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, > Good spotting, this is indeed a issue which needs fixing. It isn't > introduced by this patch though, it exists even without the usb patch > queue. Something like the attached patch should fix it. cheers, Gerd --------------070204090008070706050406 Content-Type: text/plain; name="fix" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix" diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index bc31850..e9993a7 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -234,6 +234,19 @@ static void uhci_async_validate_end(UHCIState *s) } } +static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev) +{ + UHCIAsync *curr, *n; + + QTAILQ_FOREACH_SAFE(curr, &s->async_pending, next, n) { + if (curr->packet.owner != dev) { + continue; + } + uhci_async_unlink(s, curr); + uhci_async_cancel(s, curr); + } +} + static void uhci_async_cancel_all(UHCIState *s) { UHCIAsync *curr, *n; @@ -1097,6 +1110,13 @@ static void uhci_map(PCIDevice *pci_dev, int region_num, register_ioport_read(addr, 32, 1, uhci_ioport_readb, s); } +static void uhci_device_destroy(USBBus *bus, USBDevice *dev) +{ + UHCIState *s = container_of(bus, UHCIState, bus); + + uhci_async_cancel_device(s, dev); +} + static USBPortOps uhci_port_ops = { .attach = uhci_attach, .detach = uhci_detach, @@ -1104,6 +1124,10 @@ static USBPortOps uhci_port_ops = { .complete = uhci_async_complete, }; +static USBBusOps uhci_bus_ops = { + .device_destroy = uhci_device_destroy, +}; + static int usb_uhci_common_initfn(UHCIState *s) { uint8_t *pci_conf = s->dev.config; @@ -1116,7 +1140,7 @@ static int usb_uhci_common_initfn(UHCIState *s) pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3 pci_conf[0x60] = 0x10; // release number - usb_bus_new(&s->bus, &s->dev.qdev); + usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev); for(i = 0; i < NB_PORTS; i++) { usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops, USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); diff --git a/hw/usb.h b/hw/usb.h index 0fa86a3..097d789 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -139,6 +139,7 @@ #define USB_ENDPOINT_XFER_INT 3 typedef struct USBBus USBBus; +typedef struct USBBusOps USBBusOps; typedef struct USBPort USBPort; typedef struct USBDevice USBDevice; typedef struct USBDeviceInfo USBDeviceInfo; @@ -330,6 +331,7 @@ void musb_set_size(MUSBState *s, int epnum, int size, int is_tx); struct USBBus { BusState qbus; + USBBusOps *ops; int busnr; int nfree; int nused; @@ -338,7 +340,11 @@ struct USBBus { QTAILQ_ENTRY(USBBus) next; }; -void usb_bus_new(USBBus *bus, DeviceState *host); +struct USBBusOps { + void (*device_destroy)(USBBus *bus, USBDevice *dev); +}; + +void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host); USBBus *usb_bus_find(int busnr); void usb_qdev_register(USBDeviceInfo *info); void usb_qdev_register_many(USBDeviceInfo *info); --------------070204090008070706050406--