Re: [PATCH v2 12/12] iommu/vt-d: Retire struct intel_svm

From: Baolu Lu
Date: Thu Apr 11 2024 - 09:13:34 EST


On 2024/4/11 21:07, Jason Gunthorpe wrote:
+static void intel_mm_free_notifier(struct mmu_notifier *mn)
+{
+ kfree(container_of(mn, struct dmar_domain, notifier));
+}
+
static const struct mmu_notifier_ops intel_mmuops = {
.release = intel_mm_release,
.arch_invalidate_secondary_tlbs =
intel_arch_invalidate_secondary_tlbs,
+ .free_notifier = intel_mm_free_notifier,
};

static int intel_svm_set_dev_pasid(struct iommu_domain *domain,
@@ -598,10 +604,8 @@ static void intel_svm_domain_free(struct iommu_domain
*domain)
{
struct dmar_domain *dmar_domain = to_dmar_domain(domain);

- if (dmar_domain->notifier.ops)
- mmu_notifier_unregister(&dmar_domain->notifier, domain->mm);
-
- kfree(dmar_domain);
+ /* dmar_domain free is defered to the mmu free_notifier callback. */
+ mmu_notifier_put(&dmar_domain->notifier);
}
Yeah, that is better.

Also you need to have mmu notifier call on module unload when using
this scheme.

The Intel IOMMU driver doesn't support being a module. It's always
built-in.

Best regards,
baolu