[PATCH v1] iommu/vt-d: Remove redundant SLTS cap check for nested and dirty tracking

Wei Wang posted 1 patch 6 months, 2 weeks ago
drivers/iommu/intel/iommu.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
[PATCH v1] iommu/vt-d: Remove redundant SLTS cap check for nested and dirty tracking
Posted by Wei Wang 6 months, 2 weeks ago
In intel_iommu_domain_alloc_paging_flags():
For the nested_parent case, nested_supported() has been check earlier,
and for the dirty_tracking case, ssads_supported() has been check earlier.
Both of these imply SLTS support, making the subsequent SLTS cap check
redundant.
Also, false-initialize the first_stage boolean to simplify the code.

Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
 drivers/iommu/intel/iommu.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 7aa3932251b2..a79f91b47a8a 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3340,7 +3340,7 @@ intel_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
 	struct intel_iommu *iommu = info->iommu;
 	struct dmar_domain *dmar_domain;
 	struct iommu_domain *domain;
-	bool first_stage;
+	bool first_stage = false;
 
 	if (flags &
 	    (~(IOMMU_HWPT_ALLOC_NEST_PARENT | IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
@@ -3356,13 +3356,8 @@ intel_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
 	 * IOMMU_HWPT_ALLOC_NEST_PARENT or IOMMU_HWPT_ALLOC_DIRTY_TRACKING
 	 * is specified.
 	 */
-	if (nested_parent || dirty_tracking) {
-		if (!sm_supported(iommu) || !ecap_slts(iommu->ecap))
-			return ERR_PTR(-EOPNOTSUPP);
-		first_stage = false;
-	} else {
+	if (!nested_parent && !dirty_tracking)
 		first_stage = first_level_by_default(iommu);
-	}
 
 	dmar_domain = paging_domain_alloc(dev, first_stage);
 	if (IS_ERR(dmar_domain))

base-commit: 16b70698aa3ae7888826d0c84567c72241cf6713
-- 
2.43.0
Re: [PATCH v1] iommu/vt-d: Remove redundant SLTS cap check for nested and dirty tracking
Posted by Jason Gunthorpe 6 months, 2 weeks ago
On Thu, Jun 05, 2025 at 06:10:52PM +0800, Wei Wang wrote:
> In intel_iommu_domain_alloc_paging_flags():
> For the nested_parent case, nested_supported() has been check earlier,
> and for the dirty_tracking case, ssads_supported() has been check earlier.
> Both of these imply SLTS support, making the subsequent SLTS cap check
> redundant.
> Also, false-initialize the first_stage boolean to simplify the code.
> 
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> ---
>  drivers/iommu/intel/iommu.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)

I'm going to post a patch that fixes this (and the other one you sent)
differently next week:

https://github.com/jgunthorpe/linux/commits/iommu_pt_vtd/

  iommu/vtd: Split intel_iommu_domain_alloc_paging_flags()

Jason