Skip to content

Commit 251c4db

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd/io-pgtable: Implement unmap_pages io_pgtable_ops callback
Implement the io_pgtable_ops->unmap_pages() callback for AMD driver and deprecate io_pgtable_ops->unmap callback. Also if fetch_pte() returns NULL then return from unmap_mapages() instead of trying to continue to unmap remaining pages. Suggested-by: Robin Murphy <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8cc233d commit 251c4db

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/iommu/amd/io_pgtable.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,17 +435,18 @@ static int iommu_v1_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
435435
return ret;
436436
}
437437

438-
static unsigned long iommu_v1_unmap_page(struct io_pgtable_ops *ops,
439-
unsigned long iova,
440-
size_t size,
441-
struct iommu_iotlb_gather *gather)
438+
static unsigned long iommu_v1_unmap_pages(struct io_pgtable_ops *ops,
439+
unsigned long iova,
440+
size_t pgsize, size_t pgcount,
441+
struct iommu_iotlb_gather *gather)
442442
{
443443
struct amd_io_pgtable *pgtable = io_pgtable_ops_to_data(ops);
444444
unsigned long long unmapped;
445445
unsigned long unmap_size;
446446
u64 *pte;
447+
size_t size = pgcount << __ffs(pgsize);
447448

448-
BUG_ON(!is_power_of_2(size));
449+
BUG_ON(!is_power_of_2(pgsize));
449450

450451
unmapped = 0;
451452

@@ -457,14 +458,14 @@ static unsigned long iommu_v1_unmap_page(struct io_pgtable_ops *ops,
457458
count = PAGE_SIZE_PTE_COUNT(unmap_size);
458459
for (i = 0; i < count; i++)
459460
pte[i] = 0ULL;
461+
} else {
462+
return unmapped;
460463
}
461464

462465
iova = (iova & ~(unmap_size - 1)) + unmap_size;
463466
unmapped += unmap_size;
464467
}
465468

466-
BUG_ON(unmapped && !is_power_of_2(unmapped));
467-
468469
return unmapped;
469470
}
470471

@@ -524,7 +525,7 @@ static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo
524525
cfg->tlb = &v1_flush_ops;
525526

526527
pgtable->iop.ops.map_pages = iommu_v1_map_pages;
527-
pgtable->iop.ops.unmap = iommu_v1_unmap_page;
528+
pgtable->iop.ops.unmap_pages = iommu_v1_unmap_pages;
528529
pgtable->iop.ops.iova_to_phys = iommu_v1_iova_to_phys;
529530

530531
return &pgtable->iop;

0 commit comments

Comments
 (0)