summaryrefslogtreecommitdiff
path: root/hw/usb/hcd-xhci.c
AgeCommit message (Collapse)AuthorFilesLines
2013-04-03xhci: remove leftover debug printfGerd Hoffmann1-2/+0
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-03xhci: fix numintrs sanity checksGerd Hoffmann1-0/+3
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-03-26pcie: Add endpoint capability initialization wrapperAlex Williamson1-1/+1
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-02-23xhci: fix bad print specifierHervé Poussineau1-2/+2
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-19usb-xhci: usb3 streamsGerd Hoffmann1-45/+223
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-19usb-core: usb3 streamsGerd Hoffmann1-4/+5
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-01-14xhci: nuke transfe5rs on detachGerd Hoffmann1-1/+7
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-14xhci: call xhci_detach_slot on root port detach tooGerd Hoffmann1-0/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-14xhci: create xhci_detach_slot helper functionGerd Hoffmann1-6/+18
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-10Make all static TypeInfos constAndreas Färber1-1/+1
Since 39bffca2030950ef6efe57c2fac8327a45ae1015 (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-07xhci: call set-address with dummy usbpacketGerd Hoffmann1-1/+6
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-07usb: Add an usb_device_ep_stopped USBDevice methodHans de Goede1-0/+7
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>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17pci: update all users to look in pci/Michael S. Tsirkin1-3/+3
update all users so we can remove the makefile hack. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-11-29usb: tag usb host adapters as not hotpluggable.Gerd Hoffmann1-0/+1
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-09xhci: Fix some DMA host endian bugsDavid Gibson1-27/+54
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-08xhci: Add support for packets with both data and an error statusHans de Goede1-2/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-08usb: split packet result into actual_length + statusHans de Goede1-24/+22
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-01xhci: allow address slot being called multiple timesGerd Hoffmann1-2/+7
win8 guests do that for some reason ... Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: add port trace pointsGerd Hoffmann1-1/+5
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: set pls in xhci_port_update & xhci_port_resetGerd Hoffmann1-2/+24
Set the port link state to the correct values in xhci_port_update and xhci_port_reset functions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: add xhci_port_resetGerd Hoffmann1-4/+9
Move port reset logic to its own function. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: add xhci_port_notifyGerd Hoffmann1-14/+17
Create a function to notify the guest about port status changes and put it into use. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: add xhci_port_have_deviceGerd Hoffmann1-2/+12
Factor out the code which checks whenever a usb device is attached to the port in question. No functional change. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: s/xhci_update_port/xhci_port_update/Gerd Hoffmann1-5/+5
Rename the function for xhci_port_* naming scheme, also drop the xhci parameter as port carries a pointer to xhci anyway. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01xhci: add {get,set}_field macros & enum for plsGerd Hoffmann1-8/+31
Add {get,set}_field macros (simliar to ehci) to read and update some bits of a word. Put them into use for updating pls (port link state) values. Also add a enum for pls values. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25xhci: fix usb name in capsGerd Hoffmann1-2/+2
Used to be "UTB" not "USB". Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25xhci: make number of interrupters and slots configurableGerd Hoffmann1-31/+48
Add properties to tweak the numbers of available interrupters and slots. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25xhci: allow disabling interruptersGerd Hoffmann1-0/+6
For secondary interrupters this is explicitly allowed in the specs. For the primary interrupter behavior is undefined, lets be friendly and allow disabling too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25xhci: flush endpoint context unconditinallyGerd Hoffmann1-3/+0
Not updating the endpoint context in case the state didn't change is wrong. Other context fields might have changed, for example the dequeue pointer in response to a CR_SET_TR_DEQUEUE command. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25xhci: fix function name in error messageGerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25usb: Add an int_req flag to USBPacketHans de Goede1-5/+11
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25usb: Move short-not-ok handling to the coreHans de Goede1-1/+1
After a short-not-ok packet ending short, we should not advance the queue. Move enforcing this to the core, rather then handling it in the hcd code. This may result in the queue now actually containing multiple input packets (which would not happen before), and this requires special handling in combination with pipelining, so disable pipleining for input endpoints (for now). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25usb: Move clearing of queue on halt to the coreHans de Goede1-0/+4
hcds which queue up more then one packet at once (uhci, ehci and xhci), must clear the queue after an error which has caused the queue to halt. Currently this is handled as a special case inside the hcd code, this patch instead adds an USB_RET_REMOVE_FROM_QUEUE packet result code, teaches the 3 hcds about this and moves the clearing of the queue on a halt into the USB core. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25usb: Add USB_RET_ADD_TO_QUEUE packet result codeHans de Goede1-0/+6
This can be used by usb-device code which wishes to process an entire endpoint queue at once, to do this the usb-device code returns USB_RET_ADD_TO_QUEUE from its handle_data class method and defines a flush_ep_queue class method to call when the hcd is done queuing up packets. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25xhci: Add a xhci_ep_nuke_one_xfer helper functionHans de Goede1-19/+30
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-23Rename target_phys_addr_t to hwaddrAvi Kivity1-9/+9
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-05cleanup useless return sentenceAmos Kong1-1/+0
This patch cleans up return sentences in the end of void functions. Reported-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-09-26xhci: create a memory region for each portGerd Hoffmann1-42/+43
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-26xhci: route string & usb hub supportGerd Hoffmann1-31/+55
Parse route string in slot contexts and support devices connected via hub.
2012-09-26xhci: tweak limitsGerd Hoffmann1-4/+4
Set maxports to 15. This is what the usb3 route string can handle. Set maxslots to 64. This is more than the number of root ports we can have, but with additional hubs you can end up with more devices. Set maxintrs (aka msi vectors) to 16. Should be enougth, especially considering that vectors are a limited ressource. Linux guests use only three at the moment. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: allow bytewise capability register readsGerd Hoffmann1-1/+3
Some guests need this according to Alejandro Martinez Ruiz <alex@securiforest.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: kill xhci_mem_{read,write} dispatcher functionsGerd Hoffmann1-65/+75
... and register subregions instead, so we offload the dispatching to the the memory subsystem which is designed to handle it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: support multiple interruptersGerd Hoffmann1-5/+1
Everything is in place, flip the big switch now and enable support for multiple interrupters. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: pick target interrupterGerd Hoffmann1-6/+16
Pick the correct interrupter when queuing an event. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: prepare xhci_runtime_{read,write} for multiple interruptersGerd Hoffmann1-43/+57
Prepare xhci runtime register access function for multiple interrupters. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: add XHCIInterrupterGerd Hoffmann1-147/+160
Move all state belonging to the (single) interrupter into a separate struct. First step in adding support for multiple interrupters. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: move register update into xhci_intr_raiseGerd Hoffmann1-9/+5
Now that we have a separate function to raise an IRQ we can move some comon code into the function. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: add msix supportGerd Hoffmann1-1/+46
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: rework interrupt handlingGerd Hoffmann1-14/+33
Split xhci_irq_update into a function which handles intx updates (including lowering the irq line once the guests acks the interrupt) and one which is used for raising an irq only. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>