* [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug
@ 2014-06-03 10:54 arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 1/9] usb: add usb_bus_release function arei.gonglei
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
add support for usb host adapter hotplug, as the same
as other pci devices.
changes since v1:
* rework usb_bus_release function suggested by Gerd.
* add more completely resource cleanup for every usb host adapter.
* fix memory leak.
Gonglei (9):
usb: add usb_bus_release function
usb-ohci: Fix memory leak for ohci timer
usb-ohci: add exit function
usb-uhci: clean up uhci resource when pci-uhci exit
usb-ehci: add vmstate properity for EHCIState
usb-ehci: expose ehci_queues_rip_all
usb-ehci: add ehci-pci device exit function
usb-xhci: add exit function
usb: tag usb host controller as hotpluggable
hw/usb/bus.c | 7 +++++++
hw/usb/hcd-ehci-pci.c | 34 +++++++++++++++++++++++++++++++++-
hw/usb/hcd-ehci.c | 4 ++--
hw/usb/hcd-ehci.h | 2 ++
hw/usb/hcd-ohci.c | 26 ++++++++++++++++++++++++--
hw/usb/hcd-uhci.c | 17 ++++++++++++++++-
hw/usb/hcd-xhci.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
include/hw/usb.h | 1 +
8 files changed, 131 insertions(+), 7 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 1/9] usb: add usb_bus_release function
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 2/9] usb-ohci: Fix memory leak for ohci timer arei.gonglei
` (8 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
add global variables releasing logic when the usb buses
were removed or hot-unpluged.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/bus.c | 7 +++++++
include/hw/usb.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 927a47b..84e8bb4 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -87,6 +87,13 @@ void usb_bus_new(USBBus *bus, size_t bus_size,
QTAILQ_INSERT_TAIL(&busses, bus, next);
}
+void usb_bus_release(USBBus *bus)
+{
+ assert(next_usb_bus > 0);
+
+ QTAILQ_REMOVE(&busses, bus, next);
+}
+
USBBus *usb_bus_find(int busnr)
{
USBBus *bus;
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 1919bdc..f0f9e73 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -523,6 +523,7 @@ struct USBBusOps {
void usb_bus_new(USBBus *bus, size_t bus_size,
USBBusOps *ops, DeviceState *host);
+void usb_bus_release(USBBus *bus);
USBBus *usb_bus_find(int busnr);
void usb_legacy_register(const char *typename, const char *usbdevice_name,
USBDevice *(*usbdevice_init)(USBBus *bus,
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 2/9] usb-ohci: Fix memory leak for ohci timer
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 1/9] usb: add usb_bus_release function arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 3/9] usb-ohci: add exit function arei.gonglei
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-ohci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index cd87074..dc1adbf 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1371,8 +1371,10 @@ static int ohci_bus_start(OHCIState *ohci)
/* Stop sending SOF tokens on the bus */
static void ohci_bus_stop(OHCIState *ohci)
{
- if (ohci->eof_timer)
+ if (ohci->eof_timer) {
timer_del(ohci->eof_timer);
+ timer_free(ohci->eof_timer);
+ }
ohci->eof_timer = NULL;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 3/9] usb-ohci: add exit function
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 1/9] usb: add usb_bus_release function arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 2/9] usb-ohci: Fix memory leak for ohci timer arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 4/9] usb-uhci: clean up uhci resource when pci-uhci exit arei.gonglei
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
clean up ohci resource when ohci pci device exit
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-ohci.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index dc1adbf..b513a13 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1954,6 +1954,26 @@ static int usb_ohci_initfn_pci(PCIDevice *dev)
return 0;
}
+static void usb_ohci_exit(PCIDevice *dev)
+{
+ OHCIPCIState *ohci = PCI_OHCI(dev);
+ OHCIState *s = &ohci->state;
+
+ ohci_bus_stop(s);
+
+ if (s->async_td) {
+ usb_cancel_packet(&s->usb_packet);
+ s->async_td = 0;
+ }
+ ohci_stop_endpoints(s);
+
+ memory_region_destroy(&s->mem);
+
+ if (!ohci->masterbus) {
+ usb_bus_release(&s->bus);
+ }
+}
+
#define TYPE_SYSBUS_OHCI "sysbus-ohci"
#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
@@ -2094,6 +2114,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = usb_ohci_initfn_pci;
+ k->exit = usb_ohci_exit;
k->vendor_id = PCI_VENDOR_ID_APPLE;
k->device_id = PCI_DEVICE_ID_APPLE_IPID_USB;
k->class_id = PCI_CLASS_SERIAL_USB;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 4/9] usb-uhci: clean up uhci resource when pci-uhci exit
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (2 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 3/9] usb-ohci: add exit function arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 5/9] usb-ehci: add vmstate properity for EHCIState arei.gonglei
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
clean up uhci resource when uhci pci device exit.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-uhci.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 9b1166b..4697a2d 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1294,7 +1294,23 @@ static void usb_uhci_exit(PCIDevice *dev)
{
UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
+ if (s->frame_timer) {
+ timer_del(s->frame_timer);
+ timer_free(s->frame_timer);
+ s->frame_timer = NULL;
+ }
+
+ if (s->bh) {
+ qemu_bh_delete(s->bh);
+ }
+
+ uhci_async_cancel_all(s);
+
memory_region_destroy(&s->io_bar);
+
+ if (!s->masterbus) {
+ usb_bus_release(&s->bus);
+ }
}
static Property uhci_properties[] = {
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 5/9] usb-ehci: add vmstate properity for EHCIState
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (3 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 4/9] usb-uhci: clean up uhci resource when pci-uhci exit arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 6/9] usb-ehci: expose ehci_queues_rip_all arei.gonglei
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
since hotunplug the ehci host adapter, we should
delete vm_change_state_handler also, so the
VMChangeStateEntry should be saved in EHCIState.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-ehci.c | 2 +-
hw/usb/hcd-ehci.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index a3ae9f2..0e7cd3b 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2545,7 +2545,7 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
s->device = dev;
qemu_register_reset(ehci_reset, s);
- qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
+ s->vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
}
void usb_ehci_init(EHCIState *s, DeviceState *dev)
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 1ad4b96..594d9d3 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -316,6 +316,7 @@ struct EHCIState {
uint32_t async_stepdown;
uint32_t periodic_sched_active;
bool int_req_by_async;
+ VMChangeStateEntry *vmstate;
};
extern const VMStateDescription vmstate_ehci;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 6/9] usb-ehci: expose ehci_queues_rip_all
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (4 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 5/9] usb-ehci: add vmstate properity for EHCIState arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function arei.gonglei
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
As for usb-ehci-pci.c can call the function to
free ehci queue.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-ehci.c | 2 +-
hw/usb/hcd-ehci.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 0e7cd3b..a585a94 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -746,7 +746,7 @@ static void ehci_queues_rip_device(EHCIState *ehci, USBDevice *dev, int async)
}
}
-static void ehci_queues_rip_all(EHCIState *ehci, int async)
+void ehci_queues_rip_all(EHCIState *ehci, int async)
{
EHCIQueueHead *head = async ? &ehci->aqueues : &ehci->pqueues;
const char *warn = async ? "guest stopped busy async schedule" : NULL;
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 594d9d3..19e079e 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 ehci_queues_rip_all(EHCIState *ehci, int async);
#define TYPE_PCI_EHCI "pci-ehci-usb"
#define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (5 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 6/9] usb-ehci: expose ehci_queues_rip_all arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-04 6:09 ` Gerd Hoffmann
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 8/9] usb-xhci: add " arei.gonglei
` (2 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
clean up ehci resource when ehci pci device exit.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-ehci-pci.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 505741a..115d9b5 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -84,6 +84,38 @@ static void usb_ehci_pci_init(Object *obj)
usb_ehci_init(s, DEVICE(obj));
}
+static void usb_ehci_pci_exit(PCIDevice *dev)
+{
+ EHCIPCIState *i = PCI_EHCI(dev);
+ EHCIState *s = &i->ehci;
+
+ 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);
+ }
+}
+
static void usb_ehci_pci_write_config(PCIDevice *dev, uint32_t addr,
uint32_t val, int l)
{
@@ -121,6 +153,7 @@ static void ehci_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = usb_ehci_pci_initfn;
+ k->exit = usb_ehci_pci_exit;
k->class_id = PCI_CLASS_SERIAL_USB;
k->config_write = usb_ehci_pci_write_config;
dc->hotpluggable = false;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 8/9] usb-xhci: add exit function
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (6 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 9/9] usb: tag usb host controller as hotpluggable arei.gonglei
2014-06-04 6:11 ` [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug Gerd Hoffmann
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
clean up xhci resource when xhci pci device exit.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
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 54dea16..da8a1fb 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3617,6 +3617,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;
@@ -3806,6 +3851,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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 9/9] usb: tag usb host controller as hotpluggable
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (7 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 8/9] usb-xhci: add " arei.gonglei
@ 2014-06-03 10:54 ` arei.gonglei
2014-06-04 6:11 ` [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug Gerd Hoffmann
9 siblings, 0 replies; 14+ messages in thread
From: arei.gonglei @ 2014-06-03 10:54 UTC (permalink / raw)
To: qemu-devel; +Cc: weidong.huang, Gonglei, luonengjun, kraxel, peter.huangpeng
From: Gonglei <arei.gonglei@huawei.com>
usb host controller should be able to support hotplug/unplug,
as the same as the other pci devices, which not enable
multifunction capability.
BTW, the qemu have not the capability to support
hotplug mulitfuncition pci devices at present.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/hcd-ehci-pci.c | 1 -
hw/usb/hcd-ohci.c | 1 -
hw/usb/hcd-uhci.c | 1 -
hw/usb/hcd-xhci.c | 1 -
4 files changed, 4 deletions(-)
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 115d9b5..319fbb9 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -156,7 +156,6 @@ static void ehci_class_init(ObjectClass *klass, void *data)
k->exit = usb_ehci_pci_exit;
k->class_id = PCI_CLASS_SERIAL_USB;
k->config_write = usb_ehci_pci_write_config;
- dc->hotpluggable = false;
dc->vmsd = &vmstate_ehci_pci;
dc->props = ehci_pci_properties;
}
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index b513a13..5dfcb6f 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -2121,7 +2121,6 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_USB, dc->categories);
dc->desc = "Apple USB Controller";
dc->props = ohci_pci_properties;
- dc->hotpluggable = false;
dc->vmsd = &vmstate_ohci;
}
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 4697a2d..7f0d447 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1334,7 +1334,6 @@ static void uhci_class_init(ObjectClass *klass, void *data)
k->device_id = info->device_id;
k->revision = info->revision;
k->class_id = PCI_CLASS_SERIAL_USB;
- dc->hotpluggable = false;
dc->vmsd = &vmstate_uhci;
dc->props = uhci_properties;
set_bit(DEVICE_CATEGORY_USB, dc->categories);
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index da8a1fb..c3ffa2f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3848,7 +3848,6 @@ static void xhci_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_xhci;
dc->props = xhci_properties;
dc->reset = xhci_reset;
- dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_USB, dc->categories);
k->init = usb_xhci_initfn;
k->exit = usb_xhci_exit;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function arei.gonglei
@ 2014-06-04 6:09 ` Gerd Hoffmann
2014-06-04 6:22 ` Gonglei (Arei)
0 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2014-06-04 6:09 UTC (permalink / raw)
To: arei.gonglei; +Cc: weidong.huang, luonengjun, qemu-devel, peter.huangpeng
On Di, 2014-06-03 at 18:54 +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> clean up ehci resource when ehci pci device exit.
>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> hw/usb/hcd-ehci-pci.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
> index 505741a..115d9b5 100644
> --- a/hw/usb/hcd-ehci-pci.c
> +++ b/hw/usb/hcd-ehci-pci.c
> @@ -84,6 +84,38 @@ static void usb_ehci_pci_init(Object *obj)
> usb_ehci_init(s, DEVICE(obj));
> }
>
> +static void usb_ehci_pci_exit(PCIDevice *dev)
> +{
Too much non-pci stuff in here. I think we should create a
usb_ehci_unrealize function and do the cleanup there, then just call
this from usb_ehci_pci_exit. You also don't need patch #6 then.
cheers,
Gerd
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
` (8 preceding siblings ...)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 9/9] usb: tag usb host controller as hotpluggable arei.gonglei
@ 2014-06-04 6:11 ` Gerd Hoffmann
2014-06-04 6:40 ` Gonglei (Arei)
9 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2014-06-04 6:11 UTC (permalink / raw)
To: arei.gonglei; +Cc: weidong.huang, luonengjun, qemu-devel, peter.huangpeng
Hi,
> changes since v1:
> * add more completely resource cleanup for every usb host adapter.
Looks good overall. How did you test this?
cheers,
Gerd
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function
2014-06-04 6:09 ` Gerd Hoffmann
@ 2014-06-04 6:22 ` Gonglei (Arei)
0 siblings, 0 replies; 14+ messages in thread
From: Gonglei (Arei) @ 2014-06-04 6:22 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Huangweidong (C), Luonengjun, qemu-devel@nongnu.org,
Huangpeng (Peter)
> -----Original Message-----
> From: Gerd Hoffmann [mailto:kraxel@redhat.com]
> Sent: Wednesday, June 04, 2014 2:10 PM
> To: Gonglei (Arei)
> Cc: qemu-devel@nongnu.org; Luonengjun; Huangweidong (C); Huangpeng
> (Peter)
> Subject: Re: [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function
>
> On Di, 2014-06-03 at 18:54 +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > clean up ehci resource when ehci pci device exit.
> >
> > Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> > ---
> > hw/usb/hcd-ehci-pci.c | 33 +++++++++++++++++++++++++++++++++
> > 1 file changed, 33 insertions(+)
> >
> > diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
> > index 505741a..115d9b5 100644
> > --- a/hw/usb/hcd-ehci-pci.c
> > +++ b/hw/usb/hcd-ehci-pci.c
> > @@ -84,6 +84,38 @@ static void usb_ehci_pci_init(Object *obj)
> > usb_ehci_init(s, DEVICE(obj));
> > }
> >
> > +static void usb_ehci_pci_exit(PCIDevice *dev)
> > +{
>
> Too much non-pci stuff in here. I think we should create a
> usb_ehci_unrealize function and do the cleanup there, then just call
> this from usb_ehci_pci_exit. You also don't need patch #6 then.
>
Good idea! I will do it in v3, Thanks!
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug
2014-06-04 6:11 ` [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug Gerd Hoffmann
@ 2014-06-04 6:40 ` Gonglei (Arei)
0 siblings, 0 replies; 14+ messages in thread
From: Gonglei (Arei) @ 2014-06-04 6:40 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Huangweidong (C), Luonengjun, qemu-devel@nongnu.org,
Huangpeng (Peter)
> -----Original Message-----
> From: Gerd Hoffmann [mailto:kraxel@redhat.com]
> Sent: Wednesday, June 04, 2014 2:12 PM
> To: Gonglei (Arei)
> Cc: qemu-devel@nongnu.org; Luonengjun; Huangweidong (C); Huangpeng
> (Peter)
> Subject: Re: [PATCH v2 0/9] usb: usb host adapter hotplug
>
> Hi,
>
> > changes since v1:
> > * add more completely resource cleanup for every usb host adapter.
>
> Looks good overall. How did you test this?
>
Thanks!
The steps of tested:
1. start a vm using below qemu command line:
./qemu-system-x86_64 -enable-kvm -m 4096 -smp 4 -name win7 -boot c -drive file=/mnt/sdb/gonglei/image/win7_32_2U -vnc 0.0.0.0:10 -monitor stdio
2. hot-plug/unplug an usb host adapters:
2.1) For ehci:
(qemu) device_add usb-ehci,id=ehci
(qemu) device_add usb-tablet,id=input0,bus=ehci.0,port=1
(qemu) device_del ehci
2.2) For uhci:
(qemu) device_add piix3-usb-uhci,id=uhci
(qemu) device_del uhci
2.3) For uhci:
(qemu) device_add pci-ohci,id=ohci
(qemu) device_del ohci
2.4) For uhci:
(qemu) device_add nec-usb-xhci,id=xhci
(qemu) device_del xhci
3. do step #2 repeating, more than 20 times.
BTW, I will add some qtestes for usb host adapters hot-plug/unplug later,
and add tracing for exit function.
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-06-04 6:41 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-03 10:54 [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 1/9] usb: add usb_bus_release function arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 2/9] usb-ohci: Fix memory leak for ohci timer arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 3/9] usb-ohci: add exit function arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 4/9] usb-uhci: clean up uhci resource when pci-uhci exit arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 5/9] usb-ehci: add vmstate properity for EHCIState arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 6/9] usb-ehci: expose ehci_queues_rip_all arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function arei.gonglei
2014-06-04 6:09 ` Gerd Hoffmann
2014-06-04 6:22 ` Gonglei (Arei)
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 8/9] usb-xhci: add " arei.gonglei
2014-06-03 10:54 ` [Qemu-devel] [PATCH v2 9/9] usb: tag usb host controller as hotpluggable arei.gonglei
2014-06-04 6:11 ` [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug Gerd Hoffmann
2014-06-04 6:40 ` Gonglei (Arei)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).