Message ID | 1623854282-26121-1-git-send-email-zhangfei.gao@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC] iommu: add domain->nested | expand |
On Wed, Jun 16, 2021 at 10:38:02PM +0800, Zhangfei Gao wrote: > +++ 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.
On 2021/6/16 下午10:44, Christoph Hellwig wrote: > On Wed, Jun 16, 2021 at 10:38:02PM +0800, Zhangfei Gao wrote: >> +++ 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.
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 {
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(-)