Use error_is_set() only when necessary
error_is_set(&var) is the same as var != NULL, but it takeswhole-program analysis to figure that out. Unnecessarily hard foroptimizers, static checkers, and human readers. Dumb it down toobvious.
Gets rid of several dozen Coverity false positives....
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
acpi,pc,pci fixes and enhancements
Most changes here are hotplug related:
This merges hotplug infrastructure changes by Igor,some acpi related fixes, and PC fixes.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
exec: Make stl_*_phys input an AddressSpace
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
pci/shpc: convert SHPC hotplug to use hotplug-handler API
Split shpc_device_hotplug() into hotplug/unplug callbacksand register them as "hotplug-handler" interface implementation ofPCI_BRIDGE_DEV device.
Replace pci_bus_hotplug() wiring with setting link on PCI BUS...
pci/pcie: convert PCIE hotplug to use hotplug-handler API
Split pcie_cap_slot_hotplug() into hotplug/unplug callbacksand register them as "hotplug-handler" interface implementation ofPCIE_SLOT device.
hw/pci: switch to a generic hotplug handling for PCIDevice
make qdev_unplug()/device_set_realized() to call hotplug handler'splug/unplug methods if available and remove not needed anymorehot(un)plug handling from PCIDevice.
In case if hotplug handler is not available, revert to the legacy...
qdev:pci: refactor PCIDevice to use generic "hotpluggable" property
Get rid of PCIDevice specific PCIDeviceClass.no_hotplug and usegeneric DeviceClass.hotpluggable field instead.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>Reviewed-by: Michael S. Tsirkin <mst@redhat.com>...
hw/pci: fix error flow in pci multifunction init
Scenario: - There is a non multifunction pci device A on 00:0X.0. - Hot-plug another multifunction pci device B at 00:0X.1. - The operation will fail of course. - Try to hot-plug the B device 2-3 more times, qemu will crash....
pci: add pci_for_each_bus_depth_first
Useful for ACPI hotplug.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
acpi,pci,pc,fedora,virtio fixes and enhancements
This includes some Preparatory patches for cpu hotplug for q25 and memoryhotplug by Igor, tests and memory mapping changeby Laszlo and pci reset cleanup by Paolo....
qdev: Drop misleading qbus_free() function
Same reasoning as commit 02a5c4c97422b40034f31265e0f139f7846172a8("qdev: Drop misleading qdev_free() function"). The qbus_free()function removes the child from the namespace and decrements thereference count. It does not, however, guarantee to free the child...
pci: do not export pci_bus_reset
qbus_reset_all can be used instead. There is no semantic changebecause pcibus_reset returns 1 and takes care of the devicetree traversal.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: clean up resetting of IRQs
pci_device_reset will deassert the INTX pins, and this will make theirq_count array all-zeroes. Check that this is the case, and removethe existing loop which might even unsync irq_count and irq_state.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
qdev: switch reset to post-order
Post-order is the only sensible direction for the reset signals.For example, suppose pre-order is used and the parent has some datastructures that cache children state (for example a list of activerequests). When the reset method is invoked on the parent, these caches...
pci: fix pci bridge fw path
qemu uses "pci" as name for pci bridges in the firmware device path.seabios expects "pci-bridge". Result is that bootorder is broken fordevices behind pci bridges.
Some googling suggests that "pci-bridge" is the correct one. At least...
pci: fix address space size for bridge
Address space size for bridge should be full 64 bit,so we should use UINT64_MAX not INT64_MAX as it's size.
pci: unregister vmstate_pcibus on unplug
PCIBus registers a vmstate during init. Unregister it uponremoval/unplug.
Signed-off-by: Bandan Das <bsd@redhat.com>Cc: qemu-stable@nongnu.orgReviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Revert "hw/pci: partially handle pci master abort"
This reverts commit a53ae8e934cd54686875b5bcfc2f434244ee55d6.
The patch being reverted introduced a low-priority memory regioncovering all 64 bit pci address space. This exposed the following bugselsewhere in the code:...
bswap.h: Remove cpu_to_be32wu()
Replace the legacy cpu_to_be32wu() with stl_be_p().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Michael S. Tsirkin <mst@redhat.com>Message-id: 1383669517-25598-8-git-send-email-peter.maydell@linaro.org...
qdev: Drop misleading qdev_free() function
The qdev_free() function name is misleading since all the function doesis unlink the device from its parent. The device is not necessarilyfreed.
The device will be freed when its QObject refcount reaches zero. It is...
pci, pc, acpi fixes, enhancements
This includes some pretty big changes:- pci master abort support by Marcel- pci IRQ API rework by Marcel- acpi generation support by myself
Everything has gone through several revisions, latest versions have been on...
Makefile.target: CONFIG_NO_* variables removed
CONFIG_NO_* variables replaced with the lnot logical function
Signed-off-by: Ákos Kovács <akoskovacs@gmx.com>[PMM: fixed a few CONFIG_NO_* uses that were missed]Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
pcie_host: expose UNMAPPED macro
Make it possible to test unmapped status through QMP.
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>Tested-by: Gerd Hoffmann <kraxel@redhat.com>Reviewed-by: Igor Mammedov <imammedo@redhat.com>Tested-by: Igor Mammedov <imammedo@redhat.com>...
pcie_host: expose address format
Callers pass in the address so it's helpful forthem to be able to decode it.
pci: fix up w64 size calculation helper
BAR base was calculated incorrectly.Use existing pci_bar_address to get it right.
Tested-by: Igor Mammedov <imammedo@redhat.com>Reviewed-by: Igor Mammedov <imammedo@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw: set interrupts using pci irq wrappers
pci_set_irq and the other pci irq wrappers usePCI_INTERRUPT_PIN config register to compute deviceINTx pin to assert/deassert.
An irq is allocated using pci_allocate_irq wrapperonly if is needed by non pci devices....
hw/pcie: AER and hot-plug events must use device's interrupt
The fields hpev_intx and aer_intx were removed becauseboth AER and hot-plug events must use device's interrupt.Assert/deassert interrupts using pci irq wrappers instead.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>...
hw/pci: removed irq field from PCIDevice
Instead of exposing the the irq field,pci wrappers to qemu_set_irq or qemu_irq_*can be used.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/pci: partially handle pci master abort
A MemoryRegion with negative priority was created andit spans over all the pci address space.It "intercepts" the accesses to unassigned pciaddress space and will follow the pci spec: 1. returns -1 on read 2. does nothing on write...
hw/pci: add pci wrappers for allocating and asserting irqs
Interrupt pin is selected and saved into PCI_INTERRUPT_PINregister during device initialization. Devices should not calldirectly qemu_set_irq and specify the INTx pin on each call.
Added pci_* wrappers to replace qemu_set_irq, qemu_irq_raise,...
pci: remove explicit check to 64K ioport size
This check is useless, as bigger addresses will be ignored whenadded to 'io' MemoryRegion, which has a size of 64K.
However, some architectures don't use the 'io' MemoryRegion, likethe alpha and versatile platforms. They create a PCI I/O region...
pci: add helper to retrieve the 64-bit range
Add c++ keywords to QAPI helper script
Add c++ keywords to avoid errors in compiling with c++ compiler.This also renames class member of PciDeviceInfo to q_class.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>...
pc,pci,virtio fixes and cleanups
This includes pc and pci cleanups and enhancements,and a virtio bugfix for level interrupts.
qdev: Pass size to qbus_create_inplace()
To be passed to object_initialize().
Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument isvoid*, so drop some superfluous (BusState *) casts or direct parentfield usages.
Signed-off-by: Andreas Färber <afaerber@suse.de>
pci: Pass size to pci_bus_new_inplace()
To be passed to qbus_create_inplace().
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
pci: add config space access traces
This adds pci_cfg_read and pci_cfg_write traces for config spacesaccesses.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: Introduce helper to retrieve a PCI device's DMA address space
A PCI device's DMA address space (possibly an IOMMU) is returned by amethod on the PCIBus. At the moment that only has one caller, so themethod is simply open coded. We'll need another caller for VFIO, so...
pcie_port: Turn PCIEPort and PCIESlot into abstract QOM types
Move PCIEPort's "port" property to the new type, same for "aer_log_max".Move PCIESlot's "chassis" and "slot" properties to the new type.
Reviewed-by: Don Koch <dkoch@verizon.com>Acked-by: Michael S. Tsirkin <mst@redhat.com>...
pci-bridge: Turn PCIBridge into abstract QOM type
Introduce TYPE_PCI_BRIDGE as base type and use PCI_BRIDGE() casts.
Reviewed-by: Don Koch <dkoch@verizon.com>Acked-by: Michael S. Tsirkin <mst@redhat.com>[AF: Updated pbm-bridge parent to TYPE_PCI_BRIDGE]...
scsi: Improve error propagation for scsi_bus_legacy_handle_cmdline()
Let scsi_bus_legacy_add_drive() and scsi_bus_legacy_handle_cmdline()return an Error**. Prepare qdev initfns for QOM realize error model.
pci,net,pc enhancements
This includes some fixes and enhancements that accumulated in my tree:pci fixes by dkoch, virtio-net enhancements by akong and mst,and a fix for xen pc by mst.
pci-bridge: update mappings for migration/restore
Fix for LP#1187529: Devices on PCI bridge stop working whenlive-migrated. Update bridge mappings for all PCI bridgedevices in get_pci_config_device().
Signed-off-by: Don Koch <dkoch@verizon.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci,misc enhancements
This includes some pci enhancements:
Better support for systems with multiple PCI root busesFW cfg interface for more robust pci programming in BIOSMinor fixes/cleanups for fw cfg and cross-version migration -...
pci: Use helper to find device's root bus in pci_find_domain()
Currently pci_find_domain() performs two functions - it locates the PCIroot bus above the given bus, then looks up that root bus's domain number.This patch adds a helper function to perform the first task, finding the...
pci: Replace pci_find_domain() with more general pci_root_bus_path()
pci_find_domain() is used in a number of places where we want an id for awhole PCI domain (i.e. the subtree under a PCI root bus). The trouble isthat many platforms may support multiple independent host bridges with no...
pci: Add root bus argument to pci_get_bus_devfn()
pci_get_bus_devfn() interprets a full PCI address string to give a PCIBus *and device/function number within that bus. Currently it assumes it isworking on an address under the primary PCI root bus. This patch extends...
pci: Add root bus parameter to pci_nic_init()
At present, pci_nic_init() and pci_nic_init_nofail() assume that they willonly create a NIC under the primary PCI root. As we add support formultiple PCI roots, that may no longer be the case. This patch adds a root...
pci: Simpler implementation of primary PCI bus
Currently pci_find_primary_bus() searches the list of root buses for onewith domain 0. But since host buses are always registered with domain 0,this just amounts to finding the only PCI host bus. The only remaining...
pci: Remove domain from PCIHostBus
There are now no users of the domain field of PCIHostBus, so remove itfrom the structure, and as a parameter from the pci_host_bus_register()function which sets it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>...
pci: Fold host_buses list into PCIHostState functionality
The host_buses list is an odd structure - a list of pointers to PCI rootbuses existing in parallel to the normal qdev tree structure. This patchremoves it, instead putting the link pointers into the PCIHostState...
pci: Abolish pci_find_root_bus()
pci_find_root_bus() takes a domain parameter. Currently PCI root buseswith domain other than 0 can't be created, so this is more or less a longwinded way of retrieving the main PCI root bus. Numbered domains don'tactually properly cover the (non x86) possibilities for multiple PCI root...
hw/p*: pass owner to memory_region_init* functions
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: add owner argument to initialization functions
pci: Cleanup configuration for pci-hotplug.c
pci-hotplug.c and the CONFIG_PCI_HOTPLUG variable which controls itscompilation are misnamed. They're not about PCI hotplug in general, butrather about the pci_add/pci_del interface which are now deprecated in...
pci: Move pci_read_devaddr to pci-hotplug-old.c
pci_read_devaddr() is only used by the legacy functions for the old PCIhotplug interface in pci-hotplug-old.c. So we move the function there,and make it static.
dma: eliminate DMAContext
The DMAContext is a simple pointer to an AddressSpace that is now alwaysalready available. Make everyone hold the address space directly,and clean up the DMA API to use the AddressSpace directly.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
memory: give name to every AddressSpace
The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpacestructs created by PCI and VIO devices. Those devices do not normallyhave names and therefore not present in "info mtree" output....
dma: eliminate old-style IOMMU support
The translate function in the DMAContext is now always NULL.Remove every reference to it.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pci: use memory core for iommu support
Use the new iommu support in the memory core for iommu support. The onlyuser, spapr, is also converted, but it still provides a DMAContextinterface until the non-PCI bits switch to AddressSpace.
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>...
qdev: Drop FROM_QBUS() macro
Use QOM cast macros I2C_BUS(), SSI_BUS(), PCI_BUS() instead.
pci: add VMSTATE_MSIX
Using a trick cut+pasted from vmstate_scsi_deviceto wind up msix_save and msix_load.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Acked-by: Michael S. Tsirkin <mst@redhat.com>
exec: eliminate qemu_put_ram_ptr
hw: move PCI bridges to hw/pci-* or hw/ARCH
hw: move target-independent files to subdirectories
This patch tackles all files that are compiled once, movingthem to subdirectories of hw/.
hw: make all of hw/pci/ configurable via default-configs/
hw: move headers to include/
Many of these should be cleaned up with proper qdev-/QOM-ification.Right now there are many catch-all headers in include/hw/ARCH dependingon cpu.h, and this makes it necessary to compile these files per-target.However, fixing this does not belong in these patches....
usb-storage: Forward serial number to scsi-disk
usb-storage takes care to fetch the USB serial number from -driveoptions, but it neglected to pass its own 'serial' property to thescsi-disk it creates. With this patch, the 'serial' qdev property andthe 'serial' option in -drive behave the same and correctly apply the...
virtio,pci,qom
Work by Alex to support VGA assignment,pci and virtio fixes by Stefan, Jason and myself, and anew qmp event for hotplug support by myself.
pcie: Add endpoint capability initialization wrapper
Fix the awkward API of mangling the caller specified PCIe type andjust provide an interface to initialize an endpoint device. Thiswill pick either a regular endpoint or integrated endpoint based onthe bus and return pcie_cap_init to doing exactly what is asked....
pci: Create and register a new PCI Express TypeInfo
This will allow us to differentiate Express and Legacy buses.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: Move PCI and PCIE type defines
Move these so that we can reference them from a more common headerinstead of including pci_bus.h everywhere.
pci: Allow PCI bus creation interfaces to specify the type of bus
No change to any types.
pci: Create pci_bus_is_express helper
For testing the bus type.
pci: Create and use API to determine root buses
pcie: Mangle types to match topology
Windows will fail to start drivers for devices with an Endpoint typePCIe capability attached to a Root Complex (code 10 - Device cannotstart). The proper type for such a device is Root Complex IntegratedEndpoint. Devices don't care which they are, so do this conversion...
pci: Teach PCI Bridges about VGA routing
Each PCI Bridge has a set of implied VGA regions that are enabled whenthe VGA bit is set in the bridge control register. This allows VGAdevices behind bridges. Unfortunately with VGA Enable, which weformerly allowed but didn't back, comes along some required VGA...
pci_bridge: factor out common code
Reuse common code in pcie_port, override the hardwired-to-0bits per PCI Express spec.No functional change but makes the code easier to follow.
pci_bridge: drop formatting from source
We use the same formatting for all files, itdoesn't make sense to have formatting directives onlyin pci bridge header.
pci: Fix INTx routing notifier recursion
For some reason we recurse to fire the INTx routing notifier for eachchild of a bus, for each possible device of a bus. That means that ifwe add a root port, the notifier gets called for that bridge 256times. If we add an upstream switch behind that root port, 256^2. But...
pci_bridge: Use a default map_irq function
The PCI bridge spec defines a default swizzle for translating INTxIRQs from secondary bus to primary. Use this by default for anybridge that doesn't set a function.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
pci: refuse empty ROM files
A zero size ROM file is invalid and should produce a warning.Attempting to use a zero size file ends up hitting an assertionqemu_ram_set_idstr() because RAMBlocks with duplicate addresses areallocated - due to zero size the allocator doesn't increment the next...
pci: Add PCI VGA helpers
Allow devices to register VGA memory regions for handling PCI specdefined VGA I/O port and MMIO areas. PCI will attach these to thebus address spaces and enable them according to the device commandregister value.
VMXNET3 device implementation
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>Signed-off-by: Yan Vugenfirer <yan@daynix.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Fix typos and misspellings
Fix various typos and misspellings. The bulk of these were found withcodespell.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Merge remote-tracking branch 'bonzini/hw-dirs' into staging
pci_host: Drop write-only address_space field
The address_space field of PCIHostState was only ever written, never used.Drop it completely.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw: move qdev-monitor.o to toplevel directory
qdev-monitor.c is the only "core qdev" file that is not used inuser-mode emulation, and it does not define anything that is usedby hardware models. Remove it from the hw/ directory andremove hw/qdev-monitor.h from hw/qdev.h too; this requires...
error: Strip trailing '\n' from error string arguments (again)
Commit 6daf194d and be62a2eb got rid of a bunch, but they keep comingback. Tracked down with this Coccinelle semantic patch:
r expression err, eno, cls, fmt; position p; @@ (...
r
pci: use qbus_create in pci_bus_new
Remove knowledge of QOM innards. The common part of pci_bus_new andpci_bus_new_inplace is moved to a new function pci_bus_init.
Acked-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
build: remove extra-obj-y
extra-obj-y is somewhat complicated to understand. Replace it with aspecial CONFIG_ALL symbol that is defined only at toplevel.This limits the case of directories defining more than one*-obj-y target.
Add TEWS TPCI200 IndustryPack emulation
The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.
A new bus type called 'IndustryPack' has been created so anycompatible module can be attached to this board.
Reviewed-by: Andreas Färber <afaerber@suse.de>...
pci,virtio
This further optimizes MSIX handling in virtio-pci.Also included is pci cleanup by Paolo, and pci deviceassignment fix by Alex.
Make all static TypeInfos const
Since 39bffca2030950ef6efe57c2fac8327a45ae1015 (qdev: register alltypes natively through QEMU Object Model), TypeInfo as used inthe common, non-iterative pattern is no longer amended with informationand should therefore be const....
pci: use constants for devices under the 1B36 device ID, document them
virtio-9p: use symbolic constant, add to pci-ids.txt
msix: add api to access msix message
Will be used by virtio pci.
msix: expose access to masked/pending state
For use by poll handler.
pcie: Fix bug in pcie_ext_cap_set_next
Upper 16 bits of the PCIe Extended Capability Header was truncated during update,also breaking pcie_add_capability.
Signed-off-by: Knut Omang <knut.omang@oracle.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
msi: add API to get notified about pending bit poll
Update all users.