@@ -4729,23 +4729,38 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length, u32 *type)
4729
4729
return vtd ;
4730
4730
}
4731
4731
4732
+ /*
4733
+ * Set dirty tracking for the device list of a domain. The caller must
4734
+ * hold the domain->lock when calling it.
4735
+ */
4736
+ static int device_set_dirty_tracking (struct list_head * devices , bool enable )
4737
+ {
4738
+ struct device_domain_info * info ;
4739
+ int ret = 0 ;
4740
+
4741
+ list_for_each_entry (info , devices , link ) {
4742
+ ret = intel_pasid_setup_dirty_tracking (info -> iommu , info -> dev ,
4743
+ IOMMU_NO_PASID , enable );
4744
+ if (ret )
4745
+ break ;
4746
+ }
4747
+
4748
+ return ret ;
4749
+ }
4750
+
4732
4751
static int intel_iommu_set_dirty_tracking (struct iommu_domain * domain ,
4733
4752
bool enable )
4734
4753
{
4735
4754
struct dmar_domain * dmar_domain = to_dmar_domain (domain );
4736
- struct device_domain_info * info ;
4737
4755
int ret ;
4738
4756
4739
4757
spin_lock (& dmar_domain -> lock );
4740
4758
if (dmar_domain -> dirty_tracking == enable )
4741
4759
goto out_unlock ;
4742
4760
4743
- list_for_each_entry (info , & dmar_domain -> devices , link ) {
4744
- ret = intel_pasid_setup_dirty_tracking (info -> iommu , info -> dev ,
4745
- IOMMU_NO_PASID , enable );
4746
- if (ret )
4747
- goto err_unwind ;
4748
- }
4761
+ ret = device_set_dirty_tracking (& dmar_domain -> devices , enable );
4762
+ if (ret )
4763
+ goto err_unwind ;
4749
4764
4750
4765
dmar_domain -> dirty_tracking = enable ;
4751
4766
out_unlock :
@@ -4754,10 +4769,8 @@ static int intel_iommu_set_dirty_tracking(struct iommu_domain *domain,
4754
4769
return 0 ;
4755
4770
4756
4771
err_unwind :
4757
- list_for_each_entry (info , & dmar_domain -> devices , link )
4758
- intel_pasid_setup_dirty_tracking (info -> iommu , info -> dev ,
4759
- IOMMU_NO_PASID ,
4760
- dmar_domain -> dirty_tracking );
4772
+ device_set_dirty_tracking (& dmar_domain -> devices ,
4773
+ dmar_domain -> dirty_tracking );
4761
4774
spin_unlock (& dmar_domain -> lock );
4762
4775
return ret ;
4763
4776
}
0 commit comments