xen/passthrough: arm: release the DT devices assigned to a guest earlier
authorJulien Grall <julien.grall@linaro.org>
Tue, 28 Apr 2015 14:32:32 +0000 (15:32 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 8 May 2015 14:41:59 +0000 (15:41 +0100)
The toolstack may not have deassigned every device used by a guest.
Therefore we have to go through the device list and remove them before
asking the IOMMU drivers to release memory for this domain.

This can be done by moving the call to the release function when we
relinquish the resources. The IOMMU part will be destroyed later when
the domain is freed.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Robert VanVossen <robert.vanvossen@dornerworks.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/domain.c
xen/drivers/passthrough/arm/iommu.c
xen/drivers/passthrough/device_tree.c
xen/include/xen/iommu.h

index 180bccc676dadded267e64801afcedab3c72124c..24b89380f8852ea6db4e4e8ad0f67edf76d8b39a 100644 (file)
@@ -795,6 +795,10 @@ int domain_relinquish_resources(struct domain *d)
     switch ( d->arch.relmem )
     {
     case RELMEM_not_started:
+        ret = iommu_release_dt_devices(d);
+        if ( ret )
+            return ret;
+
         d->arch.relmem = RELMEM_xen;
         /* Fallthrough */
 
index 92346579a93c3cc501a44a8c28a5805eb4eb9633..95b1abb972adfcab05f9b84be4c756b0a33b7561 100644 (file)
@@ -66,7 +66,6 @@ int arch_iommu_domain_init(struct domain *d)
 
 void arch_iommu_domain_destroy(struct domain *d)
 {
-    iommu_dt_domain_destroy(d);
 }
 
 int arch_iommu_populate_page_table(struct domain *d)
index 4d82a097594e4c669ca3e24461fd6961c608a7b6..05ab2743059323dce16e4fa7761fdfaa8316b0c1 100644 (file)
@@ -105,7 +105,7 @@ int iommu_dt_domain_init(struct domain *d)
     return 0;
 }
 
-void iommu_dt_domain_destroy(struct domain *d)
+int iommu_release_dt_devices(struct domain *d)
 {
     struct hvm_iommu *hd = domain_hvm_iommu(d);
     struct dt_device_node *dev, *_dev;
@@ -115,7 +115,12 @@ void iommu_dt_domain_destroy(struct domain *d)
     {
         rc = iommu_deassign_dt_device(d, dev);
         if ( rc )
+        {
             dprintk(XENLOG_ERR, "Failed to deassign %s in domain %u\n",
                     dt_node_full_name(dev), d->domain_id);
+            return rc;
+        }
     }
+
+    return 0;
 }
index e9d2d5c28023507881ecc8eb3b3d008fb0aeb692..d9c9ede27992bff1507bb6fe6f7a0d9d4609cc0f 100644 (file)
@@ -117,7 +117,7 @@ void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg);
 int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev);
 int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev);
 int iommu_dt_domain_init(struct domain *d);
-void iommu_dt_domain_destroy(struct domain *d);
+int iommu_release_dt_devices(struct domain *d);
 
 #endif /* HAS_DEVICE_TREE */