aboutsummaryrefslogtreecommitdiffstats
path: root/hw/usb-ehci.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-27ehci: drop old stuffGerd Hoffmann1-29/+1
Drop the "ehci under development" banner. Drop unused & inactive (#if 0) code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-27usb-ehci: Handle ISO packets failing with an error other then NAKHans de Goede1-3/+19
Before this patch the ehci code was not checking for any other errors other then USB_RET_NAK. This causes 2 problems: 1) Other errors are not reported to the guest. 2) When transactions with the ITD_XACT_IOC bit set completing with another error would not result in USBSTS_INT getting set. I hit this problem when unplugging devices while iso data was streaming from the device to the guest. When this happens it takes a while for the guest to process the unplugging and remove ISO transactions from the ehci schedule, in the mean time these transactions would complete with a result of USB_RET_NODEV, which was not handled. This lead to the Linux guest's usb subsystem "hanging", that is it would no longer see new usb devices getting plugged in and running for example lsusb would lead to a stuck (D state) lsusb process. This patch fixes this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-27usb-ehci: sanity-check iso xfersGerd Hoffmann1-6/+10
This patch adds a sanity check to itd processing to make sure the endpoint addressed by the guest is actually an iso endpoint. Also verify that usb drivers don't return USB_RET_ASYNC which is illegal for iso xfers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-27usb-ehci: fix resetGerd Hoffmann1-1/+2
Two reset fixes: * pick up s->usbcmd value after ehci_reset call to make sure it keeps the reset value and doesn't get rubbish filled in when val is written back to the mmio register array later on. * make sure the frame timer is zapped on reset. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-15Merge remote-tracking branch 'kraxel/usb.38' into stagingAnthony Liguori1-48/+45
* kraxel/usb.38: (28 commits) xhci: handle USB_RET_NAK xhci: remote wakeup support xhci: kill port arg from xhci_setup_packet xhci: stop on errors xhci: add trb type name lookup support. xhci: signal low- and fullspeed support usb: add USBBusOps->wakeup_endpoint usb: pass USBEndpoint to usb_wakeup usb: maintain async packet list per endpoint usb: Set USBEndpoint in usb_packet_setup(). usb: add USBEndpoint->{nr,pid} usb: USBPacket: add status, rename owner -> ep usb: fold usb_generic_handle_packet into usb_handle_packet usb: kill handle_packet callback usb-xhci: switch to usb_find_device() usb-musb: switch to usb_find_device() usb-ohci: switch to usb_find_device() usb-ehci: switch to usb_find_device() usb-uhci: switch to usb_find_device() usb: handle dev == NULL in usb_handle_packet() ...
2012-02-15qom: Unify type registrationAndreas Färber1-2/+3
Replace device_init() with generalized type_init(). While at it, unify naming convention: type_init([$prefix_]register_types) Also, type_init() is a function, so add preceding blank line where necessary and don't put a semicolon after the closing brace. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: malc <av1474@comtv.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-10usb: Set USBEndpoint in usb_packet_setup().Gerd Hoffmann1-6/+9
With the separation of the device lookup (via usb_find_device) and packet processing we can lookup device and endpoint before setting up the usb packet. So we can initialize USBPacket->ep early and keep it valid for the whole lifecycle of the USBPacket. Also the devaddr and devep fields are not needed any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10usb: USBPacket: add status, rename owner -> epGerd Hoffmann1-2/+2
Add enum to track the status of USBPackets, use that instead of the owner pointer to figure whenever a usb packet is currently in flight or not. Add some more packet status sanity checks. Also rename the USBEndpoint pointer from "owner" to "ep". Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10usb-ehci: switch to usb_find_device()Gerd Hoffmann1-40/+29
Switch over EHCI to use the new usb_find_device() function for device lookup. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10usb: kill USB_MSG_RESETGerd Hoffmann1-2/+2
The USB subsystem pipes internal reset notifications through usb_handle_packet() with a special magic PID. This indirection is a pretty pointless excercise as it ends up being handled by usb_generic_handle_packet anyway. Replace the USB_MSG_RESET with a usb_device_reset() function which can be called directly. Also rename the existing usb_reset() function to usb_port_reset() to avoid confusion. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10usb-ehci: Clear the portstatus powner bit on device disconnectHans de Goede1-0/+5
According to the EHCI spec port ownership should revert to the EHCI controller on device disconnect. This fixes the problem of a port getting stuck on USB 1 when using redirection and plugging in a USB 2 device after a USB 1 device has been redirected. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-03qdev: register all types natively through QEMU Object ModelAnthony Liguori1-14/+18
This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27pci: convert to QEMU Object ModelAnthony Liguori1-20/+34
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27qdev: prepare source tree for code conversionAnthony Liguori1-25/+24
These are various small stylistic changes which help make things more consistent such that the automated conversion script can be simpler. It's not necessary to agree or disagree with these style changes because all of this code is going to be rewritten by the patch monkey script anyway. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-17usb: link packets to endpoints not devicesGerd Hoffmann1-1/+2
Add USBEndpoint for the control endpoint to USBDevices. Link async packets to the USBEndpoint instead of the USBDevice. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-12-12Remove unnecessary casts from PCI DMA code in usb-ehciDavid Gibson1-3/+3
This patch removes some unnecessary casts in the usb-ehci device, introduced by commit 68d553587c0aa271c3eb2902921b503740d775b6 'usb-ehci: Use PCI DMA stub functions'. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-23usb-ehci: add register namesGerd Hoffmann1-0/+2
The mmio register name list only had the names for four port status registers. We emulate a EHCI adapter with six ports though, the last two ones are listed as "unknown" in traces. Fix it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-23usb-ehci: codestyle fixupsGerd Hoffmann1-28/+28
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-21ehci: add assertGerd Hoffmann1-0/+1
Coverity thinks q could be NULL there and warns. I believe it can't be NULL there. Add assert to prove it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-11-01usb-ehci: Use PCI DMA stub functionsDavid Gibson1-19/+25
This updates the usb-ehci device emulation to use the explicit PCI DMA wrapper to initialize its scatter/gathjer structure. This means this driver should not need further changes when the sglist interface is extended to support IOMMUs. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-13usb: fix port resetGerd Hoffmann1-2/+2
commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a removed the implicit detach before (re-)attaching in usb_attach(). Some usb host controllers used that behavior though to do a port reset by a detach+attach sequence. This patch establishes old behavior by adding a new usb_reset() function for port resets and putting it into use, thereby also unifying port reset behavior of all host controllers. The patch also adds asserts to usb_attach() and usb_detach() to make sure the calls are symmetrical. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-19pci: interrupt pin documentation updateMichael S. Tsirkin1-1/+1
Fix up some erroneous comments in code: interrupt pins are named A-D, the interrupt pin register is always readonly and isn't zeroed out on reset. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-07usb: claim port at device initialization time.Gerd Hoffmann1-11/+11
This patch makes qemu assign a port when creating the device, not when attaching it. For most usb devices this isn't a noticable difference because they are in attached state all the time. The change affects usb-host devices which live in detached state while the real device is unplugged from the host. They have a fixed port assigned all the time now instead of getting grabbing one on attach and releasing it at detach, i.e. they stop floating around at the usb bus. The change also allows to simplify usb-hub. It doesn't need the handle_attach() callback any more to configure the downstream ports. This can be done at device initialitation time now. The changed initialization order (first grab upstream port, then register downstream ports) also fixes some icky corner cases. For example it is not possible any more to plug the hub into one of its own downstream ports. The usb host adapters must care too. USBPort->dev being non-NULL doesn't imply any more the device is in attached state. The host adapters must additionally check the USBPort->dev->attached flag. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07usb-ehci: handle siTDsGerd Hoffmann1-1/+42
This patch adds code to do minimal siTD handling, which is basically just following the next pointer. This is good enougth to handle the inactive siTDs used by FreeBSD. Active siTDs are skipped too as we don't have split transfer support in qemu, additionally a warning is printed. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-2/+2
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-08pci: rename pci_register_bar_region() to pci_register_bar()Avi Kivity1-1/+1
Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-08ehci: convert to memory APIAvi Kivity1-27/+9
Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-04ehci: iovec support, remove bufferGerd Hoffmann1-86/+63
Map guest memory and pass on a direct pointer instead of copying the bits to a indirect buffer. EHCI transfer descriptors can reference multiple (physical guest) pages so we'll actually start seeing usb packets wich carry iovec with more than one element. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-04usb: use iovecs in USBPacketGerd Hoffmann1-13/+8
Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-20ehci doesn't support migrationGerd Hoffmann1-0/+7
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05ehci: add ich9 controller.Gerd Hoffmann1-14/+29
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05ehci: fix port count.Gerd Hoffmann1-1/+1
The ICH4 EHCI controller which we emulate has six ports not four. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb-ehci: Add support for registering companion controllersHans de Goede1-30/+144
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb-ehci: Fix handling of PED and PEDC port status bitsHans de Goede1-13/+11
The PED bit should only be set for highspeed devices and the PEDC bit should not be set on "normal" PED bit changes, only on io errors. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb-ehci: cleanup port reset handlingHans de Goede1-6/+1
Doing a usb_attach when dev is NULL will just result in the port detach op getting called even though nothing was connected in the first place. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb-ehci: Connect Status bit is read only, don't allow changing it by the guestHans de Goede1-2/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb-ehci: drop unused num-ports state memberHans de Goede1-1/+0
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Replace device_destroy bus op with a child_detach port opHans de Goede1-8/+10
Note this fixes 2 things in one go, first of all the device_destroy bus op should be a device_detach bus op, as pending async packets from the device should be cancelled on detach not on destroy. Secondly having this as a bus op won't work with companion controllers, since then there will be 1 bus driven by the ehci controller and thus 1 set of bus ops, but the device being detached may be downstream of a handed over port. Making the detach of a downstream device a port op allows the ehci controller to forward this to the companion controller port for handed over ports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Make port wakeup and complete ops take a USBPort instead of a DeviceHans de Goede1-1/+1
This makes them consistent with the attach and detach ops, and in general it makes sense to make portops take a port as argument. This also makes adding support for a companion controller easier / cleaner. [ kraxel: fix usb-musb.c build ] Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05usb: Move (initial) call of usb_port_location to usb_fill_portHans de Goede1-1/+0
Cleanup / preparation patch for companion controller support. Note that as a "side-effect" this patch also fixes the milkymist-softusb controller not having a port_location set for its ports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23ehci: switch to nanosecondsGerd Hoffmann1-18/+11
Make ehci use nanoseconds everywhere. Simplifies time calculations. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23ehci: add freq + maxframes propertiesGerd Hoffmann1-2/+12
Add properties for the wakeup rate and the max number of frames ehci will process at once. The wakeup rate defaults to 1000 which equals the usb frame rate. This can be reduced to make qemu wake up less often when ehci is active. In case the wakeup rate is reduced or the ehci timer is delayed due to latency issues elsewhere in qemu ehci will process multiple frames at once. The maxframes property specifies the upper limit for this. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-22Merge remote-tracking branch 'mst/for_anthony' into stagingAnthony Liguori1-5/+4
Conflicts: hw/usb-uhci.c
2011-06-15usb-ehci: move device/vendor/class id to qdevMichael S. Tsirkin1-5/+4
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-06-14usb: Use defines for serial bus release number register for EHCIBrad Hards1-1/+1
Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb-ehci: split trace calls to handle arg count limitsGerd Hoffmann1-21/+27
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb-ehci: itd handling fixes.Gerd Hoffmann1-36/+65
This patch fixes a bunch of issues in the itd descriptor handling. Most important fix is to handle transfers which cross page borders correctly by looking up the address of the next page. Luckily the linux uses physically contigous memory so the data used to hits the correct location even with this bug instead of corrupting guest memory. Also the transfer length updates for outgoing transfers wasn't correct. While being at it DPRINTFs have been replaced by tracepoints. The isoch_pause logic has been disabled. Not clear to me which propose this serves and I think it is incorrect too as we just skip processing itds. Even when no xfer happens we have to clear the active bit. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb-ehci: drop EXECUTING checks.Gerd Hoffmann1-30/+2
The state machine doesn't stop in EXECUTING state any more when async packets are in flight, so the checks are not needed any more and can be dropped. Also kick out the check for the frame timer. As we don't stop & sleep any more on async packets this is obsolete. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14usb: cancel async packets on unplugGerd Hoffmann1-1/+24
This patch adds USBBusOps struct with (for now) only a single callback which is called when a device is about to be destroyed. The USB Host adapters are implementing this callback and use it to cancel any async requests which might be in flight before the device actually goes away. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14ehci: fix a number of unused-but-set-variable warnings (new with gcc-4.6)Hans de Goede1-4/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>