From df6a050c82e56fc7a0afeb62cf4bc2e0c4c6d888 Mon Sep 17 00:00:00 2001 From: Yi Min Zhao Date: Wed, 4 May 2016 15:07:11 +0800 Subject: s390x/pci: introduce S390PCIBusDevice.iommu_enabled 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 Reviewed-by: Pierre Morel Signed-off-by: Cornelia Huck --- hw/s390x/s390-pci-bus.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'hw/s390x/s390-pci-bus.c') diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b934fc80c2..5d54c73774 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -340,7 +340,8 @@ static IOMMUTLBEntry s390_translate_iommu(MemoryRegion *iommu, hwaddr addr, .perm = IOMMU_NONE, }; - if (!pbdev->configured || !pbdev->pdev || !(pbdev->fh & FH_ENABLED)) { + if (!pbdev->configured || !pbdev->pdev || + !(pbdev->fh & FH_ENABLED) || !pbdev->iommu_enabled) { return ret; } @@ -480,21 +481,19 @@ static const MemoryRegionOps s390_msi_ctrl_ops = { void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) { - pbdev->configured = false; uint64_t size = pbdev->pal - pbdev->pba + 1; memory_region_init_iommu(&pbdev->iommu_mr, OBJECT(&pbdev->mr), &s390_iommu_ops, "iommu-s390", size); memory_region_add_subregion(&pbdev->mr, pbdev->pba, &pbdev->iommu_mr); - pbdev->configured = true; + pbdev->iommu_enabled = true; } void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) { - pbdev->configured = false; memory_region_del_subregion(&pbdev->mr, &pbdev->iommu_mr); object_unparent(OBJECT(&pbdev->iommu_mr)); - pbdev->configured = true; + pbdev->iommu_enabled = false; } static void s390_pcihost_init_as(S390pciState *s) -- cgit v1.2.3