usb: Fix usb_packet_map() in the presence of IOMMUs
With the IOMMU infrastructure introduced before 1.2, we need to usedma_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...
xhci: tweak limits
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 wecan have, but with additional hubs you can end up with more devices.
Set maxintrs (aka msi vectors) to 16. Should be enougth, especially...
xhci: route string & usb hub support
Parse route string in slot contexts andsupport devices connected via hub.
xhci: create a memory region for each port
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ehci: Fix interrupt packet MULT handling
There are several issues with our handling of the MULT epcap fieldof interrupt qhs, which this patch fixes.
1) When we don't execute a transaction because of the transaction counterbeing 0, p->async stays EHCI_ASYNC_NONE, and the next time we process the...
Merge branch 'usb.65' of git://git.kraxel.org/qemu
net: clean up usbnet_receive()
The USB network interface has two code paths depending on whether or notRNDIS mode is enabled. Refactor usbnet_receive() so that there is acommon path throughout the function instead of duplicating everythingacross if (is_rndis(s)) ... else ... code paths....
net: fix usbnet_receive() packet drops
The USB network interface has a single buffer which the guest readsfrom. This patch prevents multiple calls to usbnet_receive() fromclobbering the input buffer. Instead we queue packets until bufferspace becomes available again....
usb-redir: Add support for migration
Signed-off-by: Hans de Goede <hdegoede@redhat.com>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
usb-redir: Add chardev open / close debug logging
usb-redir: Revert usb-redir part of commit 93bfef4c
Commit 93bfef4c6e4b23caea9d51e1099d06433d8835a4 makes qemu-deviceswhich report the qemu version string to the guest in some way use aqemu_get_version function which reports a machine-specific version string....
uhci: Don't queue up packets after one with the SPD flag set
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 ithas completed, and if it is short we should stop the queue....
ehci: Don't set seen to 0 when removing unseen queue-heads
When removing unseen queue-heads from the async queue list, we should notset the seen flag to 0, as this may cause them to be removed byehci_queues_rip_unused() during the next call to ehci_advance_async_state()...
ehci: Walk async schedule before and after migration
usb-redir: Change cancelled packet code into a generic packet-id queue
usb-redir: Add an already_in_flight packet-id queue
After a live migration, the usb-hcd will re-queue all packets bywalking over the schedule in the guest memory again, but requests whichwere encountered on the migration source before will already be in flight,...
usb-redir: Store max_packet_size in endp_data
So that we've a place to migrate it to / from to allow restoring it aftermigration.
ehci: switch to new-style memory ops
Also register different memory regions for capabilities,operational registers and port status registers. Createseparate tracepoints for operational regs and port statusregs. Ditch a bunch of sanity checks because the memory...
ehci: Fix interrupts stopping when Interrupt Threshold Control is 8
If Interrupt Threshold Control is 8 or a multiple of 8, thens->usbsts_frindex can become exactly 0x4000, at which point(s->usbsts_frindex > s->frindex) will never become true, ass->usbsts_frindex will not be lowered / reset in this case....
ehci: Don't process too much frames in 1 timer tick (v2)
The Linux ehci isoc scheduling code fills the entire schedule ahead oftime minus 80 frames. If we make a large jump in where we are in theschedule, ie 40 frames, then the scheduler all of a sudden will only have...
usb-host: allow emulated (non-async) control requests without USBPacket
xhci needs this for USB_REQ_SET_ADDRESS due to the wayusb addressing is handled by the xhci hardware.
xhci: add msix support
xhci: move register update into xhci_intr_raise
Now that we have a separate function to raise an IRQ we can movesome comon code into the function.
xhci: add XHCIInterrupter
Move all state belonging to the (single) interrupter into a separatestruct. First step in adding support for multiple interrupters.
xhci: prepare xhci_runtime_{read,write} for multiple interrupters
Prepare xhci runtime register access function for multiple interrupters.
xhci: pick target interrupter
Pick the correct interrupter when queuing an event.
xhci: support multiple interrupters
Everything is in place, flip the big switch nowand enable support for multiple interrupters.
xhci: kill xhci_mem_{read,write} dispatcher functions
... and register subregions instead, so we offload the dispatchingto the the memory subsystem which is designed to handle it.
xhci: allow bytewise capability register reads
Some guests need this according toAlejandro Martinez Ruiz <alex@securiforest.com>
xhci: drop buffering
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....
xhci: move device lookup into xhci_setup_packet
xhci: implement mfindex
Implement mfindex register and mfindex wrap event.
xhci: iso xfer support
Add support for iso transfers.
xhci: trace cc codes in cleartext
xhci: add trace_usb_xhci_ep_set_dequeue
xhci: fix runtime write tracepoint
xhci: update register layout
Change the register layout to be a bit more sparse and also not dependon the number of ports. Useful when for making the number of portsruntime-configurable.
xhci: update port handling
This patch changes the way xhci ports are linked to USBPorts. The fixed1:1 relationship between xhci ports and USBPorts is gone. Now eachUSBPort represents a physical plug which has usually two xhci portsassigned: one usb2 and ond usb3 port. usb devices show up at one or the...
usb3: superspeed descriptors
Add superspeed descriptor entry to USBDesc,advertise superspeed support when present.
usb3: superspeed endpoint companion
Add support for building superspeed endpoint companion descriptors,create them for superspeed usb devices.
usb3: bos decriptor
Add support for creating BOS descriptor anddevice cappability descriptors.
usb-storage: usb3 support
Add usb3 descriptors to usb-storage, so it shows up as superspeeddevice when connected to xhci.
xhci: fix & cleanup msi.
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.
xhci: rework interrupt handling
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.
usb-redir: Don't delay handling of open events to a bottom half
There is no need for this, and doing so means that a backend trying towrite immediately after an open event will see qemu_chr_be_can_writereturning 0, which not all backends handle well as there is no wakeup...
usb-redir: Get rid of async-struct get member
This is a preparation patch for completely getting rid of the async-packetstruct in usb-redir, instead relying on the (new) per ep queues in theqemu usb core.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>...
usb-redir: Get rid of local shadow copy of packet headers
The shadow copy only serves as an extra check (besides the packet-id) toensure the packet we get back is a reply to the packet we think it is.
This check has never triggered in all the time usb-redir is in use now,...
usb-redir: Get rid of unused async-struct dev member
usb-redir: Move to core packet id and queue handling
usb-redir: Return babble when getting more bulk data then requested
Babble is the appropriate error in this case (rather then signalling a stall).
usb-redir: Convert to new libusbredirparser 0.5 API
This gives us support for 64 bit ids which is needed for using XHCI withthe new hcd generated ids.
usb-redir: Set ep max_packet_size if available
This is needed for usb-redir to work properly with the xhci emulation.
usb-redir: Add a usbredir_reject_device helper function
usb-redir: Ensure our peer has the necessary caps when redirecting to XHCI
In order for redirection to work properly when redirecting to an emulatedXHCI controller, the usb-redir-host must support bothusb_redir_cap_ep_info_max_packet_size and usb_redir_cap_64bits_ids,...
usb-redir: Enable pipelining for bulk endpoints
Better name usb braille device
Windows users need to know that they have to use the Baum driver to makethe qemu braille device work.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
usb-audio: fix usb version
usb-audio is a full speed (1.1) device,but bcdUSB claims it is usb 2.0. Fix it.
xhci: rip out background transfer code
original xhci code (the one which used libusb directly) used to use'background transfers' for iso streams. In upstream qemu the isostream buffering is handled by usb-host & usb-redir, so we willnever ever need this. It has been left in as reference, but is dead...
usb-core: Add a usb_ep_find_packet_by_id() helper function
usb-core: Allow the first packet of a pipelined ep to complete immediately
This can happen with usb-redir live-migration when the packet gets re-queuedafter the migration and the original queuing from the migration source sidehas already finished.
Revert "ehci: don't flush cache on doorbell rings."
This reverts commit 9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0, which gotadded to fix an issue where the real, underlying cause was not stoppingthe ep queue on an error.
Now that the underlying cause is fixed by the "usb: Halt ep queue and...
ehci: Validate qh is not changed unexpectedly by the guest
-combine the qh check with the check for devaddr changes-also ensure that p gets set to NULL when the queue gets cancelled on devaddr change, which was not done properly before this patch
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
ehci: Update copyright headers to reflect recent work
Update copyright headers to reflect all the work Gerd and I have been doingon the EHCI emulation.
ehci: Properly cleanup packets on cancel
ehci: Properly report completed but not yet processed packets to the guest
Reported packets which have completed before being cancelled as such to thehost. Note that the new code path this patch adds is untested since it I'vebeen unable to actually trigger the race which needs this code path....
ehci: check for EHCI_ASYNC_FINISHED first in ehci_free_packet
Otherwise we'll see the packet free twice in the trace log even thoughit actually happens only once.
ehci: trace guest bugs
make qemu_queue_{cancel,reset} return the number of packets released,so the caller can figure whenever there have been active packets eventhough there shouldn't have been any. Add tracepoint to log this.
ehci: add doorbell trace events
ehci: Add some additional ehci_trace_guest_bug() calls
ehci: Fix memory leak in handling of NAK-ed packets
Currently each time we try to execute a NAK-ed packet we redoehci_init_transfer, and usb_packet_map, re-allocing (without freeing) thesg list every time.
This patch fixes this, it does this by introducing another async state, so...
ehci: Handle USB_RET_PROCERR in ehci_fill_queue
USB_RET_PROCERR can be triggered by the guest (by for example requesting morethen BUFFSIZE bytes), so don't assert on it.
ehci: Correct a comment in fetchqtd packet processing
Since my previous comment said "Should never happen", I tried changing thenext line to an assert(0), which did not go well, which as the new commentsexplains is logical if you think about it for a moment....
usb-redir: Never return USB_RET_NAK for async handled packets
USB_RET_NAK is not a valid response for async handled packets (and willtrigger an assert as such).
Also drop the warning when receiving a status of cancelled for packets notcancelled by qemu itself, this can happen when a device gets unredirected...
usb: controllers do not need to check for babble themselves
If an (emulated) usb-device tries to write more data to a packet thenits iov len, this will trigger an assert in usb_packet_copy(), and ifa driver somehow circumvents that check and writes more data to the...
usb-core: Don't set packet state to complete on a nak
This way the hcd can re-use the same packet to retry without needingto re-init it.
ehci: Fix interrupt endpoints no longer working
One of the recent changes (likely the addition of queuing support) has brokeninterrupt endpoints, this patch fixes this.
uas: move transfer kickoff
Kick next scsi transfer from request release callback instead of commandcompletion callback, otherwise we might get stuck in case scsi_req_unref()doesn't release the request instantly due to someone else holding areference too....
ehci: handle TD deactivation of inflight packets
Check the TDs of inflight packets, cancelpackets in case the guest clears the active bit.
ehci: simplify ehci_state_executing
ehci_state_executing does not need to check for p->usb_status == USB_RET_ASYNCor USB_RET_PROCERR, since ehci_execute_complete already does a similar checkand will trigger an assert if either value is encountered.
USB_RET_ASYNC should never be the packet status when execute_complete runs...
ehci: add ehci_cancel_queue()
Factor out function to cancel all packets of a queue.No behavior change.
ehci: Schedule async-bh when IAAD bit gets set
After the "ehci: Print a warning when a queue unexpectedly contains packetson cancel" commit. Under certain reproducable conditions I was getting thefollowing message: "EHCI: Warning queue not empty on queue reset"....
ehci: Remove unnecessary ehci_flush_qh call
ehci_qh_do_overlay() already calls ehci_flush_qh() before it returns, callingit twice is useless.
ehci: Fix NULL ptr deref when unplugging an USB dev with an iso stream active
usb: unique packet ids
This patch adds IDs to usb packets. Those IDs are (a) supposed to beunique for the lifecycle of a packet (from packet setup until the packetis either completed or canceled) and (b) stable across migration.
uhci, ohci, ehci and xhci use the guest physical address of the transfer...
usb: Halt ep queue en cancel pending packets on a packet error
For controllers which queue up more then 1 packet at a time, we must halt theep queue, and inside the controller code cancel all pending packets on anerror.
There are multiple reasons for this:...
ehci: Fix setting of halt bit from usbcmd register updates
This fixes linux guests started without any USB devices not seeing newlyplugged devices until "lsusb" is done inside the guest.
ehci: fix Interrupt Threshold Control implementation
First, not all interrupts are subject to Interrupt Threshold Control,some of them must be delivered without delay.
Second, Interrupt Threshold Control state must be part of vmstate,otherwise we might loose IRQs on migration....
usb: async control xfer fixup
Need to clear p->result after copying setup data using usb_packet_copy()because we'll reuse the USBPacket for the data transfer.
usb: update uas product id
Pick other product id to fix clash with audio.
Current usage list (after applying this patch):
46f4:0001 -- usb-storage46f4:0002 -- usb-audio46f4:0003 -- usb-uas
ehci: fix assertion typo
Signed-off-by: Alejandro Martinez Ruiz <alex@securiforest.com>Reviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
usb-storage: improve debug logging
usb-storage: fix SYNCHRONIZE_CACHE
Commit 59310659073d85745854f2f10c4292555c5a1c51 is incomplete,we'll arrive in the scsi command complete callback in CSW stateand must handle that case correctly.
net: Rename VLANClientState to NetClientState
The vlan feature is no longer part of net core. Rename VLANClientStateto NetClientState because net clients are not explicitly associated witha vlan at all, instead they have a peer net client to which they are...
net: Rename qemu_del_vlan_client() to qemu_del_net_client()
Another step in moving the vlan feature out of net core. Users onlydeal with NetClientState and therefore qemu_del_vlan_client() should benamed qemu_del_net_client().
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
Merge branch pci into master
Merge master and pci branch, resolve build breakage in hw/esp.cintroduced by f90c2bcd.
Conflicts: hw/esp.c
hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)
NET_CLIENT_TYPE_ -> NET_CLIENT_OPTIONS_KIND_
Signed-off-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Merge remote-tracking branch 'kwolf/for-anthony' into staging
hw/block-common: Factor out fall back to legacy -drive serial=...
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ehci: implement Interrupt Threshold Control support
Also reorganize and comment the irq functions while being at it.
ehci: improve expire time calculation
Move down the expire time calculation down in the frame timer, to thepoint where the timer is actually reloaded. This way we'll notice anyasync_stepdown changes (especially resetting to 0 due to usb activity).