[RFC PATCH v2 10/10] iommu:riscv: support nested iommu for get_msi_mapping_domain operation
Zong Li
zong.li at sifive.com
Fri Jun 14 07:21:56 PDT 2024
Return the iommu_domain that should hold the MSI cookie.
Signed-off-by: Zong Li <zong.li at sifive.com>
---
drivers/iommu/riscv/iommu.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
index d08eb0a2939e..969a0ba32c9e 100644
--- a/drivers/iommu/riscv/iommu.c
+++ b/drivers/iommu/riscv/iommu.c
@@ -1689,10 +1689,22 @@ static int riscv_iommu_cache_invalidate_user(struct iommu_domain *domain,
return ret;
}
+static struct iommu_domain *
+riscv_iommu_get_msi_mapping_domain(struct iommu_domain *domain)
+{
+ struct riscv_iommu_domain *riscv_domain = iommu_domain_to_riscv(domain);
+
+ if (riscv_domain->s2)
+ return &riscv_domain->s2->domain;
+
+ return domain;
+}
+
static const struct iommu_domain_ops riscv_iommu_nested_domain_ops = {
.attach_dev = riscv_iommu_attach_dev_nested,
.free = riscv_iommu_domain_free_nested,
.cache_invalidate_user = riscv_iommu_cache_invalidate_user,
+ .get_msi_mapping_domain = riscv_iommu_get_msi_mapping_domain,
};
static int
--
2.17.1
More information about the linux-riscv
mailing list