[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260205023405.41583-2-zhenzhong.duan@intel.com>
Date: Wed, 4 Feb 2026 21:34:02 -0500
From: Zhenzhong Duan <zhenzhong.duan@...el.com>
To: linux-kernel@...r.kernel.org,
iommu@...ts.linux.dev
Cc: dwmw2@...radead.org,
baolu.lu@...ux.intel.com,
joro@...tes.org,
will@...nel.org,
robin.murphy@....com,
jgg@...pe.ca,
kevin.tian@...el.com,
Zhenzhong Duan <zhenzhong.duan@...el.com>
Subject: [PATCH 1/3] iommupt/vtd: Pass dmar_domain pointer to device_set_dirty_tracking()
Pass dmar_domain pointer to device_set_dirty_tracking() instead of
device list in the domain.
This is a prerequisite patch to support dirty tracking on PASIDs.
No functional changes intended.
Suggested-by: Lu Baolu <baolu.lu@...ux.intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@...el.com>
---
drivers/iommu/intel/iommu.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 134302fbcd92..acaa6eaf7e2f 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3687,16 +3687,15 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length,
return vtd;
}
-/*
- * Set dirty tracking for the device list of a domain. The caller must
- * hold the domain->lock when calling it.
- */
-static int device_set_dirty_tracking(struct list_head *devices, bool enable)
+/* Set dirty tracking for the devices that the domain has been attached. */
+static int device_set_dirty_tracking(struct dmar_domain *domain, bool enable)
{
struct device_domain_info *info;
int ret = 0;
- list_for_each_entry(info, devices, link) {
+ lockdep_assert_held(&domain->lock);
+
+ list_for_each_entry(info, &domain->devices, link) {
ret = intel_pasid_setup_dirty_tracking(info->iommu, info->dev,
IOMMU_NO_PASID, enable);
if (ret)
@@ -3716,7 +3715,7 @@ static int parent_domain_set_dirty_tracking(struct dmar_domain *domain,
spin_lock(&domain->s1_lock);
list_for_each_entry(s1_domain, &domain->s1_domains, s2_link) {
spin_lock_irqsave(&s1_domain->lock, flags);
- ret = device_set_dirty_tracking(&s1_domain->devices, enable);
+ ret = device_set_dirty_tracking(s1_domain, enable);
spin_unlock_irqrestore(&s1_domain->lock, flags);
if (ret)
goto err_unwind;
@@ -3727,8 +3726,7 @@ static int parent_domain_set_dirty_tracking(struct dmar_domain *domain,
err_unwind:
list_for_each_entry(s1_domain, &domain->s1_domains, s2_link) {
spin_lock_irqsave(&s1_domain->lock, flags);
- device_set_dirty_tracking(&s1_domain->devices,
- domain->dirty_tracking);
+ device_set_dirty_tracking(s1_domain, domain->dirty_tracking);
spin_unlock_irqrestore(&s1_domain->lock, flags);
}
spin_unlock(&domain->s1_lock);
@@ -3745,7 +3743,7 @@ static int intel_iommu_set_dirty_tracking(struct iommu_domain *domain,
if (dmar_domain->dirty_tracking == enable)
goto out_unlock;
- ret = device_set_dirty_tracking(&dmar_domain->devices, enable);
+ ret = device_set_dirty_tracking(dmar_domain, enable);
if (ret)
goto err_unwind;
@@ -3762,8 +3760,7 @@ static int intel_iommu_set_dirty_tracking(struct iommu_domain *domain,
return 0;
err_unwind:
- device_set_dirty_tracking(&dmar_domain->devices,
- dmar_domain->dirty_tracking);
+ device_set_dirty_tracking(dmar_domain, dmar_domain->dirty_tracking);
spin_unlock(&dmar_domain->lock);
return ret;
}
--
2.47.3
Powered by blists - more mailing lists