]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/vt-d: Rename device_set_dirty_tracking() and pass dmar_domain pointer
authorZhenzhong Duan <zhenzhong.duan@intel.com>
Thu, 2 Apr 2026 06:57:25 +0000 (14:57 +0800)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 2 Apr 2026 07:26:05 +0000 (09:26 +0200)
device_set_dirty_tracking() sets dirty tracking on all devices attached to
a domain, also on all PASIDs attached to same domain in subsequent patch.

So rename it as domain_set_dirty_tracking() and pass dmar_domain pointer
to better align to what it does.

No functional changes intended.

Suggested-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20260330101108.12594-3-zhenzhong.duan@intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/intel/iommu.c

index ef7613b177b9a9ca91adf7d863a1fd4f808804bb..965e0330ec4b03b8550d78af486cb541b21d3c8d 100644 (file)
@@ -3684,16 +3684,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 domain_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)
@@ -3713,7 +3712,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 = domain_set_dirty_tracking(s1_domain, enable);
                spin_unlock_irqrestore(&s1_domain->lock, flags);
                if (ret)
                        goto err_unwind;
@@ -3724,8 +3723,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);
+               domain_set_dirty_tracking(s1_domain, domain->dirty_tracking);
                spin_unlock_irqrestore(&s1_domain->lock, flags);
        }
        spin_unlock(&domain->s1_lock);
@@ -3742,7 +3740,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 = domain_set_dirty_tracking(dmar_domain, enable);
        if (ret)
                goto err_unwind;
 
@@ -3759,8 +3757,7 @@ out_unlock:
        return 0;
 
 err_unwind:
-       device_set_dirty_tracking(&dmar_domain->devices,
-                                 dmar_domain->dirty_tracking);
+       domain_set_dirty_tracking(dmar_domain, dmar_domain->dirty_tracking);
        spin_unlock(&dmar_domain->lock);
        return ret;
 }