Commit Graph

103 Commits

Author SHA1 Message Date
Anthony Liguori 9ea0f58fc7 Merge remote-tracking branch 'kraxel/usb.88' into staging
# By Gerd Hoffmann (10) and Marcel Apfelbaum (1)
# Via Gerd Hoffmann
* kraxel/usb.88:
  usb/dev-hid: Modified usb-tablet category from Misc to Input
  Revert "usb-hub: report status changes only once"
  usb-hub: add tracepoint for status reports
  usb: parallelize usb3 streams
  uas: add property for request logging
  xhci: reset port when disabling slot
  xhci: emulate intr endpoint intervals correctly
  xhci: fix endpoint interval calculation
  xhci: add port to slot_address tracepoint
  xhci: add tracepoint for endpoint state changes
  xhci: remove leftover debug printf

Message-id: 1378117055-29620-1-git-send-email-kraxel@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-09-03 12:31:30 -05:00
Gerd Hoffmann 5c67dd7b48 xhci: reset port when disabling slot
Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02 11:06:19 +02:00
Gerd Hoffmann 4d7a81c06f xhci: emulate intr endpoint intervals correctly
Respect the interval for interrupt endpoints, so we don't finish
transfers as fast as possible but at the rate configured by the guest.

Fixes guest deadlocks triggered by interrupt storms.

Cc:
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02 11:06:19 +02:00
Gerd Hoffmann ca7162782a xhci: fix endpoint interval calculation
Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02 11:06:19 +02:00
Gerd Hoffmann 65d81ed402 xhci: add port to slot_address tracepoint
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02 11:06:19 +02:00
Gerd Hoffmann 1c82392a15 xhci: add tracepoint for endpoint state changes
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02 11:06:19 +02:00
Gerd Hoffmann 5219042274 xhci: remove leftover debug printf
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02 11:06:19 +02:00
Andreas Färber c889b3a55d usb: Pass size to usb_bus_new()
To be passed to qbus_create_inplace().

Use DEVICE() cast to avoid a direct parent field access.

Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-08-30 20:14:39 +02:00
Alex Bligh bc72ad6754 aio / timers: Switch entire codebase to the new timer API
This is an autogenerated patch using scripts/switch-timer-api.

Switch the entire code base to using the new timer API.

Note this patch may introduce some line length issues.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-08-22 19:14:24 +02:00
Gerd Hoffmann dad5b9ea08 xhci: implement warm port reset
Without this patch windows can't do port resets for usb3 devices.

https://bugzilla.redhat.com/show_bug.cgi?id=949514

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-08-08 13:29:25 +02:00
Gerd Hoffmann 75cc1c1fcb xhci: fix segfault
Guest trying to reset a endpoint of a disconnected device resulted in
xhci trying to dereference uport while being NULL, thereby crashing
qemu.  Fix that by adding a check.  Drop unused dev variable while
touching that code bit.

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-08-01 13:03:42 +02:00
Gerd Hoffmann ed60ff024f xhci: handle USB_RET_IOERROR
https://bugzilla.redhat.com/show_bug.cgi?id=980377

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-07-30 10:26:19 +02:00
Marcel Apfelbaum 125ee0ed9c devices: Associate devices to their logical category
The category will be used to sort the devices displayed in
the command line help.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Message-id: 1375107465-25767-4-git-send-email-marcel.a@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-29 10:37:09 -05:00
Andreas Färber 9b7d3334d0 usb/hcd-xhci: QOM parent field cleanup
Replace direct uses of XHCIState::pci_dev with QOM casts and rename it
to parent_obj.

Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23 00:37:33 +02:00
Peter Crosthwaite 37034575d2 usb/hcd-xhci: QOM Upcast Sweep
Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Dropped usb_xhci_init() DeviceState argument and renamed variable]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-07-23 00:37:33 +02:00
Paolo Bonzini 22fc860b0a hw/[u-x]*: pass owner to memory_region_init* functions
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04 17:42:48 +02:00
Paolo Bonzini 2c9b15cab1 memory: add owner argument to initialization functions
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04 17:42:44 +02:00
Gerd Hoffmann 37352df30f xhci: add live migration support
With all preparing pieces in place we can finally drop in
the vmstate structs and the postload function.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-06-03 11:38:03 +02:00
Gerd Hoffmann 003e15a180 xhci: add xhci_init_epctx
Factor out endpoint context initialization to a separate function.
xhci live migration will need that too, in post_load.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-06-03 11:37:51 +02:00
Gerd Hoffmann 492b21f63f xhci: add xhci_alloc_epctx
Factor out endpoint context allocation to a separate function.
xhci live migration will need that too, in post_load.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-06-03 11:37:51 +02:00
Gerd Hoffmann 4034e6938a xhci: add XHCISlot->addressed
Preparing for live-migration support, post_load will need that.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-06-03 11:37:51 +02:00
Gerd Hoffmann 4e906d567a xhci: handle USB_RET_BABBLE
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-05-07 11:34:03 +02:00
Gerd Hoffmann 7d04c2b755 xhci: remove XHCIRing->base (unused)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-23 08:43:10 +02:00
Gerd Hoffmann a67188743b xhci: fix address device
Zero-initialize the set-address dummy USBPacket,
also add buffer to avoid sanity checks triggering.

https://bugzilla.redhat.com/show_bug.cgi?id=929019

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-16 12:04:09 +02:00
Gerd Hoffmann af203be36d xhci: use slotid as device address
Is good enougth for unique device addresses and avoids the need for any
state for device addressing.  Makes live migration support easier.  Also
makes device->slot lookups trivial.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-16 12:04:09 +02:00
Gerd Hoffmann bdfce20df1 xhci: fix portsc writes
Check for port reset first and skip everything else then.
Add sanity checks for PLS updates.
Add PLC notification when entering PLS_U0 state.

This gets host-initiated port resume going on win8.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-16 11:59:08 +02:00
Gerd Hoffmann 6d3bc22e31 xhci: add xhci_cap_write
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-16 11:59:08 +02:00
Gerd Hoffmann 94ae9eece7 xhci: remove leftover debug printf
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-16 11:59:08 +02:00
Gerd Hoffmann 4b7b2afae7 xhci: zap unused name field
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-03 11:39:42 +02:00
Gerd Hoffmann 0ab966cfcc xhci: remove unimplemented printfs
Replace them with a tracepoint, so they don't spam stderr by default.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-03 09:55:49 +02:00
Gerd Hoffmann 61803996de xhci: remove leftover debug printf
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-03 09:55:49 +02:00
Gerd Hoffmann c94a7c6979 xhci: fix numintrs sanity checks
Make sure numintrs is a power of two, msi requires this.

https://bugzilla.redhat.com/show_bug.cgi?id=918035

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-03 09:55:49 +02:00
Alex Williamson 6214e73cc5 pcie: Add endpoint capability initialization wrapper
Fix the awkward API of mangling the caller specified PCIe type and
just provide an interface to initialize an endpoint device.  This
will pick either a regular endpoint or integrated endpoint based on
the bus and return pcie_cap_init to doing exactly what is asked.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-03-26 21:02:19 +02:00
Hervé Poussineau 685cbd2f63 xhci: fix bad print specifier
This fixes the following compilation error:
hw/usb/hcd-xhci.c:1156:17: error: format ‘%llx’ expects argument of type
‘long long unsigned int’, but argument 4 has type ‘unsigned int’

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-02-23 09:39:41 +00:00
Gerd Hoffmann 024426acc0 usb-xhci: usb3 streams
Add streams support to the xhci emulation.  No secondary streams yet,
only linear stream arays are supported for now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-02-19 13:17:48 +01:00
Gerd Hoffmann 8550a02d12 usb-core: usb3 streams
This patch adds support for usb3 streams to the usb subsystem core.
This is just adding a streams field / parameter in a number of places.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-02-19 12:30:05 +01:00
Gerd Hoffmann 0cb41e2c5e xhci: nuke transfe5rs on detach
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-14 08:59:40 +01:00
Gerd Hoffmann f3dcf6384c xhci: call xhci_detach_slot on root port detach too
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-14 08:59:40 +01:00
Gerd Hoffmann 8125184178 xhci: create xhci_detach_slot helper function
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-14 08:59:40 +01:00
Andreas Färber 8c43a6f05d Make all static TypeInfos const
Since 39bffca203 (qdev: register all
types natively through QEMU Object Model), TypeInfo as used in
the common, non-iterative pattern is no longer amended with information
and should therefore be const.

Fix the documented QOM examples:

 sed -i 's/static TypeInfo/static const TypeInfo/g' include/qom/object.h

Since frequently the wrong examples are being copied by contributors of
new devices, fix all types in the tree:

 sed -i 's/^static TypeInfo/static const TypeInfo/g' */*.c
 sed -i 's/^static TypeInfo/static const TypeInfo/g' */*/*.c

This also avoids to piggy-back these changes onto real functional
changes or other refactorings.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-10 15:11:53 -06:00
Gerd Hoffmann a820b57578 xhci: call set-address with dummy usbpacket
Due to the way devices are addressed with xhci (done by hardware, not
the guest os) there is no packet when invoking the set-address control
request.  Create a dummy packet in that case to avoid null pointer
dereferences.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07 12:57:24 +01:00
Hans de Goede f79738b03b usb: Add an usb_device_ep_stopped USBDevice method
Some usb devices (host or network redirection) can benefit from knowing when
the guest stops using an endpoint. Redirection may involve submitting packets
independently from the guest (in combination with a fifo buffer between the
redirection code and the guest), to ensure that buffers of the real usb device
are timely emptied. This is done for example for isoc traffic and for interrupt
input endpoints. But when the (re)submission of packets is done by the device
code, then how does it know when to stop this?

For isoc endpoints this is handled by detecting a set interface (change alt
setting) command, which works well for isoc endpoints. But for interrupt
endpoints currently the redirection code never stops receiving data from
the device, which is less then ideal.

However the controller emulation is aware when a guest looses interest, as
then the qh for the endpoint gets unlinked (ehci, ohci, uhci) or the endpoint
is explicitly stopped (xhci). This patch adds a new ep_stopped USBDevice
method and modifies the hcd code to call this on queue unlink / ep stop.

This makes it possible for the redirection code to properly stop receiving
interrupt input (*) data when the guest no longer has interest in it.

*) And in the future also buffered bulk input.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07 12:57:24 +01:00
Paolo Bonzini 1de7afc984 misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:32:39 +01:00
Michael S. Tsirkin a2cb15b0dd pci: update all users to look in pci/
update all users so we can remove the makefile hack.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-12-17 13:02:26 +02:00
Gerd Hoffmann 6c2d1c32d0 usb: tag usb host adapters as not hotpluggable.
Hotplugging them simply doesn't work, so tag them accordingly to
avoid users trying and then crashing qemu.

For xhci there is nothing fundamental which prevents hotplug from
working, we'll "only" need a exit() function which cleans up
everything properly.  That isn't for 1.3 though.

For ehci+uhci+ohci hotplug can't be supported until qemu gains the
capability to hotplug multifunction pci devices.

https://bugzilla.redhat.com/show_bug.cgi?id=879096

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-29 08:04:13 +01:00
David Gibson 616b5d53ae xhci: Fix some DMA host endian bugs
The xhci device does correct endian switches on the results of some DMAs
but not all.  In particular, there are many DMAs of what are essentially
arrays of 32-bit integers which never get byteswapped.  This causes them
to be interpreted incorrectly on big-endian hosts, since (as per the xhci
spec) these arrays are always little-endian in guest memory.

This patch adds some helper functions to fix these bugs.  This may not be
all the endian bugs in the xhci code, but it's certainly some of them and
the Linux guest xhci driver certainly gets further with these fixes.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-09 08:27:55 +01:00
Hans de Goede 9b8251c5c4 xhci: Add support for packets with both data and an error status
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-08 18:41:47 +01:00
Hans de Goede 9a77a0f589 usb: split packet result into actual_length + status
Since with the ehci and xhci controllers a single packet can be larger
then maxpacketsize, it is possible for the result of a single packet
to be both having transferred some data as well as the transfer to have
an error.

An example would be an input transfer from a bulk endpoint successfully
receiving 1 or more maxpacketsize packets from the device, followed
by a packet signalling halt.

While already touching all the devices and controllers handle_packet /
handle_data / handle_control code, also change the return type of
these functions to void, solely storing the status in the packet. To
make the code paths for regular versus async packet handling more
uniform.

This patch unfortunately is somewhat invasive, since makeing the qemu
usb core deal with this requires changes everywhere. This patch only
prepares the usb core for this, all the hcd / device changes are done
in such a way that there are no functional changes.

This patch has been tested with uhci and ehci hcds, together with usb-audio,
usb-hid and usb-storage devices, as well as with usb-redir redirection
with a wide variety of real devices.

Note that there is usually no need to directly set packet->actual_length
form devices handle_data callback, as that is done by usb_packet_copy()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-08 18:41:46 +01:00
Gerd Hoffmann 0bc85da69e xhci: allow address slot being called multiple times
win8 guests do that for some reason ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01 13:10:09 +01:00
Gerd Hoffmann 4f47f0f82e xhci: add port trace points
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01 13:10:09 +01:00