[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xen/arm: smmu: Set/clear IOMMU domain for device



From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>

When a device is assigned/de-assigned it is required to properly set
IOMMU domain used to protect the device. This assignment was missing,
thus it was not possible to de-assign the device:

(XEN) Deassigning device 0000:03:00.0 from dom2
(XEN) smmu: 0000:03:00.0:  not attached to domain 2
(XEN) d2: deassign (0000:03:00.0) failed (-3)

Fix this by assigning IOMMU domain on arm_smmu_assign_dev and reset it
to NULL on arm_smmu_deassign_dev.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
---
 xen/drivers/passthrough/arm/smmu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/drivers/passthrough/arm/smmu.c 
b/xen/drivers/passthrough/arm/smmu.c
index c234ad9c7f1e..373d9d4d123a 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -2768,6 +2768,7 @@ static int arm_smmu_assign_dev(struct domain *d, u8 devfn,
                        arm_smmu_destroy_iommu_domain(domain);
        } else {
                atomic_inc(&domain->ref);
+               dev_iommu_domain(dev) = domain;
        }
 
 out:
@@ -2794,7 +2795,10 @@ static int arm_smmu_deassign_dev(struct domain *d, 
struct device *dev)
        atomic_dec(&domain->ref);
 
        if (domain->ref.counter == 0)
+       {
                arm_smmu_destroy_iommu_domain(domain);
+               dev_iommu_domain(dev) = NULL;
+       }
 
        spin_unlock(&xen_domain->lock);
 
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.