aboutsummaryrefslogtreecommitdiff
path: root/hw/s390x/s390-pci-bus.h
AgeCommit message (Collapse)AuthorFilesLines
2017-02-01s390-pci: fix compilation on older GCC versionsPaolo Bonzini1-2/+2
S390PCIBusDevice is typedef'ed earlier in the file, before the hunks that this patch modifies. The double typedef causes old versions of GCC to complain. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1485523252-88288-1-git-send-email-pbonzini@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
2017-01-24hw: Fix typos found by codespellStefan Weil1-2/+2
Signed-off-by: Stefan Weil <sw@weilnetz.de> Acked-by: Alistair Francis <alistair.francis@xilinx.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2017-01-20s390x/pci: handle PCIBridge bus numberPierre Morel1-0/+1
The PCI bus number is usually set by the host during the enumeration. In the s390 architecture we neither get a Device Tree nor have an enumeration understanding bridge devices. Let's fake the enumeration on reset and set the PCI_PRIMARY_BUS, PCI_SECONDARY_BUS and PCI_SUBORDINATE_BUS config entries for the bridges. Let's add the configuration of these three config entries on bridge hot plug. The bus number is calculated based on a new entry, bus_num of the S390pciState device. This commit is inspired by what spapr pci does. Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2017-01-20s390x/pci: use hashtable to look up zpci via fhYi Min Zhao1-0/+1
After PCI multibus is supported, more than 32 PCI devices could be plugged. The current implementation of s390_pci_find_dev_by_fh() appears low performance if there's a huge number of PCI devices plugged. Therefore we introduce a hashtable using idx as key to store zpci device's pointer on account of translating fh to idx very easily. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2017-01-20s390x/pci: optimize calling s390_get_phb()Yi Min Zhao1-4/+6
A function may recursively call device search functions or may call serveral different device search function. Passing the S390pciState to search functions as an argument instead of looking up it inside the search functions lowers the number of calling s390_get_phb(). Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2017-01-20s390x/pci: change the device array to a listPierre Morel1-2/+5
In order to support a greater number of devices we use a QTAILQ list of devices instead of a limited array. This leads us to change: - every lookup function s390_pci_find_xxx() for QTAILQ - the FH_MASK_INDEX to index up to 65536 devices Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2017-01-20s390x/pci: dynamically allocate iommuYi Min Zhao1-1/+6
When initializing a PCI device, an address space is required during PCI core initialization and before the call to the embedding object hotplug callback. To provide this AS, we allocate a S390PCIIOMMU object containing this AS. Initialization of S390PCIIOMMU object is done before the PCI device is completely created. So that we cannot associate the IOMMU with the device at the moment. To track the IOMMU object, we use g_hash functions with the PCI device's bus address as a key to provide an array of pointers indexed by the PCI device's devfn to the allocated IOMMU. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2017-01-20s390x/pci: make S390PCIIOMMU inherit ObjectYi Min Zhao1-7/+13
Currently S390PCIIOMMU is a normal struct. Let's make it inherit Object in order to take advantage of QOM. In addition, we move some stuff related to IOMMU from S390PCIBusDevice to S390PCIIOMMU. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-09-28s390x/pci: assign msix io region for each pci deviceYi Min Zhao1-2/+2
For efficiency we now assign one msix io region for each pci device and provide it with the pointer to the zPCI device as opaque parameter. In addition, we remove msix address space and add msix io region as a subregion to the root memory region of pci device. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
2016-07-12Use #include "..." for our own headers, <...> for othersMarkus Armbruster1-2/+2
Tracked down with an ugly, brittle and probably buggy Perl script. Also move includes converted to <...> up so they get included before ours where that's obviously okay. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Eric Blake <eblake@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-07-11s390x/pci: make hot-unplug handler smootherYi Min Zhao1-0/+3
The current implementation of hot-unplug handler is abrupt. Any pci operation will be just rejected if pci device is unconfigured. Thus a pci device can not be reset or destroyed in a right, smooth and safe way. Improve this as follows: - Notify the guest via a HP_EVENT_DECONFIGURE_REQUEST(0x303) event in the unplug handler, giving it a chance to deconfigure the device via sclp and allowing us to continue hot-unplug afterwards. - Set up a timer that will generate the HP_EVENT_CONFIGURE_TO_STBRES (0x304) event as before if the guest did not react after an adequate time. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: refactor list_pciYi Min Zhao1-0/+1
Because of the refactor of s390_pci_find_dev_by_idx(), list_pci() should be updated. We introduce a new function to get the next available zpci device. It simplifies the code of looking up zpci devices. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: enable uid-checkingYi Min Zhao1-0/+1
The uid-checking facility guarantees uniqueness of the uid within the vm and exposes the real uid to the guest when listing pci devices. Let's always enable it and present it to the guest in the response to the list pci clp command. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: introduce S390PCIBusDevice qdevYi Min Zhao1-1/+11
To support definitions of s390 pci attributes in Qemu cmdline, we have to make current S390PCIBusDevice struct inherit DeviceState and add three properties for it. Currently we only support definitions of uid and fid. 'uid' is optionally defined by users, identifies a zpci device and must be defined with a 16-bit and non-zero unique value. 'fid' ranges from 0x0 to 0xFFFFFFFF. For fid property, we introduce a new PropertyInfo by the name of s390_pci_fid_propinfo with our special setter and getter. As 'fid' is optional, introduce 'fid_defined' to track whether the user specified a fid. 'target' field is to direct qemu to find the corresponding generic PCI device. It is equal to the 'id' value of one of generic pci devices. If the user doesn't specify 'id' parameter for a generic pci device, its 'id' value will be generated automatically and use this value as 'target' to create an associated zpci device. If the user did not specify 'uid' or 'fid', values are generated automatically. 'target' is required. In addition, if a pci device has no associated zpci device, the code will generate a zpci device automatically for it. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: introduce S390PCIIOMMUYi Min Zhao1-2/+7
Currently each zpci device holds its own DMA address space and memory region. At the same time, all instances of zpci device are stored in S390pciState. So duirng the initialization of S390pciState, all zpci devices are created and then all DMA address spaces are created. Thus, when initializing pci devices, their corresponding DMA address spaces could be found. But zpci qdev will be introduced later. Zpci device may be initialized and plugged afterwards generic pci device. So we should initialize all DMA address spaces and memory regions before initializing zpci devices. We introduce a new struct named S390PCIIOMMU. And a new field of S390pciState, which is an array to store all instances of S390PCIIOMMU, is added so that qemu pci code could find the corresponding DMA address space when initializing a generic pci device. And this should be done before the connection of a zpci device and a generic pci device is built. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: introduce S390PCIBusYi Min Zhao1-0/+8
To enable S390PCIBusDevice as qdev, there should be a new bus to plug and manage all instances of S390PCIBusDevice. Due to this, S390PCIBus is introduced. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: enforce zPCI state checkingYi Min Zhao1-3/+31
Current code uses some fields combinatorially to indicate the state of a s390 pci device. This patch introduces device states in order to make the code more readable and more logical. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-11s390x/pci: unify FH_ macrosYi Min Zhao1-3/+6
Present code uses some macros to structure PCI Function Handle. But their names don't have a uniform format. Let's use FH_MASK_ as the unified prefix. While we're at it, differentiate the SHM bits: use different bits for vfio and emulated devices. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-05-17s390x/pci: remove whitespaceYi Min Zhao1-5/+5
Fix indentation of PciCfgSccb struct. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-05-17s390x/pci: introduce S390PCIBusDevice.iommu_enabledYi Min Zhao1-0/+1
We introduce iommu_enabled field for S390PCIBusDevice struct to track whether the iommu has been enabled for the device. This allows us to stop temporarily changing ->configured while en/disabling the iommu and to do conditional cleanup later. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-05-17s390x/pci: separate s390_pcihost_iommu_configure functionYi Min Zhao1-1/+2
Split s390_pcihost_iommu_configure() into separate functions for configuring and deconfiguring in order to make the code more readable. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-05-17s390x/pci: separate s390_sclp_configure functionYi Min Zhao1-1/+2
Split s390_sclp_configure() into separate functions for sclp configuring and deconfiguring in order to make the code more readable. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-03-01s390x/pci: fix reg/dereg irq functionsYi Min Zhao1-0/+2
Indicator refcounting interfaces are introduced. This patch fixes introducing unneeded indicator mappings and failure to release AISB mappings on deregistration. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-01-13s390x/pci: reject some operations to disabled PCI functionYi Min Zhao1-0/+1
According to the s390 architecture, any mpcifc, pcilg, pcistg, pcistb and rpcit instructions issued to disabled PCI functions are rejected, and the instruction completes by setting condition code 3. In addition, any DMA and MSIX interruption operations are ignored. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2015-12-01s390x/pci: fix up IOMMU sizeYi Min Zhao1-0/+2
Present code uses @size==UINT64_MAX to initialize IOMMU. It infers that it can map any 64-bit IOVA whatsoever. But in fact, the largest DMA range for each PCI Device on s390x is from ZPCI_SDMA_ADDR to ZPCI_EDMA_ADDR. The largest value is returned from hardware, which is to indicate the largest range hardware can support. But the real IOMMU size for specific PCI Device is obtained once qemu intercepts mpcifc instruction that guest is requesting a DMA range for that PCI Device. Therefore, before intercepting mpcifc instruction, qemu cannot be aware of the size of IOMMU region that guest will use. Moreover, iommu replay during device initialization for the whole region in 4k steps takes a very long time. In conclusion, this patch intializes IOMMU region for each PCI Device when intercept mpcifc instruction which is to register DMA range for the PCI Device. And then, destroy IOMMU region when guest wants to deregister IOAT. Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2015-01-12s390: Add PCI bus supportFrank Blaschka1-0/+251
This patch implements a pci bus for s390x together with infrastructure to generate and handle hotplug events, to configure/unconfigure via sclp instruction, to do iommu translations and provide s390 support for MSI/MSI-X notification processing. Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>