[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/25] s390x/pci: introduce S390PCIIOMMU
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PULL 16/25] s390x/pci: introduce S390PCIIOMMU |
Date: |
Mon, 11 Jul 2016 10:09:03 +0200 |
From: Yi Min Zhao <address@hidden>
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 <address@hidden>
Acked-by: Pierre Morel <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/s390x/s390-pci-bus.c | 19 +++++++++++--------
hw/s390x/s390-pci-bus.h | 9 +++++++--
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 0c67c1e..af3263f 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -406,7 +406,7 @@ static AddressSpace *s390_pci_dma_iommu(PCIBus *bus, void
*opaque, int devfn)
{
S390pciState *s = opaque;
- return &s->pbdev[PCI_SLOT(devfn)].as;
+ return &s->iommu[PCI_SLOT(devfn)]->as;
}
static uint8_t set_ind_atomic(uint64_t ind_loc, uint8_t to_be_set)
@@ -478,15 +478,15 @@ static const MemoryRegionOps s390_msi_ctrl_ops = {
void s390_pci_iommu_enable(S390PCIBusDevice *pbdev)
{
- memory_region_init_iommu(&pbdev->iommu_mr, OBJECT(&pbdev->mr),
+ memory_region_init_iommu(&pbdev->iommu_mr, OBJECT(&pbdev->iommu->mr),
&s390_iommu_ops, "iommu-s390", pbdev->pal + 1);
- memory_region_add_subregion(&pbdev->mr, 0, &pbdev->iommu_mr);
+ memory_region_add_subregion(&pbdev->iommu->mr, 0, &pbdev->iommu_mr);
pbdev->iommu_enabled = true;
}
void s390_pci_iommu_disable(S390PCIBusDevice *pbdev)
{
- memory_region_del_subregion(&pbdev->mr, &pbdev->iommu_mr);
+ memory_region_del_subregion(&pbdev->iommu->mr, &pbdev->iommu_mr);
object_unparent(OBJECT(&pbdev->iommu_mr));
pbdev->iommu_enabled = false;
}
@@ -494,13 +494,15 @@ void s390_pci_iommu_disable(S390PCIBusDevice *pbdev)
static void s390_pcihost_init_as(S390pciState *s)
{
int i;
- S390PCIBusDevice *pbdev;
+ S390PCIIOMMU *iommu;
for (i = 0; i < PCI_SLOT_MAX; i++) {
- pbdev = &s->pbdev[i];
- memory_region_init(&pbdev->mr, OBJECT(s),
+ iommu = g_malloc0(sizeof(S390PCIIOMMU));
+ memory_region_init(&iommu->mr, OBJECT(s),
"iommu-root-s390", UINT64_MAX);
- address_space_init(&pbdev->as, &pbdev->mr, "iommu-pci");
+ address_space_init(&iommu->as, &iommu->mr, "iommu-pci");
+
+ s->iommu[i] = iommu;
}
memory_region_init_io(&s->msix_notify_mr, OBJECT(s),
@@ -576,6 +578,7 @@ static void s390_pcihost_hot_plug(HotplugHandler
*hotplug_dev,
pbdev->pdev = pci_dev;
pbdev->state = ZPCI_FS_DISABLED;
pbdev->fh = s390_pci_get_pfh(pci_dev);
+ pbdev->iommu = s->iommu[PCI_SLOT(pci_dev->devfn)];
s390_pcihost_setup_msix(pbdev);
diff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h
index c4d4079..ea1efcc 100644
--- a/hw/s390x/s390-pci-bus.h
+++ b/hw/s390x/s390-pci-bus.h
@@ -248,6 +248,11 @@ typedef struct S390MsixInfo {
uint32_t pba_offset;
} S390MsixInfo;
+typedef struct S390PCIIOMMU {
+ AddressSpace as;
+ MemoryRegion mr;
+} S390PCIIOMMU;
+
typedef struct S390PCIBusDevice {
PCIDevice *pdev;
ZpciState state;
@@ -263,8 +268,7 @@ typedef struct S390PCIBusDevice {
uint8_t sum;
S390MsixInfo msix;
AdapterRoutes routes;
- AddressSpace as;
- MemoryRegion mr;
+ S390PCIIOMMU *iommu;
MemoryRegion iommu_mr;
IndAddr *summary_ind;
IndAddr *indicator;
@@ -278,6 +282,7 @@ typedef struct S390pciState {
PCIHostState parent_obj;
S390PCIBus *bus;
S390PCIBusDevice pbdev[PCI_SLOT_MAX];
+ S390PCIIOMMU *iommu[PCI_SLOT_MAX];
AddressSpace msix_notify_as;
MemoryRegion msix_notify_mr;
QTAILQ_HEAD(, SeiContainer) pending_sei;
--
2.9.0
- [Qemu-devel] [PULL 12/25] s390x/pci: unify FH_ macros, (continued)
- [Qemu-devel] [PULL 12/25] s390x/pci: unify FH_ macros, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 19/25] s390x/pci: enable zpci hot-plug/hot-unplug, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 17/25] s390x/pci: introduce S390PCIBusDevice qdev, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 03/25] s390x/ipl: Support IPL from selected SCSI device, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 02/25] pc-bios/s390-ccw.img: rebuild image, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 15/25] s390x/pci: introduce S390PCIBus, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 23/25] s390x/pci: fix stpcifc_service_call, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 20/25] s390x/pci: add checkings in CLP_SET_PCI_FN, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 18/25] s390x/pci: enable uid-checking, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 11/25] s390x/pci: write fid in CLP_QUERY_PCI_FN, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 16/25] s390x/pci: introduce S390PCIIOMMU,
Cornelia Huck <=
- [Qemu-devel] [PULL 21/25] s390x/pci: refactor s390_pci_find_dev_by_idx, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 10/25] s390x/pci: acceleration for getting S390pciState, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 24/25] s390x/pci: replace fid with idx in msg data of msix, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 07/25] s390x/css: Factor out virtual css bridge and bus, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 22/25] s390x/pci: refactor list_pci, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 25/25] s390x/pci: make hot-unplug handler smoother, Cornelia Huck, 2016/07/11
- [Qemu-devel] [PULL 13/25] s390x/pci: refactor s390_pci_find_dev_by_fh, Cornelia Huck, 2016/07/11
- Re: [Qemu-devel] [PULL 00/25] s390x patches for 2.7, Peter Maydell, 2016/07/12