> From: Lu Baolu <baolu...@linux.intel.com>
> Sent: Tuesday, June 14, 2022 10:52 AM
> 
> Fold __dmar_remove_one_dev_info() into dmar_remove_one_dev_info()
> which
> is its only caller. Make the spin lock critical range only cover the
> device list change code and remove some unnecessary checks.
> 
> Signed-off-by: Lu Baolu <baolu...@linux.intel.com>
> ---
>  drivers/iommu/intel/iommu.c | 34 +++++++++-------------------------
>  1 file changed, 9 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index af22690f44c8..8345e0c0824c 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -295,7 +295,6 @@ static LIST_HEAD(dmar_satc_units);
>  static int g_num_of_iommus;
> 
>  static void dmar_remove_one_dev_info(struct device *dev);
> -static void __dmar_remove_one_dev_info(struct device_domain_info *info);
> 
>  int dmar_disabled = !IS_ENABLED(CONFIG_INTEL_IOMMU_DEFAULT_ON);
>  int intel_iommu_sm =
> IS_ENABLED(CONFIG_INTEL_IOMMU_SCALABLE_MODE_DEFAULT_ON);
> @@ -4141,20 +4140,14 @@ static void domain_context_clear(struct
> device_domain_info *info)
>                              &domain_context_clear_one_cb, info);
>  }
> 
> -static void __dmar_remove_one_dev_info(struct device_domain_info *info)
> +static void dmar_remove_one_dev_info(struct device *dev)
>  {
> -     struct dmar_domain *domain;
> -     struct intel_iommu *iommu;
> -
> -     assert_spin_locked(&device_domain_lock);
> -
> -     if (WARN_ON(!info))
> -             return;
> -
> -     iommu = info->iommu;
> -     domain = info->domain;
> +     struct device_domain_info *info = dev_iommu_priv_get(dev);
> +     struct dmar_domain *domain = info->domain;

this local variable is not required as there is just one reference
to info->domain.

btw I didn't see info->domain is cleared in this path. Is it correct?

> +     struct intel_iommu *iommu = info->iommu;
> +     unsigned long flags;
> 
> -     if (info->dev && !dev_is_real_dma_subdevice(info->dev)) {
> +     if (!dev_is_real_dma_subdevice(info->dev)) {
>               if (dev_is_pci(info->dev) && sm_supported(iommu))
>                       intel_pasid_tear_down_entry(iommu, info->dev,
>                                       PASID_RID2PASID, false);
> @@ -4164,20 +4157,11 @@ static void
> __dmar_remove_one_dev_info(struct device_domain_info *info)
>               intel_pasid_free_table(info->dev);
>       }
> 
> -     list_del(&info->link);
> -     domain_detach_iommu(domain, iommu);
> -}
> -
> -static void dmar_remove_one_dev_info(struct device *dev)
> -{
> -     struct device_domain_info *info;
> -     unsigned long flags;
> -
>       spin_lock_irqsave(&device_domain_lock, flags);
> -     info = dev_iommu_priv_get(dev);
> -     if (info)
> -             __dmar_remove_one_dev_info(info);
> +     list_del(&info->link);
>       spin_unlock_irqrestore(&device_domain_lock, flags);
> +
> +     domain_detach_iommu(domain, iommu);
>  }
> 
>  static int md_domain_init(struct dmar_domain *domain, int guest_width)
> --
> 2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to