Re: [Xen-devel] [PATCH v4 22/33] xen/passthrough: arm: release the DT devices assigned to a guest earlier

2015-03-31 Thread Ian Campbell
On Thu, 2015-03-19 at 19:29 +, Julien Grall wrote:
 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.gr...@linaro.org
 Signed-off-by: Robert VanVossen robert.vanvos...@dornerworks.com
 Acked-by: Jan Beulich jbeul...@suse.com

Acked-by: Ian Campbell ian.campb...@citrix.com



___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 22/33] xen/passthrough: arm: release the DT devices assigned to a guest earlier

2015-03-19 Thread Julien Grall
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.gr...@linaro.org
Signed-off-by: Robert VanVossen robert.vanvos...@dornerworks.com
Acked-by: Jan Beulich jbeul...@suse.com

---
Changes in v4:
- Typoes in commit message
- Add Jan's ack
- iommu_release_dt_devices was only release the first device by
mistake. Thanks for Robert VanVossen for spotting it.

Changes in v3:
- Patch added. Superseed the patch xen/passthrough: call
arch_iommu_domain_destroy before calling iommu teardown in
the previous patch series.
---
 xen/arch/arm/domain.c | 4 
 xen/drivers/passthrough/arm/iommu.c   | 1 -
 xen/drivers/passthrough/device_tree.c | 7 ++-
 xen/include/xen/iommu.h   | 2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 7c5bf9f..7ebdce3 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -767,6 +767,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;
 /* Falltrough */
 
diff --git a/xen/drivers/passthrough/arm/iommu.c 
b/xen/drivers/passthrough/arm/iommu.c
index 9234657..95b1abb 100644
--- a/xen/drivers/passthrough/arm/iommu.c
+++ b/xen/drivers/passthrough/arm/iommu.c
@@ -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)
diff --git a/xen/drivers/passthrough/device_tree.c 
b/xen/drivers/passthrough/device_tree.c
index 4d82a09..05ab274 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -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;
 }
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index e9d2d5c..d9c9ede 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -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 */
 
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel