usb patch queue
Hi,
Here comes the usb patch queue. It features cleanup functions for the
host adapters, in preparation to make them hot-pluggable. Hotplug itself isn't there yet, some details still need to be sorted as we can't hotplug companion controller setups (expect RfC patches soon), but the majority of the bits needed to make hotplug fly is there.
There are also some simple host adapter tests (just start qemu with an device instance, not much actual testing yet), and the usual collection of bugfixes.
please pull,
Gerd
The following changes since commit c47c61be8dcd91689c8fc77776db924d684c3b39:
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140825.0' into staging (2014-08-26 10:42:06 +0100)
are available in the git repository at:
git://git.kraxel.org/qemu tags/pull-usb-20140829-1
for you to fetch changes up to 25e89ec5d2c7f8d953cb1ca558afa74974ff8930:
tests: add xHCI qtest (2014-08-29 12:53:47 +0200)
----------------------------------------------------------------
usb: bugfix collection.
usb: add cleanup functions for host adapters,
in preparation for hotplug support.
usb: add simple qtests for uhci,ohci,xhci.
----------------------------------------------------------------
Gerd Hoffmann (2):
xhci: use (1u << i)
Revert "xhci: Fix number of streams allocated when using streams"
Gonglei (13):
xhci: fix debug print compiling error
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: add ehci unrealize funciton
usb-ehci: add ehci-pci device exit function
usb-xhci: add exit function
usb: add usb host adapters exit trace
tests: add OHCI qtest
tests: add UHCI qtest
tests: add xHCI qtest
Jack Un (1):
Fix OHCI ISO TD state never being written back.
Markus Armbruster (1):
usb: Fix bootindex for portnr > 9
MAINTAINERS | 2 +- hw/usb/bus.c | 11 +++++++++-- hw/usb/hcd-ehci-pci.c | 14 +++++++++++++ hw/usb/hcd-ehci.c | 29 ++++++++++++++++++++++++++- hw/usb/hcd-ehci.h | 2 ++ hw/usb/hcd-ohci.c | 27 ++++++++++++++++++++++--- hw/usb/hcd-uhci.c | 24 +++++++++++++++++++++++ hw/usb/hcd-xhci.c | 50 +++++++++++++++++++++++++++++++++++++++++------ include/hw/usb.h | 1 + tests/Makefile | 10 +++++++++- tests/usb-hcd-ohci-test.c | 35 +++++++++++++++++++++++++++++++++ tests/usb-hcd-uhci-test.c | 35 +++++++++++++++++++++++++++++++++ tests/usb-hcd-xhci-test.c | 35 +++++++++++++++++++++++++++++++++ trace-events | 3 +++ 14 files changed, 264 insertions(+), 14 deletions(-) create mode 100644 tests/usb-hcd-ohci-test.c create mode 100644 tests/usb-hcd-uhci-test.c create mode 100644 tests/usb-hcd-xhci-test.c
[Qemu-devel] [PULL 01/17] usb: Fix bootindex for portnr > 9
From: Markus Armbruster <[email protected]>
We identify devices by their Open Firmware device paths. The encoding of the host controller and hub port numbers is incorrect:usb_get_fw_dev_path() formats them in decimal, while SeaBIOS uses hexadecimal. When some port number > 9, SeaBIOS will miss the bootindex (lucky case), or apply it to another device (unlucky case).
The relevant spec[*] agrees with SeaBIOS (and OVMF, for that matter). Change %d to %x.
Bug can bite only with host controllers or hubs sporting more than ten ports. I'm not aware of any.
[*] Open Firmware Recommended Practice: Universal Serial Bus, Version 1, Section 3.2.1 Device Node Address Representation
http://www.openfirmware.org/1275/bindings/usb/usb-1_0.ps
Note: xhci can be configured with up to 15 ports (default is 4 ports).
--- hw/usb/bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/bus.c +2 -2
@@ -589,11 +589,11 @@ static char *usb_get_fw_dev_path(DeviceState *qdev) nr =strtol (in, &in,10 );if (in[0 ] =='.' ) {/* some hub between root port and device */ - pos +=snprintf (fw_path + pos, fw_len - pos,"hub@%ld/" , nr); + pos +=snprintf (fw_path + pos, fw_len - pos,"hub@%lx/" , nr); in++; }else {/* the device itself */ - pos +=snprintf (fw_path + pos, fw_len - pos,"%s@%ld" , + pos +=snprintf (fw_path + pos, fw_len - pos,"%s@%lx" ,qdev_fw_name (qdev), nr);break ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 04/17] xhci: use (1u << i)
In reply to Gerd Hoffmann--- hw/usb/hcd-xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.c +2 -2
@@ -1180,7 +1180,7 @@ static int xhci_epmask_to_eps_with_streams(XHCIState *xhci, slot = &xhci->slots[slotid -1 ];for (i =2 , j =0 ; i <=31 ; i++) { -if (!(epmask & (1 << i))) { +if (!(epmask & (1u << i))) {continue ; }
@@ -2465,7 +2465,7 @@ static TRBCCode xhci_configure_slot(XHCIState *xhci, unsigned int slotid, res =xhci_alloc_device_streams (xhci, slotid, ictl_ctx[1 ]);if (res !=CC_SUCCESS ) {for (i =2 ; i <=31 ; i++) { -if (ictl_ctx[1 ] & (1 << i)) { +if (ictl_ctx[1 ] & (1u << i)) {xhci_disable_ep (xhci, slotid, i); } }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 02/17] xhci: fix debug print compiling error
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
after commit 003e15a180373048f0c1f4df0bfe303746eb2676 the DPRINTF will broke compiling, adjust its location.
--- hw/usb/hcd-xhci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/usb/hcd-xhci.c +3 -3
@@ -1380,14 +1380,11 @@ static void xhci_init_epctx(XHCIEPContext *epctx, dequeue =xhci_addr64 (ctx[2 ] & ~0xf , ctx[3 ]); epctx->type = (ctx[1 ] >>EP_TYPE_SHIFT ) &EP_TYPE_MASK ; -DPRINTF ("xhci: endpoint %d.%d type is %d\n" , epid/2 , epid%2 , epctx->type); epctx->pctx = pctx; epctx->max_psize = ctx[1 ]>>16 ; epctx->max_psize *=1 +((ctx[1 ]>>8 )&0xff ); epctx->max_pstreams = (ctx[0 ] >>10 ) &0xf ; epctx->lsa = (ctx[0 ] >>15 ) &1 ; -DPRINTF ("xhci: endpoint %d.%d max transaction (burst) size is %d\n" , - epid/2 , epid%2 , epctx->max_psize);if (epctx->max_pstreams) {xhci_alloc_streams (epctx, dequeue); }else {
@@ -1418,6 +1415,9 @@ static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid, slot->eps[epid-1 ] = epctx;xhci_init_epctx (epctx, pctx, ctx); +DPRINTF ("xhci: endpoint %d.%d type is %d, max transaction (burst) " +"size is %d\n" , epid/2 , epid%2 , epctx->type, epctx->max_psize); + epctx->mfindex_last =0 ; epctx->state =EP_RUNNING ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 05/17] Revert "xhci: Fix number of streams allocated when using streams"
In reply to Gerd HoffmannThis reverts commit d063c3112c4cd23a479ee18720c2bd119da2d315.
"2 << x" is the same as "2 ^ (x + 1)", so the old code is correct.
--- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-xhci.c +1 -1
@@ -1151,7 +1151,7 @@ static void xhci_reset_streams(XHCIEPContext *epctx)static void xhci_alloc_streams (XHCIEPContext *epctx,dma_addr_t base) {assert (epctx->pstreams ==NULL ); - epctx->nr_pstreams =2 << (epctx->max_pstreams +1 ); + epctx->nr_pstreams =2 << epctx->max_pstreams; epctx->pstreams =xhci_alloc_stream_contexts (epctx->nr_pstreams, base); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 08/17] usb-ohci: add exit function
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
clean up ohci resource when ohci pci device exit.
--- hw/usb/hcd-ohci.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
hw/usb/hcd-ohci.c +19 -0
@@ -1954,6 +1954,24 @@ 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); + +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)
@@ -2091,6 +2109,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 ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 10/17] usb-ehci: add vmstate properity for EHCIState
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
since hotunplug the ehci host adapter, we should
delete vm_change_state_handler also, so the
VMChangeStateEntry should be saved in EHCIState.
--- hw/usb/hcd-ehci.c | 2 +- hw/usb/hcd-ehci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
hw/usb/hcd-ehci.c +1 -1
@@ -2468,7 +2468,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)
hw/usb/hcd-ehci.h +1 -0
@@ -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;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 11/17] usb-ehci: add ehci unrealize funciton
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
cleanup ehci controller resource, both pci and sysbus if they're necessary.
--- hw/usb/hcd-ehci.c | 25 +++++++++++++++++++++++++ hw/usb/hcd-ehci.h | 1 + 2 files changed, 26 insertions(+)
hw/usb/hcd-ehci.c +25 -0
@@ -2471,6 +2471,31 @@ 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); + +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 */
hw/usb/hcd-ehci.h +1 -0
@@ -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)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 12/17] usb-ehci: add ehci-pci device exit function
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
clean up ehci resource when ehci pci device exit.
--- hw/usb/hcd-ehci-pci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/usb/hcd-ehci-pci.c +14 -0
@@ -84,6 +84,19 @@ 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; + +usb_ehci_unrealize (s,DEVICE (dev),NULL ); + +if (s->irq) { +g_free (s->irq); + s->irq =NULL ; + } +} +static void usb_ehci_pci_write_config (PCIDevice *dev,uint32_t addr,uint32_t val,int l) {
@@ -121,6 +134,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;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 13/17] usb-xhci: add exit function
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
clean up xhci resource when xhci pci device exit.
--- hw/usb/hcd-xhci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
hw/usb/hcd-xhci.c +36 -0
@@ -3644,6 +3644,41 @@ 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); + +for (i =0 ; i < xhci->numports; i++) { +XHCIPort *port = &xhci->ports[i]; +memory_region_del_subregion (&xhci->mem, &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_del_subregion (&xhci->mem, &dev->msix_pba_mmio); + } + +usb_bus_release (&xhci->bus); +} +static int usb_xhci_post_load (void *opaque,int version_id) {XHCIState *xhci = opaque;
@@ -3836,6 +3871,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 ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 15/17] tests: add OHCI qtest
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
--- MAINTAINERS | 2 +- tests/Makefile | 3 +++ tests/usb-hcd-ohci-test.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/usb-hcd-ohci-test.c
MAINTAINERS +1 -1
@@ -614,7 +614,7 @@ USB M: Gerd Hoffmann <[email protected]> S: Maintained F: hw/usb/* -F: tests/usb-hcd-ehci-test.c +F: tests/usb-*-test.c VFIO M: Alex Williamson <[email protected]>
tests/Makefile +3 -0
@@ -155,6 +155,8 @@ check-qtest-i386-y += tests/i82801b11-test$(EXESUF) gcov-files-i386-y += hw/pci-bridge/i82801b11.c check-qtest-i386-y += tests/ioh3420-test$(EXESUF) gcov-files-i386-y += hw/pci-bridge/ioh3420.c +check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF) +gcov-files-i386-y += hw/usb/hcd-ohci.c check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF) gcov-files-i386-y += hw/usb/hcd-ehci.c gcov-files-i386-y += hw/usb/hcd-uhci.c
@@ -335,6 +337,7 @@ tests/ac97-test$(EXESUF): tests/ac97-test.o tests/es1370-test$(EXESUF): tests/es1370-test.o tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o +tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y) tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
tests/usb-hcd-ohci-test.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* QTest testcase for USB OHCI controller +* +* Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + + +static void test_ohci_init (void ) +{ +qtest_start ("-device pci-ohci,id=ohci" ); + +qtest_end (); +} + + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); + +qtest_add_func ("/ohci/pci/init" , test_ohci_init); + + ret =g_test_run (); + +return ret; +}
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 03/17] Fix OHCI ISO TD state never being written back.
In reply to Gerd HoffmannFrom: Jack Un <[email protected]>
There appears to be typo in OHCI with isochronous transfers resulting in isoch. transfer descriptor state never being written back. The'put_words' function is in a OR statement hence it is never called.
--- hw/usb/hcd-ohci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/hcd-ohci.c +2 -2
@@ -619,8 +619,8 @@ static inline int ohci_put_td(OHCIState *ohci,static inline int ohci_put_iso_td (OHCIState *ohci,dma_addr_t addr,struct ohci_iso_td *td) { -return put_dwords (ohci, addr, (uint32_t *)td,4 || -put_words (ohci, addr +16 , td->offset,8 )); +return put_dwords (ohci, addr, (uint32_t *)td,4 ) || +put_words (ohci, addr +16 , td->offset,8 ); } static inline int ohci_put_hcca(OHCIState *ohci,
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 06/17] usb: add usb_bus_release function
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
add global variables releasing logic when the usb buses were removed or hot-unpluged.
--- hw/usb/bus.c | 7 +++++++ include/hw/usb.h | 1 + 2 files changed, 8 insertions(+)
hw/usb/bus.c +7 -0
@@ -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;
include/hw/usb.h +1 -0
@@ -529,6 +529,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,
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 14/17] usb: add usb host adapters exit trace
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
--- hw/usb/hcd-ehci.c | 2 ++ hw/usb/hcd-uhci.c | 2 ++ hw/usb/hcd-xhci.c | 2 ++ trace-events | 3 +++ 4 files changed, 9 insertions(+)
hw/usb/hcd-ehci.c +2 -0
@@ -2473,6 +2473,8 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)void usb_ehci_unrealize (EHCIState *s,DeviceState *dev,Error **errp) { +trace_usb_ehci_unrealize (); +if (s->frame_timer) {timer_del (s->frame_timer);timer_free (s->frame_timer);
hw/usb/hcd-uhci.c +2 -0
@@ -1260,6 +1260,8 @@ static void usb_uhci_exit(PCIDevice *dev) {UHCIState *s =DO_UPCAST (UHCIState, dev, dev); +trace_usb_uhci_exit (); +if (s->frame_timer) {timer_del (s->frame_timer);timer_free (s->frame_timer);
hw/usb/hcd-xhci.c +2 -0
@@ -3649,6 +3649,8 @@ static void usb_xhci_exit(PCIDevice *dev)int i;XHCIState *xhci =XHCI (dev); +trace_usb_xhci_exit (); +for (i =0 ; i < xhci->numslots; i++) {xhci_disable_slot (xhci, i +1 ); }
trace-events +3 -0
@@ -297,6 +297,7 @@ usb_port_release(int bus, const char *port) "bus %d, port %s" # hw/usb/hcd-ehci.c usb_ehci_reset(void) "=== RESET ===" +usb_ehci_unrealize(void) "=== UNREALIZE ===" usb_ehci_opreg_read(uint32_t addr, const char *str, uint32_t val) "rd mmio %04x [%s] = %x" usb_ehci_opreg_write(uint32_t addr, const char *str, uint32_t val) "wr mmio %04x [%s] = %x" usb_ehci_opreg_change(uint32_t addr, const char *str, uint32_t new, uint32_t old) "ch mmio %04x [%s] = %x (old: %x)"
@@ -329,6 +330,7 @@ usb_ehci_dma_error(void) "" # hw/usb/hcd-uhci.c usb_uhci_reset(void) "=== RESET ===" +usb_uhci_exit(void) "=== EXIT ===" usb_uhci_schedule_start(void) "" usb_uhci_schedule_stop(void) "" usb_uhci_frame_start(uint32_t num) "nr %d"
@@ -358,6 +360,7 @@ usb_uhci_td_complete(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" # hw/usb/hcd-xhci.c usb_xhci_reset(void) "=== RESET ===" +usb_xhci_exit(void) "=== EXIT ===" usb_xhci_run(void) "" usb_xhci_stop(void) "" usb_xhci_cap_read(uint32_t off, uint32_t val) "off 0x%04x, ret 0x%08x"
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 07/17] usb-ohci: Fix memory leak for ohci timer
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
--- hw/usb/hcd-ohci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/usb/hcd-ohci.c +3 -1
@@ -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 ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 16/17] tests: add UHCI qtest
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
--- tests/Makefile | 4 +++- tests/usb-hcd-uhci-test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/usb-hcd-uhci-test.c
tests/Makefile +3 -1
@@ -157,9 +157,10 @@ check-qtest-i386-y += tests/ioh3420-test$(EXESUF) gcov-files-i386-y += hw/pci-bridge/ioh3420.c check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF) gcov-files-i386-y += hw/usb/hcd-ohci.c +check-qtest-i386-y += tests/usb-hcd-uhci-test$(EXESUF) +gcov-files-i386-y += hw/usb/hcd-uhci.c check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF) gcov-files-i386-y += hw/usb/hcd-ehci.c -gcov-files-i386-y += hw/usb/hcd-uhci.c gcov-files-i386-y += hw/usb/dev-hid.c gcov-files-i386-y += hw/usb/dev-storage.c check-qtest-i386-$(CONFIG_LINUX) += tests/vhost-user-test$(EXESUF)
@@ -338,6 +339,7 @@ tests/es1370-test$(EXESUF): tests/es1370-test.o tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o +tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y) tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
tests/usb-hcd-uhci-test.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* QTest testcase for USB UHCI controller +* +* Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + + +static void test_uhci_init (void ) +{ +qtest_start ("-device piix3-usb-uhci,id=uhci" ); + +qtest_end (); +} + + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); + +qtest_add_func ("/uhci/pci/init" , test_uhci_init); + + ret =g_test_run (); + +return ret; +}
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 17/17] tests: add xHCI qtest
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
--- tests/Makefile | 3 +++ tests/usb-hcd-xhci-test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/usb-hcd-xhci-test.c
tests/Makefile +3 -0
@@ -163,6 +163,8 @@ check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF) gcov-files-i386-y += hw/usb/hcd-ehci.c gcov-files-i386-y += hw/usb/dev-hid.c gcov-files-i386-y += hw/usb/dev-storage.c +check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF) +gcov-files-i386-y += hw/usb/hcd-xhci.c check-qtest-i386-$(CONFIG_LINUX) += tests/vhost-user-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
@@ -341,6 +343,7 @@ tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y) +tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a
tests/usb-hcd-xhci-test.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* QTest testcase for USB xHCI controller +* +* Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + + +static void test_xhci_init (void ) +{ +qtest_start ("-device nec-usb-xhci,id=xhci" ); + +qtest_end (); +} + + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); + +qtest_add_func ("/xhci/pci/init" , test_xhci_init); + + ret =g_test_run (); + +return ret; +}
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 09/17] usb-uhci: clean up uhci resource when pci-uhci exit
In reply to Gerd HoffmannFrom: Gonglei <[email protected]>
clean up uhci resource when uhci pci device exit.
--- hw/usb/hcd-uhci.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
hw/usb/hcd-uhci.c +22 -0
@@ -1256,6 +1256,27 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)return usb_uhci_common_initfn (dev); } +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); + +if (!s->masterbus) { +usb_bus_release (&s->bus); + } +} +static Property uhci_properties[] = {DEFINE_PROP_STRING ("masterbus" , UHCIState, masterbus),DEFINE_PROP_UINT32 ("firstport" , UHCIState, firstport,0 ),
@@ -1272,6 +1293,7 @@ static void uhci_class_init(ObjectClass *klass, void *data)UHCIInfo *info = data; k->init = info->initfn ? info->initfn : usb_uhci_common_initfn; + k->exit = info->unplug ? usb_uhci_exit :NULL ; k->vendor_id = info->vendor_id; k->device_id = info->device_id; k->revision = info->revision;
Signature · 1 line
1.8.3.1
Peter Maydell
AppliedQuoted 26 lines · Gerd Hoffmann
Hi,
Here comes the usb patch queue. It features cleanup functions for the
host adapters, in preparation to make them hot-pluggable. Hotplug itself isn't there yet, some details still need to be sorted as we can't hotplug companion controller setups (expect RfC patches soon), but the majority of the bits needed to make hotplug fly is there.There are also some simple host adapter tests (just start qemu with an device instance, not much actual testing yet), and the usual collection of bugfixes.
please pull,
GerdThe following changes since commit
c47c61be8dcd91689c8fc77776db924d684c3b39:Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140825.0' into staging (2014-08-26 10:42:06 +0100)
are available in the git repository at:
git://git.kraxel.org/qemutags/pull-usb-20140829-1for you to fetch changes up to
25e89ec5d2c7f8d953cb1ca558afa74974ff8930:
Quoted 7 lines
tests: add xHCI qtest (2014-08-29 12:53:47 +0200)
----------------------------------------------------------------
usb: bugfix collection.
usb: add cleanup functions for host adapters,
in preparation for hotplug support.
usb: add simple qtests for uhci,ohci,xhci.
Applied, thanks.
-- PMM