[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 08/10] usb-xhci: add exit function
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v3 08/10] usb-xhci: add exit function |
Date: |
Wed, 4 Jun 2014 16:31:53 +0800 |
From: Gonglei <address@hidden>
clean up xhci resource when xhci pci device exit.
Signed-off-by: Gonglei <address@hidden>
---
hw/usb/hcd-xhci.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 7f2af89..85ff5d0 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3644,6 +3644,51 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
return 0;
}
+static void usb_xhci_exit(PCIDevice *dev)
+{
+ int i;
+ XHCIState *xhci = XHCI(dev);
+
+ for (i = 0; i < xhci->numslots; i++) {
+ xhci_disable_slot(xhci, i + 1);
+ }
+
+ if (xhci->mfwrap_timer) {
+ timer_del(xhci->mfwrap_timer);
+ timer_free(xhci->mfwrap_timer);
+ xhci->mfwrap_timer = NULL;
+ }
+
+ memory_region_del_subregion(&xhci->mem, &xhci->mem_cap);
+ memory_region_del_subregion(&xhci->mem, &xhci->mem_oper);
+ memory_region_del_subregion(&xhci->mem, &xhci->mem_runtime);
+ memory_region_del_subregion(&xhci->mem, &xhci->mem_doorbell);
+
+ memory_region_destroy(&xhci->mem_cap);
+ memory_region_destroy(&xhci->mem_oper);
+ memory_region_destroy(&xhci->mem_runtime);
+ memory_region_destroy(&xhci->mem_doorbell);
+
+ for (i = 0; i < xhci->numports; i++) {
+ XHCIPort *port = &xhci->ports[i];
+ memory_region_del_subregion(&xhci->mem, &port->mem);
+ memory_region_destroy(&port->mem);
+ }
+
+ /* destroy msix memory region */
+ if (dev->msix_table && dev->msix_pba
+ && dev->msix_entry_used) {
+ memory_region_del_subregion(&xhci->mem, &dev->msix_table_mmio);
+ memory_region_destroy(&dev->msix_table_mmio);
+ memory_region_del_subregion(&xhci->mem, &dev->msix_pba_mmio);
+ memory_region_destroy(&dev->msix_pba_mmio);
+ }
+
+ memory_region_destroy(&xhci->mem);
+
+ usb_bus_release(&xhci->bus);
+}
+
static int usb_xhci_post_load(void *opaque, int version_id)
{
XHCIState *xhci = opaque;
@@ -3835,6 +3880,7 @@ static void xhci_class_init(ObjectClass *klass, void
*data)
dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_USB, dc->categories);
k->init = usb_xhci_initfn;
+ k->exit = usb_xhci_exit;
k->vendor_id = PCI_VENDOR_ID_NEC;
k->device_id = PCI_DEVICE_ID_NEC_UPD720200;
k->class_id = PCI_CLASS_SERIAL_USB;
--
1.7.12.4
- [Qemu-devel] [PATCH v3 00/10] usb: usb host adapter hotplug, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 09/10] usb: tag usb host controller as hotpluggable, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 03/10] usb-ohci: add exit function, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 01/10] usb: add usb_bus_release function, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 06/10] usb-ehci: add ehci unrealize funciton, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 08/10] usb-xhci: add exit function,
arei.gonglei <=
- [Qemu-devel] [PATCH v3 02/10] usb-ohci: Fix memory leak for ohci timer, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 05/10] usb-ehci: add vmstate properity for EHCIState, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 04/10] usb-uhci: clean up uhci resource when pci-uhci exit, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 10/10] usb: add usb host adapters exit trace, arei.gonglei, 2014/06/04
- [Qemu-devel] [PATCH v3 07/10] usb-ehci: add ehci-pci device exit function, arei.gonglei, 2014/06/04
- Re: [Qemu-devel] [PATCH v3 00/10] usb: usb host adapter hotplug, Gonglei (Arei), 2014/06/11