History | View | Annotate | Download (60.2 kB)
qapi: Convert query-pci
This also fixes a bug with the old version: QMP would invert device idand vendor id. This would look ok on HMP because it was printing"device:vendor" instead of "vendor:device".
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...
pci: simplify memory region registration
The two code paths (for ADDRESS_SPACE_IO and ADDRESS_SPACE_MEM) areidentical. Unify them.
Signed-off-by: Avi Kivity <avi@redhat.com>
pci: add pci_address_space_io()
Returns the I/O address space. Useful for implementingPCI-ISA bridge devices.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Avi Kivity <avi@redhat.com>
pci: implement bridge filtering
Support bridge filtering on top of the memoryAPI as suggested by Avi Kivity:
Create a memory region for the bridge's address space. This region isnot directly added to system_memory or its descendants. Devices underthe bridge see this region as its pci_address_space(). The region is...
pci: Remove unused pci_reserve_capability
eepro100 was the last user. Now pci_add_capability is powerful enough.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
PCI: delete unused mem_base and pci_to_cpu_addr
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
pci: Error on PCI capability collisions
Nothing good can happen when we overlap capabilities. This may happenwhen plugging in assigned devices or when devices models contain bugs.Detect the overlap and report it.
Based on qemu-kvm commit by Alex Williamson....
pci: add pci_address_space()
Returns the PCI address space. Useful for bridges that can obscurepart of the PCI address space.
Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
pci: remove support for pre memory API BARs
Not used anymore.
Reviewed-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
pci: remove pci_register_bar_simple()
Superceded by pci_register_bar_region().
pci: convert pci rom to memory API
pci: remove pci_register_bar()
Superceded by pci_register_bar_region(). The implementationsare folded together.
Reviewed-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Avi Kivity <avi@redhat.com>...
pci: fold BAR mapping function into its caller
There is only one function, so no need for a function pointer.
pci: rename pci_register_bar_region() to pci_register_bar()
pci: pass I/O address space to new PCI bus
This lets us register BARs in the I/O address space.
pci: allow I/O BARs to be registered with pci_register_bar_region()
pci: add API to get a BAR's mapped address
Some (hacky) devices that have a back-channel to read thisaddress back outside the normal configuration mechanisms, suchas VMware svga.
Reviewed-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Avi Kivity <avi@redhat.com>...
Merge remote-tracking branch 'mst/for_anthony' into staging
pci: pass address space to pci bus when created
This is now done sloppily, via get_system_memory(). Eventually callerswill be converted to stop using that.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
pci: add MemoryRegion based BAR management API
Allow registering a BAR using a MemoryRegion. Once all users are converted,pci_register_bar() and pci_register_bar_simple() will be removed.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Avi Kivity <avi@redhat.com>...
pci: Common overflow prevention
Introduce pci_config_read/write_common helpers to prevent passingaccesses down the callback chain that go beyond the config space limits.Adjust length assertions as they are no longer correct (cutting maygenerate valid 3 byte accesses)....
pci: don't call qdev pci init method
As pci id initialization is moved to common layer,some initialization function can be empty.So don't call init method if NULL.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Merge remote-tracking branch 'origin/master' into pci
Conflicts: hw/virtio-pci.c
pci: move ids of config space into PCIDeviceInfo
vender id/device id... in configuration space are read-only registerswhich are commonly defined for all pci devices.So move those initialization into common place.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
Conflicts: cpu-all.h
pci: Use of qemu_put_ram_ptr in pci_add_option_rom.
Prevent a deadlock caused by leaving a map cache bucket locked by thepreceding qemu_get_ram_ptr() call.
Signed-off-By: John Baboval <john.baboval@virtualcomputer.com>Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>...
Fix typo in code and comments
Replace writeable -> writable
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
pci: Add class 0x403 as 'audio controller'
Used by HD audio controllers like our intel-hda.
pci: add pci_register_bar_simple() API
This is similar to pci_register_bar(), but automatically registers a singlememory region spanning the entire BAR.
Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: add accessor function to get irq levels
Introduce accessor function to know INTx levels.It will be used later by q35.Although piix_pci tracks the intx line levels, it can be eliminatedby this helper function.
Cc: Michael S. Tsirkin <mst@redhat.com>...
pci: use devfn for pci_find_device() instead of (slot, fn) pair
(slot, fn) pair is somewhat confusing because of ARI.So use devfn for pci_find_device() instead of (slot, fn).
pci: use PCI_DEVFN in pci_get_bus_devfn()
Replace hardcoded logic by a common macro.
pci: use uint8_t for devfn_min
use uint8_t for devfn_min instead of int.
pci: Fix memory leak
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
pci: add creation functions that may fail
pci: typo in pcibus_get_dev_path()
This patch fixes typo in pcibus_get_dev_path().Without this patch, the result of pcibus_get_dev_path() isn't unique.
pci: bridge control fixup
PCI_BRIDGE_CTL_DISCARD_STATUS (bit 10 in bridge control register)is W1C so we should not make it writeable, otherwise the assert(!(wmask& w1cmask)) in pci_default_write_config() is hit
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
pci: memory leak of PCIDevice::rom_file
PCIDevice::rom_file is leaked.PCIDevice::rom_file is allocated in pci_qdev_init(), but not freed anywhere.free it in qemu_unregister_device().
pci: use qemu_malloc() in pcibus_get_dev_path()
use qemu_malloc() instead of direct use of malloc().
pci: deassert intx on reset.
deassert intx on device reset.So far pci_device_reset() is used for system reset.In that case, interrupt controller is reset at the same time so thatall irq is are deasserted.But now pci bus reset/flr is supported, and in that case irq needs to be...
pci: fix device paths
Patch a6a7005d14b3c32d4864a718fb1cb19c789f58a5 generatedbroken device paths. We snprintf with a length shorterthan the output, so the last character is discarded and replacedby the null byte. Fix it up by snprintf to a bufferwhich is larger by 1 byte and then memcpy the data (without...
pci: allow devices being tagged as not hotpluggable.
This patch adds a field to PCIDeviceInfo to tag devices as beingnot hotpluggable. Any attempt to plug-in or -out such a devicewill throw an error.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: fix migration path for devices behind bridges
The device path used for migration is currently broken forfor all devices behind a nested bridge.
Replace this by a hierarchical list of slot/function numbers, walkingthe path from root down to device. Add :00 after the domain number...
pci: introduce a helper function to convert qdev id to PCIDevice
This patch introduce a helper function to get PCIDevice from qdev id.This function will be used later.
pcie: add flr support
Support flr: trigger device reset on flr config write.
pci: don't use bus number in migration, stub out
Using bus numbers in migration is clearly wrong asthey are guest assigned. Not really sure what theright thing to do is, for now stick 0 in there so thingskeep working for non-nested setups, add a TODO....
Merge remote branch 'mst/for_anthony' into staging
Add bootindex for option roms.
Extend -option-rom command to have additional parameter ,bootindex=.
Signed-off-by: Gleb Natapov <gleb@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Add get_fw_dev_path callback for pci bus.
pci: untangle pci/msi dependency
msi depends on pci but pci should not depend on msi.The only dependency we have is a recent additionof pci_msi_ functions, IMO they add little enough toopen-code in the small number of users.
Follow-up patches add more cleanups....
pci: make command SERR bit writable
pcie aer needs SERR bit to be writable, and the PCI spec requiresthis as well. For compatibility, introduce compat global propertycommand_serr_enable and make this bit readonly for a pre 0.14 pcmachine.
pci: fix bus walk under secondary bus reset
Take into account secondary bus reset bit forbus walk: devices behind a reset bus should notrespond to configuration cycles.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: Automatically patch PCI vendor id and device id in PCI ROM
PCI devices with different vendor or device ids sometimes sharethe same rom code. Only the ids and the checksumdiffers in a boot rom for such devices.
The i825xx ethernet controller family is a typical example...
pci: use qdev reset framework for pci bus reset
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
pci: add W1C bits to pci status register
This patch adds W1C bit support in the initialization/reset of pcistatus registers.
pci: fix bridge control bit wmask
Bits 12 to 15 in bridge control register are reserver and must beread-only zero, curent mask is 0xffff which makes them writeable. Fixthis up by using symbolic bit names for writeable bits instead of ahardcoded constant....
pci: allow hotplug removal of cold-plugged devices
This patch fixes hot unplug of cold plugged devices(those present at system start), which got broken by5beb8ad503c88a76f2b8106c3b74b4ce485a60e1 .
PCI: Bus number from the bridge, not the device
pcibus_dev_print() was erroneously retrieving the device busnumber from the secondary bus number offset of the deviceinstead of the bridge above the device. This ends of landingin the 2nd byte of the 3rd BAR for devices, which thankfully...
Merge branch 'pci' into for_anthony
pci: improve w1c mask handling
- save/restore must not check w1c bits since they are in fact guest controlled- clear w1c bits on reset
Note: for express there are different kinds ofreset, some leave part of config space alone.We will likely need a sticky bit mask to implement this....
pci: use pci_word_test_and_clear_mask() in pci_device_reset()
use pci_clear_bit_word() in pci_device_reset() where appropriate.
pci: introduce helper function to handle msi-x and msi.
this patch implements helper functions to handle msi-x and msiuniformly.They will be used later.
pci: make pci_del_capability() update for w1cmask
Clear w1cmask when deleting a pci capability.
Fix spelling in comments
multifuction -> multifunctionsuccessfull -> successful.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
pci: implement RW1C register framework.
Implement RW1C register framework.With this patch, it would be easy to implementW1C register by just setting w1cmask.Later RW1C register will be used by pcie.
Introduce range.h
Extract range functions from pci.h. These will be used by later patchesby non-PCI devices. Adjust current users.
pci: sorting out type confusion in pci_register_bar().
This patch sorts out invalid use of pcibus_t.
In pci_register_bar(), pcibus_t wmask is used. It should,however, be uint64_t because it is used to setpci configuration space value(PCIDevice::wmask)...
pci: don't ignore invalid parameter for pci_register_bar().
Abort when invalid value for region_num is passed to pci_register_bar.That is caller's bug. Abort instead of silently ignoring invalid value.
pci: improve signature of pci_register_bar().
Make type uint8_t from int because PCIIORegion::type is uint8_t.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
pci: consolidate pci_add_capability_at_offset() into pci_add_capability().
By making pci_add_capability() the special case ofpci_add_capability_at_offset() of offset = 0,consolidate pci_add_capability_at_offset() into pci_add_capability().
Cc: Stefan Weil <weil@mail.berlios.de>...
pci: call hotplug callback even when not hotplug case for later use.
call hotplug callback even when not hotplug case for later use.And move hotplug check into hotplug callback.PCIE slot needs this for card presence detection.
pci: make pci_parse_devfn() aware of func.
make pci_parse_devfn() aware of func. With func = NULL it behave as before.This will be used later.
pci/bridge: split out pci bridge code into pci_bridge.c from pci.c
Move pci bridge related code into pci_bridge.c from pci.cfor further enhancement. pci.c is big enough now, so split it out.No code change but exporting some accesser functions.
In fact, few pci bridge functions stays in pci.c....
pci: move out pci internal structures, PCIBus, PCIBridge, and pci_bus_info.
move out pci internal structures, PCIBus, PCIBridge and pci_bus_info intoprivate header file, pci_internals.h.This is a preparation. Later pci bridge implementation will besplit out form pci.c into pci_bridge.c....
pci hotplug: make pci hotplug return value to caller
make pci hotplug callback return value to caller.And when returning error, allocated resources are freed.
pci: fix bridge update
bridge config write should trigger updateson the secondary bus. never on the primary bus.
pci: fix pci_device_reset
Clear interrupt disable bit on reset, according to PCI spec.Fix pci_device_reset() with 64bit BAR.
pci: set PCI multi-function bit appropriately.
Set PCI multi-function bit according to multifunction property.PCI address, devfn ,is exported to users as addr property,so users can populate pci function(PCIDevice in qemu)at arbitrary devfn.It means each function(PCIDevice) don't know whether pci device...
pci_bridge: make pci bridge aware of pci multi function bit.
make pci bridge aware of pci multi function property and let pci genericcode to set the bit.
Cc: Blue Swirl <blauwirbel@gmail.com>Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
pci: introduce multifunction property.
introduce multifunction property.Also introduce new convenient device creation function whichwill be used later.
For bisectability this patch doesn't do anything, but sets the propertyresulting in no functional changes....
pci: remove PCIDeviceInfo::header_type
replace PCIDeviceInfo::header_type with is_bridgeas suggested by Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
pci: insert assert that auto-assigned-address function is single function device.
Auto-assigned-address pci function (passing devfn = -1) is alwayssingle function.This patch adds assert() to guarantee that auto-assigned-address functionis always single function device at function = 0....
pci: Implement BusInfo.get_dev_path()
This works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquelydescribes a global address. No need to traverse up the qdev tree.PCI segment support is a placeholder for compatibility once wesupport multiple segments....
savevm: Add DeviceState param
When available, we'd like to be able to access the DeviceStatewhen registering a savevm. For buses with a get_dev_path()function, this will allow us to create more unique savevmid strings.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
qemu_ram_alloc: Add DeviceState and name parameters
These will be used to generate unique id strings for ramblocks. The namefield is required, the device pointer is optional as most callers don'thave a device. When there's no device or the device isn't a child of...
pci: Free the space allocated for the option rom on removal
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Clarify error message when a PCI slot is already in use (v2)
When mistakenly configuring two devices in the same PCI slot,QEMU gives a not entirely obvious message about a 'devfn' beingin use:
$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3...
qdev: Revert the hack to let -net nic and pci_add set qdev ID
Setting the ID in pci_nic_init() is a blatant violation of theDeviceState abstraction. Which even carries a comment advisingagainst this:
/* This structure should not be accessed directly. We declare it here...
Monitor: Drop QMP documentation from code
Previous commit added QMP documentation to the qemu-monitor.hxfile, it's is a copy of this information.
While it's good to keep it near code, maintaining two copies ofthe same information is too hard and has little benefit as we...
pci-hotplug: make them aware of pci domain.
add helper function which converts root bus to pci domain.make them aware of pci domain.
pci: clean up of pci_set_default_subsystem_id().
Use pci accessor function.don't return value because it always return 0 andthe caller doesn't check the return value.
pci hotplug: add argument to pci hot plug callback.
Add argument, DeviceState*, to pci hot plug callback.The argument will be used later to remove global variable.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>Acked-by: Gerd Hoffmann <kraxel@redhat.com>...
pci: irq_state vmstate breakage
Code for saving irq_state got vm_statemacros wrong, passing in the wrong parameter.As a result, we both saved a wrong valueand restored it to a wrong offset.
This leads to device and bus irq counts gettingout of sync, which in turn leads to interrupts getting lost or...
pci: cleanly backout of pci_qdev_init()
If the init function of a device fails, as might happen with deviceassignment, we never undo the work done by do_pci_register_device().This not only causes a bit of a memory leak, but also leaves a boguspointer in the bus devices array that can cause a segfault or...
pci: fix pci_find_bus().
When looking down child bus, it should look parent bridge'sbus number, not child bus's.Optimized tail recursion and style fix.
Cc: Blue Swirl <blauwirbel@gmail.com>Cc: "Michael S. Tsirkin" <mst@redhat.com>Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>...
pci: add API to add capability at a known offset
Unlike virtio, device emulations need to add pci capabilitiesat known offsets to match real hardware. Make this possibleby adding an appropriate API.
error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline. Strip it itfrom its arguments.
This fixes a few error messages lacking a newline:net_handle_fd_param()'s "No file descriptor named %s found", andtap_open()'s "vnet_hdr=1 requested, but no kernel support for...
pci: fix info pci with host bridge.
This patch fixes 525e05147d5a3bdc08caa422d108c1ef71b584b5.pci host bridge doesn't have header type of bridge.The check should be by header type, instead of pci class device.
Cc: Blue Swirl <blauwirbel@gmail.com>Cc: "Michael S. Tsirkin" <mst@redhat.com>...