[RFC PATCH] iommu: add domain->nested

Subsystems: iommu subsystem, the rest

STALE1877d

3 messages, 2 authors, 2021-06-17 · open the first message on its own page

[RFC PATCH] iommu: add domain->nested

From: Zhangfei Gao <zhangfei.gao@linaro.org>
Date: 2021-06-16 14:38:27

Add domain->nested to decide whether domain is in nesting mode,
since attr DOMAIN_ATTR_NESTING is removed in the patches:
7876a83 iommu: remove iommu_domain_{get,set}_attr
7e14754 iommu: remove DOMAIN_ATTR_NESTING

Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---

Nesting info is still required for vsva according to
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210301084257.945454-16-hch@lst.de/

 drivers/iommu/iommu.c | 8 +++++++-
 include/linux/iommu.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 808ab70..ba26ad0 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2684,11 +2684,17 @@ core_initcall(iommu_init);
 
 int iommu_enable_nesting(struct iommu_domain *domain)
 {
+	int ret;
+
 	if (domain->type != IOMMU_DOMAIN_UNMANAGED)
 		return -EINVAL;
 	if (!domain->ops->enable_nesting)
 		return -EINVAL;
-	return domain->ops->enable_nesting(domain);
+	ret = domain->ops->enable_nesting(domain);
+	if (!ret)
+		domain->nested = 1;
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(iommu_enable_nesting);
 
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 32d4480..179f849 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -87,6 +87,7 @@ struct iommu_domain {
 	void *handler_token;
 	struct iommu_domain_geometry geometry;
 	void *iova_cookie;
+	int nested;
 };
 
 enum iommu_cap {
-- 
2.7.4

Re: [RFC PATCH] iommu: add domain->nested

From: Christoph Hellwig <hch@lst.de>
Date: 2021-06-16 14:44:17

On Wed, Jun 16, 2021 at 10:38:02PM +0800, Zhangfei Gao wrote:
quoted hunk
+++ b/include/linux/iommu.h
@@ -87,6 +87,7 @@ struct iommu_domain {
 	void *handler_token;
 	struct iommu_domain_geometry geometry;
 	void *iova_cookie;
+	int nested;
This should probably be a bool : 1;

Also this needs a user, so please just queue up a variant of this for
the code that eventually relies on this information.

Re: [RFC PATCH] iommu: add domain->nested

From: Zhangfei Gao <zhangfei.gao@linaro.org>
Date: 2021-06-17 03:13:48


On 2021/6/16 下午10:44, Christoph Hellwig wrote:
On Wed, Jun 16, 2021 at 10:38:02PM +0800, Zhangfei Gao wrote:
quoted
+++ b/include/linux/iommu.h
@@ -87,6 +87,7 @@ struct iommu_domain {
  	void *handler_token;
  	struct iommu_domain_geometry geometry;
  	void *iova_cookie;
+	int nested;
This should probably be a bool : 1;

Also this needs a user, so please just queue up a variant of this for
the code that eventually relies on this information.
Thanks Christoph

Got it, will do this.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help