summaryrefslogtreecommitdiffstats
path: root/hw/pci.c
Commit message (Collapse)AuthorAgeFilesLines
* 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/+5
|\
| * pci: untangle pci/msi dependencyMichael S. Tsirkin2010-12-091-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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>.
* PCI: Bus number from the bridge, not the deviceAlex Williamson2010-11-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | pcibus_dev_print() was erroneously retrieving the device bus number from the secondary bus number offset of the device instead of the bridge above the device. This ends of landing in the 2nd byte of the 3rd BAR for devices, which thankfully is usually zero. Note: pcibus_get_dev_path() copied this code, inheriting the same bug. pcibus_get_dev_path() is used for ramblock naming, so changing it can effect migration. However, I've only seen this byte be non-zero for an assigned device, which can't migrate anyway, so hopefully we won't run into any issues. This patch does not touch pcibus_get_dev_path, as bus number is guest assigned for nested buses, so using it for migration is broken anyway. Fix it properly later. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Merge branch 'pci' into for_anthonyMichael S. Tsirkin2010-10-271-238/+84
|\
| * pci: improve w1c mask handlingMichael S. Tsirkin2010-10-271-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | - 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 of reset, some leave part of config space alone. We will likely need a sticky bit mask to implement this. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: use pci_word_test_and_clear_mask() in pci_device_reset()Isaku Yamahata2010-10-191-3/+2
| | | | | | | | | | | | | | use pci_clear_bit_word() in pci_device_reset() where appropriate. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: introduce helper function to handle msi-x and msi.Isaku Yamahata2010-10-191-0/+19
| | | | | | | | | | | | | | | | | | this patch implements helper functions to handle msi-x and msi uniformly. They will be used later. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: make pci_del_capability() update for w1cmaskIsaku Yamahata2010-10-181-0/+1
| | | | | | | | | | | | | | Clear w1cmask when deleting a pci capability. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: implement RW1C register framework.Isaku Yamahata2010-09-201-0/+5
| | | | | | | | | | | | | | | | | | | | Implement RW1C register framework. With this patch, it would be easy to implement W1C(Write 1 to Clear) register by just setting w1cmask. Later RW1C register will be used by pcie. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: improve signature of pci_register_bar().Isaku Yamahata2010-09-131-1/+1
| | | | | | | | | | | | Make type uint8_t from int because PCIIORegion::type is uint8_t. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
| * pci: don't ignore invalid parameter for pci_register_bar().Isaku Yamahata2010-09-131-3/+2
| | | | | | | | | | | | | | | | 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. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: sorting out type confusion in pci_register_bar().Isaku Yamahata2010-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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 set pci configuration space value(PCIDevice::wmask) by pci_set_quad() or pci_set_long(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: make pci_parse_devfn() aware of func.Isaku Yamahata2010-09-071-8/+26
| | | | | | | | | | | | | | | | make pci_parse_devfn() aware of func. With func = NULL it behave as before. This will be used later. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: call hotplug callback even when not hotplug case for later use.Isaku Yamahata2010-09-071-1/+2
| | | | | | | | | | | | | | | | | | 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. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: consolidate pci_add_capability_at_offset() into pci_add_capability().Isaku Yamahata2010-09-071-15/+18
| | | | | | | | | | | | | | | | | | | | | | By making pci_add_capability() the special case of pci_add_capability_at_offset() of offset = 0, consolidate pci_add_capability_at_offset() into pci_add_capability(). Cc: Stefan Weil <weil@mail.berlios.de> 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/bridge: split out pci bridge code into pci_bridge.c from pci.cIsaku Yamahata2010-07-221-175/+2
| | | | | | | | | | | | | | | | | | | | | | Move pci bridge related code into pci_bridge.c from pci.c for 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. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * pci: move out pci internal structures, PCIBus, PCIBridge, and pci_bus_info.Isaku Yamahata2010-07-191-30/+2
| | | | | | | | | | | | | | | | | | | | move out pci internal structures, PCIBus, PCIBridge and pci_bus_info into private header file, pci_internals.h. This is a preparation. Later pci bridge implementation will be split out form pci.c into pci_bridge.c. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | Fix spelling in commentsStefan Weil2010-10-051-1/+1
| | | | | | | | | | | | | | multifuction -> multifunction successfull -> successful. Signed-off-by: Stefan Weil <weil@mail.berlios.de>
* | Introduce range.hBlue Swirl2010-09-181-0/+1
|/ | | | | | | Extract range functions from pci.h. These will be used by later patches by non-PCI devices. Adjust current users. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* pci: fix bridge updateMichael S. Tsirkin2010-07-111-1/+3
| | | | | | | bridge config write should trigger updates on the secondary bus. never on the primary bus. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci hotplug: make pci hotplug return value to callerIsaku Yamahata2010-07-111-4/+9
| | | | | | | | make pci hotplug callback return value to caller. And when returning error, allocated resources are freed. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: fix pci_device_resetIsaku Yamahata2010-07-111-4/+13
| | | | | | | | Clear interrupt disable bit on reset, according to PCI spec. Fix pci_device_reset() with 64bit BAR. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: set PCI multi-function bit appropriately.Isaku Yamahata2010-07-111-0/+52
| | | | | | | | | | | | | | | 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 (PCIDevice[8]) is multi function or not. So this patch allows user to set multifunction bit via property and checks whether multifunction bit is set correctly. Cc: Juan Quintela <quintela@redhat.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* pci_bridge: make pci bridge aware of pci multi function bit.Isaku Yamahata2010-07-111-2/+3
| | | | | | | | | make pci bridge aware of pci multi function property and let pci generic code 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.Isaku Yamahata2010-07-111-3/+19
| | | | | | | | | | | | | introduce multifunction property. Also introduce new convenient device creation function which will be used later. For bisectability this patch doesn't do anything, but sets the property resulting in no functional changes. Actual changes will be introduced by later patch. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* pci: remove PCIDeviceInfo::header_typeIsaku Yamahata2010-07-111-7/+8
| | | | | | | | replace PCIDeviceInfo::header_type with is_bridge as 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 ↵Isaku Yamahata2010-07-111-1/+2
| | | | | | | | | | | | device. Auto-assigned-address pci function (passing devfn = -1) is always single function. This patch adds assert() to guarantee that auto-assigned-address function is always single function device at function = 0. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* pci: Free the space allocated for the option rom on removalAlex Williamson2010-07-061-0/+11
| | | | | Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu_ram_alloc: Add DeviceState and name parametersAlex Williamson2010-07-061-1/+6
| | | | | | | | | | | These will be used to generate unique id strings for ramblocks. The name field is required, the device pointer is optional as most callers don't have a device. When there's no device or the device isn't a child of a bus implementing BusInfo.get_dev_path, the name should be unique for the platform. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* savevm: Add DeviceState paramAlex Williamson2010-07-061-1/+1
| | | | | | | | | | When available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci: Implement BusInfo.get_dev_path()Alex Williamson2010-07-061-0/+14
| | | | | | | | | | This works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Revert the hack to let -net nic and pci_add set qdev IDMarkus Armbruster2010-06-141-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Setting the ID in pci_nic_init() is a blatant violation of the DeviceState abstraction. Which even carries a comment advising against this: /* This structure should not be accessed directly. We declare it here so that it can be embedded in individual device state structures. */ What's worse, it bypasses the code ensuring unique qdev IDs: "-device virtio-net-pci,id=foo -net nic,id=foo -net nic,name=foo" happily creates three qdevs with ID "foo". That's because qdev relies on qemu_opts_create() to ensure unique IDs, but -net nic uses a different QemuOptsList, which means id is in a different namespace. And its name is not checked for uniqueness at all. -net nic and pci_add are legacy. Use -device and device_add if you want a NIC with a qdev ID. This reverts what's still left of commit eb54b6dc "qdev: add id= support for pci nics." Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Clarify error message when a PCI slot is already in use (v2)Daniel P. Berrange2010-06-141-3/+3
| | | | | | | | | | | | | | | | | | | | When mistakenly configuring two devices in the same PCI slot, QEMU gives a not entirely obvious message about a 'devfn' being in use: $ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3 qemu-kvm: -device virtio-balloon-pci,bus=pci.0,addr=0x3: PCI: devfn 24 not available for virtio-balloon-pci, in use by rtl8139 The user does not configure 'devfn' numbers, they use slot+function. Thus the error messages should be reported back to the user with that same terminology rather than the internal QEMU terminology. This patch makes it report: $ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3 qemu: -device virtio-balloon-pci,bus=pci.0,addr=0x3.7: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by rtl8139 Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Monitor: Drop QMP documentation from codeLuiz Capitulino2010-06-011-61/+0
| | | | | | | | | | | | | Previous commit added QMP documentation to the qemu-monitor.hx file, it's is a copy of this information. While it's good to keep it near code, maintaining two copies of the same information is too hard and has little benefit as we don't expect client writers to consult the code to find how to use a QMP command. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* pci-hotplug: make them aware of pci domain.Isaku Yamahata2010-05-311-1/+21
| | | | | | | | add helper function which converts root bus to pci domain. make them aware of pci domain. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci: clean up of pci_set_default_subsystem_id().Isaku Yamahata2010-05-311-7/+5
| | | | | | | | | Use pci accessor function. don't return value because it always return 0 and the caller doesn't check the return value. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
OpenPOWER on IntegriCloud