summaryrefslogtreecommitdiff
path: root/hw/usb/hcd-uhci.c
AgeCommit message (Collapse)AuthorFilesLines
2012-10-25usb: Move clearing of queue on halt to the coreHans de Goede1-16/+6
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-5/+11
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-25uhci: Move checks to continue queuing to uhci_fill_queue()Hans de Goede1-7/+3
Rather then having a special check to start queuing after the first packet, and then another check for the other packets in uhci_fill_queue(), simply check the previous packet beforehand in uhci_fill_queue() Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25uhci: Properly unmap packets on cancel / invalid pidHans de Goede1-0/+2
Packets with an invalid pid, or which were cancelled have usb_packet_map() called on them on init, but not usb_packet_unmap() before being freed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-11uhci: Raise interrupt when requested even for non active tdsHans de Goede1-1/+9
According to the spec we must raise an interrupt when one is requested even for non active tds. Linux depends on this, for bulk transfers it runs an inactivity timer to work around a bug in early uhci revisions, when we take longer then 200 ms to process a packet, this timer goes of, and as part of the handling Linux then unlinks the qh, and relinks it after the frindex has increased by atleast 1, the problem is Linux only checks for the frindex increases on an interrupt, and we don't send that, causing the qh to go inactive for more then 32 frames, at which point we consider the packet cancelled. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13uhci: Don't queue up packets after one with the SPD flag setHans de Goede1-1/+4
Don't queue up packets after a packet with the SPD (short packet detect) flag set. Since we won't know if the packet will actually be short until it has completed, and if it is short we should stop the queue. This fixes a miniature photoframe emulating a USB cdrom with the windows software for it not working. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb: controllers do not need to check for babble themselvesHans de Goede1-5/+0
If an (emulated) usb-device tries to write more data to a packet then its iov len, this will trigger an assert in usb_packet_copy(), and if a driver somehow circumvents that check and writes more data to the iov then there is space, we have a much bigger problem then not correctly reporting babble to the guest. In practice babble will only happen with (real) redirected devices, and there both the usb-host os and the qemu usb-device code already check for it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-08-31usb: unique packet idsGerd Hoffmann1-2/+2
This patch adds IDs to usb packets. Those IDs are (a) supposed to be unique for the lifecycle of a packet (from packet setup until the packet is either completed or canceled) and (b) stable across migration. uhci, ohci, ehci and xhci use the guest physical address of the transfer descriptor for this. musb needs a different approach because there is no transfer descriptor. But musb also doesn't support pipelining, so we have never more than one packet per endpoint in flight. So we go create an ID based on endpoint and device address. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-08-31usb: Halt ep queue en cancel pending packets on a packet errorHans de Goede1-0/+16
For controllers which queue up more then 1 packet at a time, we must halt the ep queue, and inside the controller code cancel all pending packets on an error. There are multiple reasons for this: 1) Guests expect the controllers to halt ep queues on error, so that they get the opportunity to cancel transfers which the scheduled after the failing one, before processing continues 2) Not cancelling queued up packets after a failed transfer also messes up the controller state machine, in the case of EHCI causing the following assert to trigger: "assert(p->qtdaddr == q->qtdaddr)" at hcd-ehci.c:2075 3) For bulk endpoints with pipelining enabled (redirection to a real USB device), we must cancel all the transfers after this a failed one so that: a) If they've completed already, they are not processed further causing more stalls to be reported, originating from the same failed transfer b) If still in flight, they are cancelled before the guest does a clear stall, otherwise the guest and device can loose sync! Note this patch only touches the ehci and uhci controller changes, since AFAIK no other controllers actually queue up multiple transfer. If I'm wrong on this other controllers need to be updated too! Also note that this patch was heavily tested with the ehci code, where I had a reproducer for a device causing a transfer to fail. The uhci code is not tested with actually failing transfers and could do with a thorough review! Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-07-29Merge branch pci into masterMichael S. Tsirkin1-2/+1
Merge master and pci branch, resolve build breakage in hw/esp.c introduced by f90c2bcd. Conflicts: hw/esp.c
2012-07-12uhci: initialize expire_time when loading v1 vmstateGerd Hoffmann1-0/+12
$subject says all: when loading old (v1) vmstate which doesn't contain expire_time initialize it with a reasonable default (current time). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-07-04pci: convert PCIUnregisterFunc to voidAlex Williamson1-2/+1
Not a single driver has any possibility of failure on their exit function, let's keep it that way. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-27usb: Convert usb_packet_{map, unmap} to universal DMA helpersDavid Gibson1-1/+1
The USB UHCI and EHCI drivers were converted some time ago to use the pci_dma_*() helper functions. However, this conversion was not complete because in some places both these drivers do DMA via the usb_packet_map() function in usb-libhw.c. That function directly used cpu_physical_memory_map(). Now that the sglist code uses DMA wrappers properly, we can convert the functions in usb-libhw.c, thus conpleting the conversion of UHCI and EHCI to use the DMA wrappers. Note that usb_packet_map() invokes dma_memory_map() with a NULL invalidate callback function. When IOMMU support is added, this will mean that usb_packet_map() and the corresponding usb_packet_unmap() must be called in close proximity without dropping the qemu device lock - otherwise the guest might invalidate IOMMU mappings while they are still in use by the device code. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-06-20uhci: fix uhci_async_cancel_allGerd Hoffmann1-2/+2
We update the QTAILQ in the loop, thus we must use the SAFE version to make sure we don't touch the queue struct after freeing it. https://bugzilla.novell.com/show_bug.cgi?id=766310 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07uhci: fix irq routingGerd Hoffmann1-2/+19
The multifunction ich9 ehci controller with uhci companions uses a different interrupt pin for each function. The three uhci devices get pins A, B and C, whereas ehci uses pin D. This way the guest can assign different IRQ lines to each controller. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07uhci: zap uhci_pre_saveGerd Hoffmann1-8/+0
Cancel transactions before saving vmstate is pretty pointless and just causes disruptions. We need to cancel them before *loading* vmstate, but in that case uhci_reset() handles it already and no special action is needed. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07uhci: make bandwidth tunableGerd Hoffmann1-2/+4
Add a property for the uhci bandwidth. Can be used to make uhci emulation run faster than real hardware. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07uhci: use bottom halfGerd Hoffmann1-1/+13
Schedule bottom half on completion of async packets instead of calling uhci_process_frame directly. This way we run uhci_process_frame only once in case multiple packets finish in a row. Also check whenever there is bandwidth left before scheduling uhci_process_frame. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07uhci: fix bandwidth managementGerd Hoffmann1-10/+12
uhci_process_frame() can be invoked multiple times per frame, so accounting usb bandwith in a local variable doesn't fly, use a variable in UHCIState instead. Also check the limit more frequently. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-26usb-uhci: update irq line on resetGerd Hoffmann1-0/+1
uhci_reset() clears irq mask and irq status registers, but doesn't update the irq line. Which may result in suspious IRQs after uhci reset. Fix it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-17usb-uhci: queuing fixGerd Hoffmann1-3/+10
When we queue up usb packets we may happen to find a already queued packet, which also might be finished at that point already. We don't want continue processing the packet at this point though, so lets just signal back we've found a in-flight packet when in queuing mode. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-17usb-uhci: stop queue filling when we find a in-flight tdGerd Hoffmann1-0/+3
Not only QHs can form rings, but TDs too. With the new queuing/pipelining support we are following TD chains and can actually walk in circles. An assert() prevents us from entering an endless loop then. Fix is easy: Just stop queuing when we figure the TD we are about to queue up is in flight already. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: alloc can't fail, drop check.Gerd Hoffmann1-2/+0
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: new uhci_handle_td return code for tds still in flightGerd Hoffmann1-5/+7
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: renumber uhci_handle_td return codesGerd Hoffmann1-4/+4
Step #2 (separate for better bisectability): renumber so the silly '-1' goes away. Pick a range which doesn't overlap the old values. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: use enum for uhci_handle_td return codesGerd Hoffmann1-16/+23
Step #1 (separate for better bisectability): replace numbers with names. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: tracing supportGerd Hoffmann1-55/+32
Zap DPRINTF, add tracepoints instead. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: cancel on schedule stop.Gerd Hoffmann1-0/+1
Cancel any in-flight transaction when the guest stops the uhci schedule. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: fix uhci_async_cancel_allGerd Hoffmann1-0/+1
It should also free all queues. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13uhci: pass addr to uhci_async_allocGerd Hoffmann1-3/+3
Also do async->td initialization in uhci_async_alloc now. Prepares for adding tracepoints. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13usb: zap hw/ush-{ohic,uhci}.h + init wrappersGerd Hoffmann1-16/+0
Remove the uhci and ohci init wrappers, which all wrapped a pci_create_simple() one-liner. Switch callsites to call pci_create_simple directly. Remove the header files where the wrappers where declared. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13usb: the big renameGerd Hoffmann1-0/+1408
Reorganize usb source files. Create a new hw/usb/ directory and move all usb source code to that place. Also make filenames a bit more descriptive. Host adapters are prefixed with "hch-" now, usb device emulations are prefixed with "dev-". Fixup paths Makefile and include paths to make it compile. No code changes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>