summaryrefslogtreecommitdiff
path: root/hw/usb
AgeCommit message (Collapse)AuthorFilesLines
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-10-11usb-redir: Don't make migration fail in none seamless caseHans de Goede1-4/+9
Instead simple disconnect the device like host redirection does on migration. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-11usb-redir: Change usbredir_open_chardev into usbredir_create_parserHans de Goede1-6/+5
As we need to create the parser at more places. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-06Merge branch 'trivial-patches' of git://github.com/stefanha/qemuAurelien Jarno3-5/+0
* 'trivial-patches' of git://github.com/stefanha/qemu: versatilepb: Use symbolic indices for ARM PIC qdev: kill bogus comment qemu-barrier: Fix compiler version check for future gcc versions hw: Add missing 'static' attribute for QEMUMachine cleanup useless return sentence qemu-sockets: Fix compiler warning (regression for MinGW) vnc: Fix spelling (hellmen -> hellman) in comment slirp: Fix spelling in comment (enought -> enough, insure -> ensure) tcg/arm: Use tcg_out_mov_reg rather than inline equivalent code cpu: Add missing 'static' attribute to qemu_global_mutex configure: Support empty target list (--target-list=) hw: Fix return value check for bdrv_read, bdrv_write
2012-10-05Remove libhwStefan Weil1-7/+7
The entries for libhw* are no longer needed in .gitignore. There is also no longer a difference between common-obj-y and hw-obj-y, so one of those two macros is sufficient. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-05cleanup useless return sentenceAmos Kong3-5/+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-26usb: Fix usb_packet_map() in the presence of IOMMUsDavid Gibson1-9/+15
With the IOMMU infrastructure introduced before 1.2, we need to use dma_memory_map() to obtain a qemu pointer to memory from an IO bus address. However, dma_memory_map() alters the given length to reflect the length over which the used DMA translation is valid - which could be either more or less than the requested length. usb_packet_map() does not correctly handle these cases, simply failing if dma_memory_map() alters the requested length. If dma_memory_map() increased the length, we just need to use the requested length for the qemu_iovec_add(). However, if it decreased the length, it means that a single DMA translation is not valid for the whole sglist element, and so we need to loop, splitting it up into multiple iovec entries for each piece with a DMA translation (in practice >2 pieces is unlikely). This patch implements the correct behaviour Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-26ehci: Fix interrupt packet MULT handlingHans de Goede1-20/+20
There are several issues with our handling of the MULT epcap field of interrupt qhs, which this patch fixes. 1) When we don't execute a transaction because of the transaction counter being 0, p->async stays EHCI_ASYNC_NONE, and the next time we process the same qtd we hit an assert in ehci_state_fetchqtd because of this. Even though I believe that this is caused by 3 below, this patch still removes the assert, as that can still happen without 3, when multiple packets are queued for the same interrupt ep. 2) We only *check* the transaction counter from ehci_state_execute, any packets queued up by fill_queue bypass this check. This is fixed by not calling fill_queue for interrupt packets. 3) Some versions of Windows set the MULT field of the qh to 0, which is a clear violation of the EHCI spec, but still they do it. This means that we will never execute a qtd for these, making interrupt ep-s on USB-2 devices not work, and after recent changes, triggering 1). So far we've stored the transaction counter in our copy of the mult field, but with this beginnig at 0 already when dealing with these version of windows this won't work. So this patch adds a transact_ctr field to our qh struct, and sets this to the MULT field value on fetchqh. When the MULT field value is 0, we set it to 4. Assuming that windows gets way with setting it to 0, by the actual hardware going horizontal on a 1 -> 0 transition, which will give it 4 transactions (MULT goes from 0 - 3). Note that we cannot stop on detecting the 1 -> 0 transition, as our decrement of the transaction counter, and checking for it are done in 2 different places. Reported-by: Shawn Starr <shawn.starr@rogers.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.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-21Merge branch 'usb.65' of git://git.kraxel.org/qemuAurelien Jarno4-134/+618
* 'usb.65' of git://git.kraxel.org/qemu: uhci: Don't queue up packets after one with the SPD flag set usb-redir: Revert usb-redir part of commit 93bfef4c usb-redir: Add chardev open / close debug logging usb-redir: Add support for migration usb-redir: Store max_packet_size in endp_data usb-redir: Add an already_in_flight packet-id queue usb-redir: Change cancelled packet code into a generic packet-id queue ehci: Walk async schedule before and after migration ehci: Don't set seen to 0 when removing unseen queue-heads configure: usbredir fixes ehci: Don't process too much frames in 1 timer tick (v2) ehci: Fix interrupts stopping when Interrupt Threshold Control is 8 ehci: switch to new-style memory ops usb-host: allow emulated (non-async) control requests without USBPacket
2012-09-14net: fix usbnet_receive() packet dropsStefan Hajnoczi1-3/+16
The USB network interface has a single buffer which the guest reads from. This patch prevents multiple calls to usbnet_receive() from clobbering the input buffer. Instead we queue packets until buffer space becomes available again. This is inspired by virtio-net and e1000 rxbuf handling. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-09-14net: clean up usbnet_receive()Stefan Hajnoczi1-13/+17
The USB network interface has two code paths depending on whether or not RNDIS mode is enabled. Refactor usbnet_receive() so that there is a common path throughout the function instead of duplicating everything across if (is_rndis(s)) ... else ... code paths. Clean up coding style and 80 character line wrap along the way. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.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-13usb-redir: Revert usb-redir part of commit 93bfef4cHans de Goede1-5/+3
Commit 93bfef4c6e4b23caea9d51e1099d06433d8835a4 makes qemu-devices which report the qemu version string to the guest in some way use a qemu_get_version function which reports a machine-specific version string. However usb-redir does not expose the qemu version to the guest, only to the usbredir-host as part of the initial handshake. This can then be logged on the usbredir-host side for debugging purposes and is otherwise completely unused! For debugging purposes it is important to have the real qemu version in there, rather then the machine-specific version. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Add chardev open / close debug loggingHans de Goede1-0/+6
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Add support for migrationHans de Goede1-3/+346
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Store max_packet_size in endp_dataHans de Goede1-1/+3
So that we've a place to migrate it to / from to allow restoring it after migration. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Add an already_in_flight packet-id queueHans de Goede1-0/+43
After a live migration, the usb-hcd will re-queue all packets by walking over the schedule in the guest memory again, but requests which were encountered on the migration source before will already be in flight, so these should *not* be re-send to the usbredir-host. This patch adds an already in flight packet ud queue, which will be filled by the source before migration and then moved over to the migration dest, any async handled packets are then checked against this queue to avoid sending the same packet to the usbredir-host twice. Signed-off-by: Hans de Goede <hdegoede@redhat,com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Change cancelled packet code into a generic packet-id queueHans de Goede1-31/+71
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13ehci: Walk async schedule before and after migrationHans de Goede1-0/+28
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13ehci: Don't set seen to 0 when removing unseen queue-headsHans de Goede1-6/+18
When removing unseen queue-heads from the async queue list, we should not set the seen flag to 0, as this may cause them to be removed by ehci_queues_rip_unused() during the next call to ehci_advance_async_state() if the timer is late or running at a low frequency. Note: 1) This *may* have caused the instant unlink / relinks described in commit 9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0 2) Rather then putting more if-s inside ehci_queues_rip_unused, this patch instead introduces a new ehci_queues_rip_unseen function. 3) This patch also makes it save to call ehci_queues_rip_unseen() multiple times, which gets used in the folluw up patch titled: "ehci: Walk async schedule before and after migration" Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-12ehci: Don't process too much frames in 1 timer tick (v2)Hans de Goede1-0/+14
The Linux ehci isoc scheduling code fills the entire schedule ahead of time minus 80 frames. If we make a large jump in where we are in the schedule, ie 40 frames, then the scheduler all of a sudden will only have 40 frames left to work in, causing it to fail packet submissions with error -27 (-EFBIG). Changes in v2: -Don't hardcode a maximum number of frames to process in one tick, instead: -Process a minimum number of frames to ensure we do eventually catch up -Stop (after the minimum number) when the guest has requested an irq Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-12ehci: Fix interrupts stopping when Interrupt Threshold Control is 8Hans de Goede1-1/+1
If Interrupt Threshold Control is 8 or a multiple of 8, then s->usbsts_frindex can become exactly 0x4000, at which point (s->usbsts_frindex > s->frindex) will never become true, as s->usbsts_frindex will not be lowered / reset in this case. This patch fixes this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-12ehci: switch to new-style memory opsGerd Hoffmann1-89/+84
Also register different memory regions for capabilities, operational registers and port status registers. Create separate tracepoints for operational regs and port status regs. Ditch a bunch of sanity checks because the memory core will do this for us now. Offloading the byte, word and dword access handling to the memory core also has the side effect of fixing ehci register access on bigendian hosts. Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-12usb-host: allow emulated (non-async) control requests without USBPacketGerd Hoffmann1-1/+1
xhci needs this for USB_REQ_SET_ADDRESS due to the way usb addressing is handled by the xhci hardware. 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>
2012-09-11xhci: fix & cleanup msi.Gerd Hoffmann1-18/+9
Drop custom write_config function which isn't needed any more. Make the msi property a bit property so it accepts 'on' & 'off'. Enable MSI by default. TODO: add compat property to disable on old machine types. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-storage: usb3 supportGerd Hoffmann1-3/+43
Add usb3 descriptors to usb-storage, so it shows up as superspeed device when connected to xhci. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb3: bos decriptorGerd Hoffmann2-0/+134
Add support for creating BOS descriptor and device cappability descriptors. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb3: superspeed endpoint companionGerd Hoffmann2-20/+61
Add support for building superspeed endpoint companion descriptors, create them for superspeed usb devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb3: superspeed descriptorsGerd Hoffmann2-1/+10
Add superspeed descriptor entry to USBDesc, advertise superspeed support when present. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: update port handlingGerd Hoffmann1-40/+97
This patch changes the way xhci ports are linked to USBPorts. The fixed 1:1 relationship between xhci ports and USBPorts is gone. Now each USBPort represents a physical plug which has usually two xhci ports assigned: one usb2 and ond usb3 port. usb devices show up at one or the other, depending on whenever they support superspeed or not. This patch also makes the number of usb2 and usb3 ports runtime configurable by adding 'p2' and 'p3' properties. It is allowed to have different numbers of usb2 and usb3 ports. Specifying p2=4,p3=2 will give you an xhci adapter which supports all speeds on physical ports 1+2 and usb2 only on ports 3+4.
2012-09-11xhci: update register layoutGerd Hoffmann1-8/+13
Change the register layout to be a bit more sparse and also not depend on the number of ports. Useful when for making the number of ports runtime-configurable.
2012-09-11xhci: fix runtime write tracepointGerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: add trace_usb_xhci_ep_set_dequeueGerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: trace cc codes in cleartextGerd Hoffmann1-1/+47
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: iso xfer supportGerd Hoffmann1-16/+101
Add support for iso transfers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: implement mfindexGerd Hoffmann1-7/+46
Implement mfindex register and mfindex wrap event. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: move device lookup into xhci_setup_packetGerd Hoffmann1-36/+38
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11xhci: drop bufferingGerd Hoffmann1-114/+71
This patch splits the xhci_xfer_data function into three. The xhci_xfer_data function used to do does two things: (1) copy transfer data between guest memory and a temporary buffer. (2) report transfer results to the guest using events. Now we three functions to handle this: (1) xhci_xfer_map creates a scatter list for the transfer and uses that (instead of the temporary buffer) to build a USBPacket. (2) xhci_xfer_unmap undoes the mapping. (3) xhci_xfer_report sends out events. The patch also fixes reporting of transaction errors which must be reported unconditinally, not only in case the guest asks for it using the ISP flag. [ v2: fix warning ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>