usb-core: Add a usb_ep_find_packet_by_id() helper function
Signed-off-by: Hans de Goede <hdegoede@redhat.com>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>...
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.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
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...
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>
uhci: initialize expire_time when loading v1 vmstate
$subject says all: when loading old (v1) vmstate which doesn't containexpire_time initialize it with a reasonable default (current time).
ehci: raise irq in the frame timer
With the async schedule being kicked from other places than the frametimer (commit 0f588df8b3688b00e77aabaa32e26ece5f19bd39) it may happenthat we call ehci_commit_interrupt() more than once per frame.
Move the call from the async schedule handler to the frame timer to...
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).
usb: add usb attached scsi emulation
$subject says all. First cut.
It's a pure UAS (usb attached scsi) emulation, without BOT (bulk-onlytransport) compatibility. If your guest can't handle it use usb-storageinstead.
The emulation works like any other scsi hba emulation (eps, lsi, virtio,...
Merge remote-tracking branch 'mjt/mjt-iov2' into staging
usb: fix interface initialization
zero is a valid interface number, so don't use it when resetting theendpoints.
usb-host: add trace events for iso xfers
Replace iso transfer fprintf's with trace points. Also rename existingtracepoints so they all match usb_host_iso_*.
usb-ehci: Fix an assert whenever isoc transfers are used
hcd-ehci.c is missing an usb_packet_init() call for the ipacket UsbPacketit uses for isoc transfers, triggering an assert (taking the entire vm down)in usb_packet_setup as soon as any isoc transfers are done by a high speed...
ehci: Kick async schedule on wakeup in the non companion case
Commit 0f588df8b3688b00e77aabaa32e26ece5f19bd39, added codeto ehci_wakeup to kick the async schedule on wakeup, but the elsewas positioned wrong making it trigger for devices which are routed...
usb-redir: Correctly handle the usb_redir_babble usbredir status
usb: split endpoint init and reset
Create a new usb_ep_reset() function to reset endpoint state, withoutre-initialiting the queues, so we don't unlink in-flight packets justbecause usb-host has to re-parse the descriptor tables.
ehci: don't flush cache on doorbell rings.
Commit 4be23939ab0d7019c7e59a37485b416fbbf0f073 makes ehci instantlyzap any unlinked queue heads when the guest rings the doorbell.
While hacking up uas support this turned out to be a problem. The linuxkernel can unlink and instantly relink the very same queue head, thereby...
ehci: fix ehci_qh_do_overlay
Use ehci_flush_qh to make sure we touch inly the fields the hc isallowed to touch.
ehci: fix td writeback
Only write back the dwords the hc is supposed to update. Should notmake a difference in theory as the guest must not touch the td whileit is active to avoid races. But it is still more correct.
pci: convert PCIUnregisterFunc to void
Not a single driver has any possibility of failure on theirexit 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>
usb-ohci: Use universal DMA helper functions
The OHCI device emulation can provide both PCI and SysBus OHCIimplementations. Because of this, it was not previously converted touse the PCI DMA helper functions.
This patch converts it to use the new universal DMA helper functions....
usb: Convert usb_packet_{map, unmap} to universal DMA helpers
The USB UHCI and EHCI drivers were converted some time ago to use thepci_dma_*() helper functions. However, this conversion was not completebecause in some places both these drivers do DMA via the usb_packet_map()...
ehci: add live migration support
usb: restore USBDevice->attached on vmload
ehci: tracing improvements
usb-host: attach only to running guest
usb-host: live migration support
uhci: fix uhci_async_cancel_all
We update the QTAILQ in the loop, thus we must use the SAFE versionto make sure we don't touch the queue struct after freeing it.
https://bugzilla.novell.com/show_bug.cgi?id=766310
Allow machines to configure the QEMU_VERSION that's exposed via hardware
QEMU exposes its version to the guest's hardware and in some cases that is wrong(e.g. Windows prints messages about driver updates when you switchthe QEMU version).There is a new field now on the struct QEmuMachine, hw_version, which may...
qdev: Use wrapper for qdev_get_path
This makes it easier to remove it from BusInfo.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>[AF: Drop now unnecessary NULL initialization in scsibus_get_dev_path()]...
qdev: Convert busses to QEMU Object Model
This is far less interesting than it sounds. We simply add an Object to eachBusState and then register the types appropriately. Most of the interestingrefactoring will follow in the next patches.
Since we're changing fundamental type names (BusInfo -> BusClass), it all needs...
qdev: Move bus properties to a separate global
Simple code movement in order to simplify future refactoring.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
qdev: Move bus properties to abstract superclasses
In qdev, each bus in practice identified an abstract superclass, butthis was mostly hidden. In QOM, instead, these abstract classes areexplicit so we can move bus properties there.
All bus property walks are removed, and all device property walks...
Merge remote-tracking branch 'kraxel/usb.52' into staging
change iov_* function prototypes to be more appropriate
Reorder arguments to be more natural, readable andconsistent with other iov_* functions, and changeargument names, from: iov_from_buf(iov, iov_cnt, buf, iov_off, size)to iov_from_buf(iov, iov_cnt, offset, buf, bytes)...
ehci: add ehci_*_enabled() helpers
Add helper functions to query whenever the async / periodic scheduleis enabled or not. Put them into use too.
ehci: update status bits in ehci_set_state
Update the status register in the ehci_set_state function, to make surethe guest-visible register is in sync with our internal schedule state.
ehci: fix halt status handling
When the enable bits for controller / async schedule / periodic schedulechange just make sure we kick the frame timer and letehci_advance_periodic_state and ehci_advance_async_state handle thecontroller state changes.
This will make ehci set USBSTS_HALT when the controller shutdown is...
ehci: remove unused attach_poll_counter
ehci: create ehci_update_frindex
Factor out code from ehci_frame_timer.
ehci: adaptive wakeup rate.
Adapt the frame timer sleeps according to the actual needs. With theperiodic schedule being active we'll have to wakeup 1000 times persecond and go check for work. In case only the async schedule is activewe can be more lazy though. When idle ehci will increate the sleep time...
ehci: rework frame skipping
Move the framecount check out of the loop and use the newehci_update_frindex function to skip frames if needed.
xhci: trace: ring fetch
xhci: trace: endpoints
xhci: trace: transfers
xhci: trace: slots
ehci: add EHCIPacket
Add a separate EHCIPacket struct and move fields over from EHCIQueue.Preparing for supporting multiple packets per queue being in flight atthe same time. No functional changes yet.
Fix some codestyle issues along the way.
ehci: make ehci_execute work on EHCIPacket instead of EHCIQueue
This way it is possible to use ehci_execute to submit others than thefirst EHCIPacket of the EHCIQueue.
ehci: cache USBDevice in EHCIQueue
Keep a USBDevice pointer in EHCIQueue so we don't have to lookup thedevice on each usb packet submission.
ehci: move ehci_flush_qh
Move ehci_flush_qh() function up in the source code.No code change.
ehci: add queuing support
Add packet queuing. Follow the qTD chain to see if there are morepackets we can submit. Improves performance on larger transfers,especially with usb-host, as we don't have to wait for a packet tofinish before sending the next one to the host for processing....
ehci: tweak queue initialization
Little tweak for the queue initialization, set the QH address in theallocation function.
ehci: add async field to EHCIQueue
Keep track whenever a EHCIQueue is part of the async or periodicschedule. This way we don't have to pass around the async flageverywhere but can look it up from the EHCIQueue struct when needed.
ehci: move async schedule to bottom half
This way we can kick the async schedule independant from theperiodic frame timer.
ehci: schedule async bh on async packet completion
When a packet completes which happens to be part of the async schedulekick the async bottom half for processing,
ehci: kick async schedule on wakeup
Kick async schedule when we get a wakeupnotification from a usb device.
ehci: fix reset
Check for the reset bit first when processing USBCMD register writes.Also break out of the switch, there is no need to check the other bits.
usb-storage: remove MSDState->residue
We have the field twice, once in MSDState directly and one in the statusword struct. Drop one.
usb-storage: add usb_msd_packet_complete()
Factor out packet completion to a separate function whichcares to get the MSDState->packet update right.
usb-storage: add scsi_off, remove scsi_buf
Repace the running buffer pointer (scsi_buf) with a buffer offsetfield (scsi_off). The later is alot easier to live-migrate.
usb-storage: migration support
With all scsi migration support bits in place thefinal step is pretty simple ;)
xhci: Clean up reset function
Properly register reset function via the device class.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
xhci: trace: mmio reads+writes
xhci: trace: run+stop
xhci: trace: irq + events
uhci: zap uhci_pre_save
Cancel transactions before saving vmstate is pretty pointless and justcauses disruptions. We need to cancel them before loading vmstate,but in that case uhci_reset() handles it already and no special actionis needed.
uhci: fix irq routing
The multifunction ich9 ehci controller with uhci companions uses adifferent interrupt pin for each function. The three uhci devicesget pins A, B and C, whereas ehci uses pin D. This way the guestcan assign different IRQ lines to each controller....