summaryrefslogtreecommitdiffstats
path: root/hw/pci.c
Commit message (Collapse)AuthorAgeFilesLines
* Use glib memory allocation and free functionsAnthony Liguori2011-08-211-23/+23
| | | | | | 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 BARsAvi Kivity2011-08-081-31/+2Star
| | | | | | | | | 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: rename pci_register_bar_region() to pci_register_bar()Avi Kivity2011-08-081-3/+3
| | | | | | | 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: fold BAR mapping function into its callerAvi Kivity2011-08-081-16/+9Star
| | | | | | | | | There is only one function, so no need for a function pointer. 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()Avi Kivity2011-08-081-25/+17Star
| | | | | | | | | | Superceded by pci_register_bar_region(). The implementations are 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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci: convert pci rom to memory APIAvi Kivity2011-08-081-13/+7Star
| | | | | | | 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()Avi Kivity2011-08-081-17/+0Star
| | | | | | | | | Superceded by pci_register_bar_region(). 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: allow I/O BARs to be registered with pci_register_bar_region()Avi Kivity2011-08-081-20/+23
| | | | | | | 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: pass I/O address space to new PCI busAvi Kivity2011-08-081-6/+12
| | | | | | | | | This lets us register BARs in the I/O address space. 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: add API to get a BAR's mapped addressAvi Kivity2011-08-081-0/+5
| | | | | | | | | | Some (hacky) devices that have a back-channel to read this address back outside the normal configuration mechanisms, such as VMware svga. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Merge remote-tracking branch 'mst/for_anthony' into stagingAnthony Liguori2011-08-051-4/+2Star
|\
| * pci: Common overflow preventionJan Kiszka2011-07-271-4/+2Star
| | | | | | | | | | | | | | | | | | | | Introduce pci_config_read/write_common helpers to prevent passing accesses down the callback chain that go beyond the config space limits. Adjust length assertions as they are no longer correct (cutting may generate valid 3 byte accesses). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | pci: add MemoryRegion based BAR management APIAvi Kivity2011-07-291-8/+39
| | | | | | | | | | | | | | | | | | 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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* | pci: pass address space to pci bus when createdAvi Kivity2011-07-291-5/+11
|/ | | | | | | | | This is now done sloppily, via get_system_memory(). Eventually callers will 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: don't call qdev pci init methodIsaku Yamahata2011-06-151-4/+6
| | | | | | | | | 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 pciMichael S. Tsirkin2011-06-151-3/+5
|\ | | | | | | | | Conflicts: hw/virtio-pci.c
| * Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori2011-05-121-3/+3
| |\ | | | | | | | | | | | | Conflicts: cpu-all.h
| | * Fix typo in code and commentsStefan Weil2011-05-061-3/+3
| | | | | | | | | | | | | | | | | | | | | Replace writeable -> writable Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * | pci: Use of qemu_put_ram_ptr in pci_add_option_rom.John Baboval2011-05-081-0/+2
| |/ | | | | | | | | | | | | | | | | Prevent a deadlock caused by leaving a map cache bucket locked by the preceding qemu_get_ram_ptr() call. Signed-off-By: John Baboval <john.baboval@virtualcomputer.com> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* / pci: move ids of config space into PCIDeviceInfoIsaku Yamahata2011-06-121-14/+32
|/ | | | | | | | | vender id/device id... in configuration space are read-only registers which are commonly defined for all pci devices. So move those initialization into common place. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: Add class 0x403 as 'audio controller'Jan Kiszka2011-05-051-0/+1
| | | | | | | Used by HD audio controllers like our intel-hda. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: add pci_register_bar_simple() APIAvi Kivity2011-04-071-0/+17
| | | | | | | | This is similar to pci_register_bar(), but automatically registers a single memory 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 levelsIsaku Yamahata2011-04-011-0/+7
| | | | | | | | | | | 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 eliminated by this helper function. Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: use uint8_t for devfn_minIsaku Yamahata2011-03-281-3/+3
| | | | | | | use uint8_t for devfn_min instead of int. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: use PCI_DEVFN in pci_get_bus_devfn()Isaku Yamahata2011-03-281-1/+1
| | | | | | | Replace hardcoded logic by a common macro. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: use devfn for pci_find_device() instead of (slot, fn) pairIsaku Yamahata2011-03-281-2/+2
| | | | | | | | (slot, fn) pair is somewhat confusing because of ARI. So use devfn for pci_find_device() instead of (slot, fn). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: Fix memory leakStefan Weil2011-02-201-0/+1
| | | | | Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* pci: add creation functions that may failBlue Swirl2011-02-121-0/+20
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* pci: typo in pcibus_get_dev_path()Isaku Yamahata2011-01-271-1/+1
| | | | | | | | This patch fixes typo in pcibus_get_dev_path(). Without this patch, the result of pcibus_get_dev_path() isn't unique. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: bridge control fixupMichael S. Tsirkin2011-01-271-1/+0Star
| | | | | | | | | | 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> Reported-by: Isaku Yamahata <yamahata@valinux.co.jp> Tested-by: Isaku Yamahata <yamahata@valinux.co.jp>
* pci: memory leak of PCIDevice::rom_fileIsaku Yamahata2011-01-241-0/+1
| | | | | | | | | PCIDevice::rom_file is leaked. PCIDevice::rom_file is allocated in pci_qdev_init(), but not freed anywhere. free it in qemu_unregister_device(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: use qemu_malloc() in pcibus_get_dev_path()Isaku Yamahata2011-01-201-1/+1
| | | | | | | use qemu_malloc() instead of direct use of malloc(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: deassert intx on reset.Isaku Yamahata2011-01-201-0/+9
| | | | | | | | | | | | 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 that all irq is are deasserted. But now pci bus reset/flr is supported, and in that case irq needs to be disabled explicitly. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: fix device pathsMichael S. Tsirkin2011-01-191-4/+12
| | | | | | | | | | | | Patch a6a7005d14b3c32d4864a718fb1cb19c789f58a5 generated broken device paths. We snprintf with a length shorter than the output, so the last character is discarded and replaced by the null byte. Fix it up by snprintf to a buffer which is larger by 1 byte and then memcpy the data (without the null byte) to where we need it. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: allow devices being tagged as not hotpluggable.Gerd Hoffmann2011-01-101-0/+10
| | | | | | | | | This patch adds a field to PCIDeviceInfo to tag devices as being not hotpluggable. Any attempt to plug-in or -out such a device will 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 bridgesMichael S. Tsirkin2010-12-271-11/+37
| | | | | | | | | | | | | | | | | The device path used for migration is currently broken for for all devices behind a nested bridge. Replace this by a hierarchical list of slot/function numbers, walking the path from root down to device. Add :00 after the domain number so that if there are no nested bridges, this is compatible with what we have now. Note: as pointed out by Gleb, using openfirmware paths might be cleaner, doing this would break compatibility though, and the IDs used are not guest or user visible at all, so breaking the compatibility is probably not worth it. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: introduce a helper function to convert qdev id to PCIDeviceIsaku Yamahata2010-12-241-0/+35
| | | | | | | | This patch introduce a helper function to get PCIDevice from qdev id. This function will be used later. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pcie: add flr supportIsaku Yamahata2010-12-221-1/+5
| | | | | | | Support flr: trigger device reset on flr config write. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: don't use bus number in migration, stub outMichael S. Tsirkin2010-12-191-1/+4
| | | | | | | | | | | | | Using bus numbers in migration is clearly wrong as they are guest assigned. Not really sure what the right thing to do is, for now stick 0 in there so things keep working for non-nested setups, add a TODO. We also probably have to mark nested bridges as non-migrateable until this is fixed? Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Alex Williamson <alex.williamson@redhat.com>
* Merge remote branch 'mst/for_anthony' into stagingAnthony Liguori2010-12-171-19/+5Star
|\
| * pci: untangle pci/msi dependencyMichael S. Tsirkin2010-12-091-19/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | msi depends on pci but pci should not depend on msi. The only dependency we have is a recent addition of pci_msi_ functions, IMO they add little enough to open-code in the small number of users. Follow-up patches add more cleanups. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
| * pci: make command SERR bit writableIsaku Yamahata2010-12-091-0/+5
| | | | | | | | | | | | | | | | | | | | pcie aer needs SERR bit to be writable, and the PCI spec requires this as well. For compatibility, introduce compat global property command_serr_enable and make this bit readonly for a pre 0.14 pc machine. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | Add bootindex for option roms.Gleb Natapov2010-12-111-1/+1
| | | | | | | | | | | | | | 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.Gleb Natapov2010-12-111-23/+85
|/ | | | | Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* pci: fix bus walk under secondary bus resetMichael S. Tsirkin2010-11-241-13/+24
| | | | | | | | Take into account secondary bus reset bit for bus walk: devices behind a reset bus should not respond to configuration cycles. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: use qdev reset framework for pci bus resetIsaku Yamahata2010-11-221-3/+21
| | | | | | 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: Automatically patch PCI vendor id and device id in PCI ROMStefan Weil2010-11-221-4/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PCI devices with different vendor or device ids sometimes share the same rom code. Only the ids and the checksum differs in a boot rom for such devices. The i825xx ethernet controller family is a typical example which is implemented in hw/eepro100.c. It uses at least 3 different device ids, so normally 3 boot roms would be needed. By automatically patching vendor id and device id (and the checksum) in qemu, all emulated family members can share the same boot rom. VGA bios roms are another example with different vendor and device ids. Only qemu's built-in default rom files will be patched. v2: * Patch also the vendor id (and remove the sanity check for vendor id). v3: * Don't patch a rom file when its name was set by the user. Thus we avoid modifications of unknown rom data. Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: fix bridge control bit wmaskMichael S. Tsirkin2010-11-221-2/+24
| | | | | | | | | | | Bits 12 to 15 in bridge control register are reserver and must be read-only zero, curent mask is 0xffff which makes them writeable. Fix this up by using symbolic bit names for writeable bits instead of a hardcoded constant. Fix a comment w1mask -> w1cmask as well. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: add W1C bits to pci status registerIsaku Yamahata2010-11-221-0/+16
| | | | | | | | This patch adds W1C bit support in the initialization/reset of pci status registers. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: allow hotplug removal of cold-plugged devicesMichael S. Tsirkin2010-11-161-3/+7
| | | | | | | | | | | | This patch fixes hot unplug of cold plugged devices (those present at system start), which got broken by 5beb8ad503c88a76f2b8106c3b74b4ce485a60e1 . Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Cam Macdonell <cam@cs.ualberta.ca> Tested-by: Cam Macdonell <cam@cs.ualberta.ca> Reported-by: Cam Macdonell <cam@cs.ualberta.ca>.