Skip to content

Commit c317452

Browse files
nicolincwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Add an inline arm_smmu_domain_free()
There will be a bit more things to free than smmu_domain itself. So keep a simple inline function in the header to share aross files. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Acked-by: Balbir Singh <balbirs@nvidia.com> Reviewed-by: Pranjal Shrivastava <praan@google.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 9b05685 commit c317452

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ static void arm_smmu_mm_release(struct mmu_notifier *mn, struct mm_struct *mm)
197197

198198
static void arm_smmu_mmu_notifier_free(struct mmu_notifier *mn)
199199
{
200-
kfree(container_of(mn, struct arm_smmu_domain, mmu_notifier));
200+
arm_smmu_domain_free(
201+
container_of(mn, struct arm_smmu_domain, mmu_notifier));
201202
}
202203

203204
static const struct mmu_notifier_ops arm_smmu_mmu_notifier_ops = {
@@ -365,6 +366,6 @@ struct iommu_domain *arm_smmu_sva_domain_alloc(struct device *dev,
365366
err_asid:
366367
xa_erase(&arm_smmu_asid_xa, smmu_domain->cd.asid);
367368
err_free:
368-
kfree(smmu_domain);
369+
arm_smmu_domain_free(smmu_domain);
369370
return ERR_PTR(ret);
370371
}

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@ static void arm_smmu_domain_free_paging(struct iommu_domain *domain)
25592559
ida_free(&smmu->vmid_map, cfg->vmid);
25602560
}
25612561

2562-
kfree(smmu_domain);
2562+
arm_smmu_domain_free(smmu_domain);
25632563
}
25642564

25652565
static int arm_smmu_domain_finalise_s1(struct arm_smmu_device *smmu,
@@ -3427,7 +3427,7 @@ arm_smmu_domain_alloc_paging_flags(struct device *dev, u32 flags,
34273427
return &smmu_domain->domain;
34283428

34293429
err_free:
3430-
kfree(smmu_domain);
3430+
arm_smmu_domain_free(smmu_domain);
34313431
return ERR_PTR(ret);
34323432
}
34333433

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,11 @@ extern struct mutex arm_smmu_asid_lock;
956956

957957
struct arm_smmu_domain *arm_smmu_domain_alloc(void);
958958

959+
static inline void arm_smmu_domain_free(struct arm_smmu_domain *smmu_domain)
960+
{
961+
kfree(smmu_domain);
962+
}
963+
959964
void arm_smmu_clear_cd(struct arm_smmu_master *master, ioasid_t ssid);
960965
struct arm_smmu_cd *arm_smmu_get_cd_ptr(struct arm_smmu_master *master,
961966
u32 ssid);

0 commit comments

Comments
 (0)