This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot.
This also allows to save/restore this field during migration. Reviewed-by: Farhan Ali <[email protected]> Reviewed-by: Matthew Rosato <[email protected]> Signed-off-by: Konstantin Shkolnyy <[email protected]> --- hw/s390x/s390-pci-bus.c | 14 +++++++------- hw/s390x/s390-pci-inst.c | 8 ++++---- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 10e0c3324a..ee05447084 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -206,7 +206,7 @@ void s390_pci_sclp_deconfigure(SCCB *sccb) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { pci_dereg_ioat(pbdev); } pbdev->state = ZPCI_FS_STANDBY; @@ -555,7 +555,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr, switch (pbdev->state) { case ZPCI_FS_ENABLED: case ZPCI_FS_BLOCKED: - if (!iommu->enabled) { + if (!pbdev->iommu_enabled) { return ret; } break; @@ -789,7 +789,7 @@ void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) memory_region_init_iommu(&pbdev->iommu_mr, sizeof(pbdev->iommu_mr), TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu->mr), name, iommu->pal + 1); - iommu->enabled = true; + pbdev->iommu_enabled = true; memory_region_add_subregion(&iommu->mr, 0, MEMORY_REGION(&pbdev->iommu_mr)); g_free(name); } @@ -812,7 +812,7 @@ void s390_pci_iommu_direct_map_enable(S390PCIBusDevice *pbdev) memory_region_init_alias(pbdev->dm_mr, OBJECT(&iommu->mr), name, get_system_memory(), 0, s390_get_memory_limit(s390ms)); - iommu->enabled = true; + pbdev->iommu_enabled = true; memory_region_add_subregion(&iommu->mr, pbdev->zpci_fn.sdma, pbdev->dm_mr); } @@ -820,7 +820,7 @@ void s390_pci_iommu_direct_map_enable(S390PCIBusDevice *pbdev) void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) { S390PCIIOMMU *iommu = pbdev->iommu; - iommu->enabled = false; + pbdev->iommu_enabled = false; g_hash_table_remove_all(pbdev->iotlb); if (pbdev->dm_mr) { memory_region_del_subregion(&iommu->mr, pbdev->dm_mr); @@ -1429,7 +1429,7 @@ static void s390_pcihost_reset(DeviceState *dev) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { pci_dereg_ioat(pbdev); } pbdev->state = ZPCI_FS_STANDBY; @@ -1570,7 +1570,7 @@ static void s390_pci_device_reset(DeviceState *dev) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { pci_dereg_ioat(pbdev); } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index f648afb401..7081be4619 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1279,7 +1279,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, if (dmaas != 0) { cc = ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL); - } else if (pbdev->iommu->enabled) { + } else if (pbdev->iommu_enabled) { cc = ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else if (reg_ioat(env, pbdev, fib, ra)) { @@ -1291,7 +1291,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, if (dmaas != 0) { cc = ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL); - } else if (!pbdev->iommu->enabled) { + } else if (!pbdev->iommu_enabled) { cc = ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else { @@ -1302,7 +1302,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, if (dmaas != 0) { cc = ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL); - } else if (!pbdev->iommu->enabled) { + } else if (!pbdev->iommu_enabled) { cc = ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else { @@ -1432,7 +1432,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, /* fallthrough */ case ZPCI_FS_ENABLED: fib.fc |= 0x80; - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { fib.fc |= 0x10; } if (!(fh & FH_MASK_ENABLE)) { diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h index fcaaf19512..24f6e60786 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -275,7 +275,6 @@ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; MemoryRegion mr; - bool enabled; uint64_t g_iota; uint64_t pba; uint64_t pal; @@ -350,6 +349,7 @@ struct S390PCIBusDevice { S390MsixInfo msix; AdapterRoutes routes; S390PCIIOMMU *iommu; + bool iommu_enabled; IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; GHashTable *iotlb; -- 2.34.1
