Re: [PATCH v4 12/13] iommu/arm-smmu-v3-sva: Remove arm_smmu_bond
From: Michael Shavit
Date: Thu Jul 13 2023 - 04:44:27 EST
> On Wed, Jun 21, 2023 at 2:44 PM Michael Shavit <mshavit@xxxxxxxxxx> wrote:
> @@ -545,23 +534,12 @@ void arm_smmu_sva_notifier_synchronize(void)
> void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain,
> struct device *dev, ioasid_t id)
> {
> - struct mm_struct *mm = domain->mm;
> - struct arm_smmu_bond *bond = NULL, *t;
> + struct arm_smmu_sva_domain *sva_domain = to_sva_domain(domain);
> struct arm_smmu_master *master = dev_iommu_priv_get(dev);
>
> mutex_lock(&sva_lock);
> - list_for_each_entry(t, &master->bonds, list) {
> - if (t->mm == mm) {
> - bond = t;
> - break;
> - }
> - }
> -
> - if (!WARN_ON(!bond)) {
> - list_del(&bond->list);
> - arm_smmu_mmu_notifier_put(bond->smmu_mn);
> - kfree(bond);
> - }
> + master->nr_attached_sva_domains -= 1;
> + arm_smmu_mmu_notifier_put(sva_domain->smmu_mn);
> mutex_unlock(&sva_lock);
> }
I've encountered a bug with this change while working on a follow-up
series. arm_smmu_sva_remove_dev_pasid() is called on the domain if
arm_smmu_sva_set_dev_pasid failed. Removing the WARN_ON(!bond)
condition removed a protection against that scenario. I have a fix for
this change that I'll push into a v5 of the series.