[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 06/10] usb-ehci: add ehci unrealize funciton
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v3 06/10] usb-ehci: add ehci unrealize funciton |
Date: |
Wed, 4 Jun 2014 16:31:51 +0800 |
From: Gonglei <address@hidden>
cleanup ehci controller resource, both pci and sysbus
if they're necessary.
Signed-off-by: Gonglei <address@hidden>
---
hw/usb/hcd-ehci.c | 29 +++++++++++++++++++++++++++++
hw/usb/hcd-ehci.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 76e939d..172ca04 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2471,6 +2471,35 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev,
Error **errp)
s->vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
}
+void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp)
+{
+ if (s->frame_timer) {
+ timer_del(s->frame_timer);
+ timer_free(s->frame_timer);
+ s->frame_timer = NULL;
+ }
+ if (s->async_bh) {
+ qemu_bh_delete(s->async_bh);
+ }
+
+ ehci_queues_rip_all(s, 0);
+ ehci_queues_rip_all(s, 1);
+
+ memory_region_del_subregion(&s->mem, &s->mem_caps);
+ memory_region_del_subregion(&s->mem, &s->mem_opreg);
+ memory_region_del_subregion(&s->mem, &s->mem_ports);
+ memory_region_destroy(&s->mem_caps);
+ memory_region_destroy(&s->mem_opreg);
+ memory_region_destroy(&s->mem_ports);
+ memory_region_destroy(&s->mem);
+
+ usb_bus_release(&s->bus);
+
+ if (s->vmstate) {
+ qemu_del_vm_change_state_handler(s->vmstate);
+ }
+}
+
void usb_ehci_init(EHCIState *s, DeviceState *dev)
{
/* 2.2 host controller interface version */
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 594d9d3..4858b7e 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -323,6 +323,7 @@ extern const VMStateDescription vmstate_ehci;
void usb_ehci_init(EHCIState *s, DeviceState *dev);
void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp);
+void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp);
#define TYPE_PCI_EHCI "pci-ehci-usb"
#define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)
--
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 <=
- [Qemu-devel] [PATCH v3 08/10] usb-xhci: add exit function, arei.gonglei, 2014/06/04
- [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