Skip to content

Commit 6255868

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Consolidate protection domain free code
Consolidate protection domain free code inside amd_iommu_domain_free() and remove protection_domain_free() function. Signed-off-by: Vasant Hegde <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5536e19 commit 6255868

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ extern unsigned long amd_iommu_pgsize_bitmap;
4747
/* Protection domain ops */
4848
void amd_iommu_init_identity_domain(void);
4949
struct protection_domain *protection_domain_alloc(void);
50-
void protection_domain_free(struct protection_domain *domain);
5150
struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev,
5251
struct mm_struct *mm);
5352
void amd_iommu_domain_free(struct iommu_domain *dom);

drivers/iommu/amd/iommu.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,15 +2434,6 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
24342434
*
24352435
*****************************************************************************/
24362436

2437-
void protection_domain_free(struct protection_domain *domain)
2438-
{
2439-
WARN_ON(!list_empty(&domain->dev_list));
2440-
if (domain->domain.type & __IOMMU_DOMAIN_PAGING)
2441-
free_io_pgtable_ops(&domain->iop.pgtbl.ops);
2442-
pdom_id_free(domain->id);
2443-
kfree(domain);
2444-
}
2445-
24462437
static void protection_domain_init(struct protection_domain *domain)
24472438
{
24482439
spin_lock_init(&domain->lock);
@@ -2580,7 +2571,11 @@ void amd_iommu_domain_free(struct iommu_domain *dom)
25802571
{
25812572
struct protection_domain *domain = to_pdomain(dom);
25822573

2583-
protection_domain_free(domain);
2574+
WARN_ON(!list_empty(&domain->dev_list));
2575+
if (domain->domain.type & __IOMMU_DOMAIN_PAGING)
2576+
free_io_pgtable_ops(&domain->iop.pgtbl.ops);
2577+
pdom_id_free(domain->id);
2578+
kfree(domain);
25842579
}
25852580

25862581
static int blocked_domain_attach_device(struct iommu_domain *domain,

drivers/iommu/amd/pasid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev,
195195

196196
ret = mmu_notifier_register(&pdom->mn, mm);
197197
if (ret) {
198-
protection_domain_free(pdom);
198+
amd_iommu_domain_free(&pdom->domain);
199199
return ERR_PTR(ret);
200200
}
201201

0 commit comments

Comments
 (0)