aboutsummaryrefslogtreecommitdiff
path: root/hw
AgeCommit message (Collapse)AuthorFilesLines
2013-01-10Merge remote-tracking branch 'awilliam/tags/qemu-1.4-vfio-20130109.0' into ↵Anthony Liguori1-6/+28
staging vfio-pci: Fixes for qemu 1.4 & stable * awilliam/tags/qemu-1.4-vfio-20130109.0: vfio-pci: Loosen sanity checks to allow future features vfio-pci: Make host MSI-X enable track guest Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-08vfio-pci: Loosen sanity checks to allow future featuresAlex Williamson1-2/+2
VFIO_PCI_NUM_REGIONS and VFIO_PCI_NUM_IRQS should never have been used in this manner as it locks a specific kernel implementation. Future features may introduce new regions or interrupt entries (VGA may add legacy ranges, AER might add an IRQ for error signalling). Fix this before it gets us into trouble. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Cc: qemu-stable@nongnu.org
2013-01-08vfio-pci: Make host MSI-X enable track guestAlex Williamson1-4/+26
Guests typically enable MSI-X with all of the vectors in the MSI-X vector table masked. Only when the vector is enabled does the vector get unmasked, resulting in a vector_use callback. These two points, enable and unmask, correspond to pci_enable_msix() and request_irq() for Linux guests. Some drivers rely on VF/PF or PF/fw communication channels that expect the physical state of the device to match the guest visible state of the device. They don't appreciate lazily enabling MSI-X on the physical device. To solve this, enable MSI-X with a single vector when the MSI-X capability is enabled and immediate disable the vector. This leaves the physical device in exactly the same state between host and guest. Furthermore, the brief gap where we enable vector 0, it fires into userspace, not KVM, so the guest doesn't get spurious interrupts. Ideally we could call VFIO_DEVICE_SET_IRQS with the right parameters to enable MSI-X with zero vectors, but this will currently return an error as the Linux MSI-X interfaces do not allow it. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Cc: qemu-stable@nongnu.org
2013-01-08qdev: Don't assume existence of parent bus on unparentingAndreas Färber1-3/+5
Commit 667d22d1ae59da46b4c1fbd094ca61145f19b8c3 (qdev: move bus removal to object_unparent) made the assumption that at unparenting time parent_bus is not NULL. This assumption is unjustified since object_unparent() may well be called directly after object_initialize(), without any qdev_set_parent_bus(). This did not cause any issues yet because qdev_[try_]create() does call qdev_set_parent_bus(), falling back to SysBus if unsupplied. While at it, ensure that this new function uses the device_ prefix and make the name more neutral in light of this semantic change. Reported-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> Tested-by: Igor Mammedov <imammedo@redhat.com>
2013-01-08qdev: Include qdev code into *-user, tooEduardo Habkost1-2/+7
The code depends on some functions from qemu-option.o, so add qemu-option.o to universal-obj-y to make sure it's included. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-01-08Merge remote-tracking branch 'kraxel/usb.75' into stagingAnthony Liguori21-330/+3279
* kraxel/usb.75: (32 commits) uhci: stop using portio lists usbredir: Add support for buffered bulk input (v2) exynos4210: Add EHCI support usb/ehci: Add SysBus EHCI device for Exynos4210 usb/ehci: Move capsbase and opregbase into SysBus EHCI class usb/ehci: Clean up SysBus and PCI EHCI split xhci: call set-address with dummy usbpacket usb-redir: Add debugging to bufpq save / restore usbredir: Add usbredir_init_endpoints() helper usbredir: Verify we have 32 bits bulk length cap when redirecting to xhci usbredir: Add ep_stopped USBDevice method usbredir: Add USBEP2I and I2USBEP helper macros usbredir: Add an usbredir_stop_ep helper function usb: Add an usb_device_ep_stopped USBDevice method usb: Fix usb_ep_find_packet_by_id hid: Change idle handling to use a timer uhci: Maximize how many frames we catch up when behind uhci: Limit amount of frames processed in one go uhci: Add a QH_VALID define uhci: Fix pending interrupts getting lost on migration ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-08uhci: stop using portio listsGerd Hoffmann1-76/+30
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-08usbredir: Add support for buffered bulk input (v2)Hans de Goede7-20/+2717
Buffered bulk mode is intended for bulk *input* endpoints, where the data is of a streaming nature (not part of a command-response protocol). These endpoints' input buffer may overflow if data is not read quickly enough. So in buffered bulk mode the usb-host takes care of the submitting and re-submitting of bulk transfers. Buffered bulk mode is necessary for reliable operation with the bulk in endpoints of usb to serial convertors. Unfortunatelty buffered bulk input mode will only work with certain devices, therefor this patch also adds a usb-id table to enable it for devices which need it, while leaving the bulk ep handling for other devices unmodified. Note that the bumping of the required usbredir from 0.5.3 to 0.6 does not mean that we will now need a newer usbredir release then qemu-1.3, .pc files reporting 0.5.3 have only ever existed in usbredir builds directly from git, so qemu-1.3 needs the 0.6 release too. Changes in v2: -Split of quirk handling into quirks.c Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-01-07exynos4210: Add EHCI supportLiming Wang2-1/+8
Add EHCI USB host controller to exynos4210. Signed-off-by: Liming Wang <walimisdev@gmail.com> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Reviewed-by: Igor Mitsyanko <i.mitsyanko@samsung.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usb/ehci: Add SysBus EHCI device for Exynos4210Andreas Färber2-0/+17
It uses a different capsbase and opregbase than the Xilinx device. Signed-off-by: Liming Wang <walimisdev@gmail.com> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Cc: Igor Mitsyanko <i.mitsyanko@samsung.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usb/ehci: Move capsbase and opregbase into SysBus EHCI classAndreas Färber2-2/+26
This allows specific derived models to use different values. Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usb/ehci: Clean up SysBus and PCI EHCI splitAndreas Färber3-24/+60
SysBus EHCI was introduced in a hurry before 1.3 Soft Freeze. To use QOM casts in place of DO_UPCAST() / FROM_SYSBUS(), we need an identifying type. Introduce generic abstract base types for PCI and SysBus EHCI to allow multiple types to access the shared fields. While at it, move the state structs being amended with macros to the header file so that they can be embedded. The VMSTATE_PCI_DEVICE() macro does not play nice with the QOM parent_obj naming convention, so defer that cleanup. Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07xhci: call set-address with dummy usbpacketGerd Hoffmann1-1/+6
Due to the way devices are addressed with xhci (done by hardware, not the guest os) there is no packet when invoking the set-address control request. Create a dummy packet in that case to avoid null pointer dereferences. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usb-redir: Add debugging to bufpq save / restoreHans de Goede1-3/+11
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usbredir: Add usbredir_init_endpoints() helperHans de Goede1-9/+13
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usbredir: Verify we have 32 bits bulk length cap when redirecting to xhciHans de Goede1-0/+2
The xhci-hcd may submit bulk transfers > 65535 bytes even when not using bulk-in pipeling, so usbredir can only be used in combination with an xhci hcd if the client has the 32 bits bulk length capability. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usbredir: Add ep_stopped USBDevice methodHans de Goede1-0/+9
To ensure that interrupt receiving is properly stopped when the guest is no longer interested in an interrupt endpoint. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usbredir: Add USBEP2I and I2USBEP helper macrosHans de Goede1-3/+7
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usbredir: Add an usbredir_stop_ep helper functionHans de Goede1-22/+19
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usb: Add an usb_device_ep_stopped USBDevice methodHans de Goede6-5/+68
Some usb devices (host or network redirection) can benefit from knowing when the guest stops using an endpoint. Redirection may involve submitting packets independently from the guest (in combination with a fifo buffer between the redirection code and the guest), to ensure that buffers of the real usb device are timely emptied. This is done for example for isoc traffic and for interrupt input endpoints. But when the (re)submission of packets is done by the device code, then how does it know when to stop this? For isoc endpoints this is handled by detecting a set interface (change alt setting) command, which works well for isoc endpoints. But for interrupt endpoints currently the redirection code never stops receiving data from the device, which is less then ideal. However the controller emulation is aware when a guest looses interest, as then the qh for the endpoint gets unlinked (ehci, ohci, uhci) or the endpoint is explicitly stopped (xhci). This patch adds a new ep_stopped USBDevice method and modifies the hcd code to call this on queue unlink / ep stop. This makes it possible for the redirection code to properly stop receiving interrupt input (*) data when the guest no longer has interest in it. *) And in the future also buffered bulk input. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07usb: Fix usb_ep_find_packet_by_idHans de Goede1-1/+1
usb_ep_find_packet_by_id mistakenly only checks the first packet and if that is not a match, keeps trying the first packet! This patch fixes this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07hid: Change idle handling to use a timerHans de Goede3-13/+43
This leads to cleaner code in usb-hid, and removes up to a 1000 calls / sec to qemu_get_clock_ns(vm_clock) if idle-time is set to its default value of 0. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07uhci: Maximize how many frames we catch up when behindHans de Goede1-0/+8
If somehow we've gotten behind a lot, simply skip ahead, like the ehci code does. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07uhci: Limit amount of frames processed in one goHans de Goede1-16/+27
Before this patch uhci would process an unlimited amount of frames when behind on schedule, by setting the timer to a time already past, causing the timer subsys to immediately recall the frame_timer function gain. This would cause invalid cancellations of bulk queues when the catching up processed more then 32 frames at a moment when the bulk qh was temporarily unlinked (which the Linux uhci driver does). This patch fixes this by processing maximum 16 frames in one go, and always setting the timer one ms later, making the code behave more like the ehci code. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07uhci: Add a QH_VALID defineHans de Goede1-4/+5
Rather then using the magic 32 value in various places. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07uhci: Fix pending interrupts getting lost on migrationHans de Goede1-1/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07uhci: Fix 1 ms delay in interrupt reporting to the guestHans de Goede1-11/+13
Re-arrange how we process frames / increase frnum / report pending interrupts, to avoid a 1 ms delay in interrupt reporting to the guest. This increases the packet throughput for cases where the guest submits a single packet, then waits for its completion then re-submits from 500 pkts / sec to 1000 pkts / sec. This impacts for example the use of redirected / virtual usb to serial convertors. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Don't call commit_irq after raising PCDHans de Goede1-2/+0
ehci_raise_irq(s, USBSTS_PCD), gets applied immediately so there is no need to call commit_irq after it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Further speedup rescanning if async schedule after raising an interruptHans de Goede1-1/+4
I tried lowering the time between raising an interrupt and rescanning the async schedule to see if the guest has queued a new transfer before, but that did not have any positive effect. I now believe the cause for this is that lowering this time made it more likely to hit the 1 ms interrupt threshold penalty for the next packet, as described in my "ehci: Use uframe precision for interrupt threshold checking" commit. Now that we do interrupt threshold handling with uframe precision, futher lowering this time from .5 to .25 ms gives an extra 15% improvement in speed (MB/s) reading from a simple USB-2.0 thumb-drive. While at it also properly set the int_req_by_async flag for short packet completions. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Use uframe precision for interrupt threshold checking (v2)Hans de Goede1-23/+47
Before this patch, the following could happen: 1) Transfer completes, raises interrupt 2) .5 ms later we check if the guest has queued up any new transfers 3) We find and execute a new transfer 4) .2 ms later the new transfer completes 5) We re-run our frame_timer to write back the completion, but less then 1 ms has passed since our last run, so frindex is not changed, so the interrupt threshold code delays the interrupt 6) 1 ms from the re-run our frame-timer runs again and finally delivers the interrupt This leads to unnecessary large delays of interrupts, this code fixes this by changing frindex to uframe precision and using that for interrupt threshold control, making the interrupt fire at step 5 for guest which have low interrupt threshold settings (like Linux). Note that the guest still sees the frindex move in steps of 8 for migration compatibility. This boosts Linux read speed of a simple cheap USB thumb drive by 6 %. Changes in v2: -Make the guest see frindex move in steps of 8 by modifying ehci_opreg_read, rather then using a shadow variable Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Verify a queue's ep direction does not changeHans de Goede2-0/+20
ehci_fill_queue assumes that there is a one on one relationship between an ep and a qh, this patch adds a check to ensure this. Note I don't expect this to ever trigger, this is just something I noticed the guest might do while working on other stuff. The only way this check can trigger is if a guest mixes in and out qtd-s in a single qh for a non control ep. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Add an ehci_get_pid helper functionHans de Goede1-16/+16
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Verify qtd for async completed packetsHans de Goede1-14/+1
Remove the short-circuiting of fetchqtd in fetchqh, so that the qtd gets properly verified before completing the transaction. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: writeback_async_complete_packet: verify qh and qtdHans de Goede1-0/+14
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Move get / put_dwords upwardsHans de Goede1-42/+42
No other changes. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Verify guest does not change the token of inflight qtd-sHans de Goede1-6/+4
This is not allowed, except for clearing active on cancellation, so don't warn when the new token does not have its active bit set. This unifies the cancellation path for modified qtd-s, and prepares ehci_verify_qtd to be used ad an extra check inside ehci_writeback_async_complete_packet(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Add ehci_verify_qh and ehci_verify_qtd helper functionsHans de Goede1-16/+35
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07ehci: Add a ehci_writeback_async_complete_packet helper functionHans de Goede1-11/+17
Also drop the warning printf, which was there mainly because this was an untested code path (as the previous bug fixes to it show), but that no longer is the case now :) Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-07rtl8139: preserve link state across device resetAmos Kong1-1/+2
A device reset does not affect the link state, only set_link does. Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-07e1000: no need auto-negotiation if link was downAmos Kong1-0/+5
Commit b9d03e352cb6b31a66545763f6a1e20c9abf0c2c added link auto-negotiation emulation, it would always set link up by callback function. Problem exists if original link status was down, link status should not be changed in auto-negotiation. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-07e1000: Discard oversized packets based on SBP|LPEMichael Contreras1-2/+5
Discard packets longer than 16384 when !SBP to match the hardware behavior. Signed-off-by: Michael Contreras <michael@inetric.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-06Revert "virtio-pci: replace byte swap hack"Blue Swirl1-1/+16
This reverts commit 9807caccd605d09a72495637959568d690e10175. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-06virtio-pci: replace byte swap hackBlue Swirl1-16/+1
Remove byte swaps by declaring the config space as native endian. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-05hw/i386: Fix broken build for non POSIX hostsStefan Weil1-0/+5
pc-testdev.c cannot be compiled with MinGW (and other non POSIX hosts): CC i386-softmmu/hw/i386/../pc-testdev.o qemu/hw/i386/../pc-testdev.c:38:22: warning: sys/mman.h: file not found qemu/hw/i386/../pc-testdev.c: In function ‘test_flush_page’: qemu/hw/i386/../pc-testdev.c:103: warning: implicit declaration of function ‘mprotect’ ... Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-04Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori3-2/+6
* stefanha/trivial-patches: spice: drop incorrect vm_change_state_handler() opaque linux-user/syscall.c: remove forward declarations hw/mcf5206: Reduce size of lookup table Remove --sparc_cpu option from the configure list pseries: Remove unneeded include statement (fixes MinGW builds) pc_sysfw: Check for qemu_find_file() failure Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-04Merge remote-tracking branch 'kraxel/testdev.1' into stagingAnthony Liguori5-49/+283
* kraxel/testdev.1: pc: remove bochs bios debug ports hw: Add test device for unittests execution add isa-debug-exit device. switch debugcon to memory api Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-04hw/mcf5206: Reduce size of lookup tableStefan Weil1-1/+1
This typically reduces the size from 512 bytes to 128 bytes. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-04pseries: Remove unneeded include statement (fixes MinGW builds)Stefan Weil1-1/+1
sys/mman.h is not needed (tested on Linux) and unavailable for MinGW, so remove it. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-04pc_sysfw: Check for qemu_find_file() failureMarkus Armbruster1-0/+4
pc_fw_add_pflash_drv() ignores qemu_find_file() failure, and happily creates a drive without a medium. When pc_system_flash_init() asks for its size, bdrv_getlength() fails with -ENOMEDIUM, which isn't checked either. It fails relatively cleanly only because -ENOMEDIUM isn't a multiple of 4096: $ qemu-system-x86_64 -S -vnc :0 -bios nonexistant qemu: PC system firmware (pflash) must be a multiple of 0x1000 [Exit 1 ] Fix by handling the qemu_find_file() failure. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-04pc: remove bochs bios debug portsGerd Hoffmann1-41/+0
Prehistoric leftover, zap it. We poweroff via acpi these days. And having a port (0x501,0x502) where any random guest write will make qemu exit -- with no way to turn it off -- is a bad joke anyway. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>