Skip to content

Commit 89d5b96

Browse files
willdeaconjoergroedel
authored andcommitted
iommu: Split 'addr_merge' argument to iommu_pgsize() into separate parts
The 'addr_merge' parameter to iommu_pgsize() is a fabricated address intended to describe the alignment requirements to consider when choosing an appropriate page size. On the iommu_map() path, this address is the logical OR of the virtual and physical addresses. Subsequent improvements to iommu_pgsize() will need to check the alignment of the virtual and physical components of 'addr_merge' independently, so pass them in as separate parameters and reconstruct 'addr_merge' locally. No functional change. Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Isaac J. Manjarres <[email protected]> Signed-off-by: Georgi Djakov <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent e7d6fff commit 89d5b96

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/iommu/iommu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,12 +2375,13 @@ phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
23752375
}
23762376
EXPORT_SYMBOL_GPL(iommu_iova_to_phys);
23772377

2378-
static size_t iommu_pgsize(struct iommu_domain *domain,
2379-
unsigned long addr_merge, size_t size)
2378+
static size_t iommu_pgsize(struct iommu_domain *domain, unsigned long iova,
2379+
phys_addr_t paddr, size_t size)
23802380
{
23812381
unsigned int pgsize_idx;
23822382
unsigned long pgsizes;
23832383
size_t pgsize;
2384+
unsigned long addr_merge = paddr | iova;
23842385

23852386
/* Page sizes supported by the hardware and small enough for @size */
23862387
pgsizes = domain->pgsize_bitmap & GENMASK(__fls(size), 0);
@@ -2433,7 +2434,7 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova,
24332434
pr_debug("map: iova 0x%lx pa %pa size 0x%zx\n", iova, &paddr, size);
24342435

24352436
while (size) {
2436-
size_t pgsize = iommu_pgsize(domain, iova | paddr, size);
2437+
size_t pgsize = iommu_pgsize(domain, iova, paddr, size);
24372438

24382439
pr_debug("mapping: iova 0x%lx pa %pa pgsize 0x%zx\n",
24392440
iova, &paddr, pgsize);
@@ -2521,8 +2522,9 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
25212522
* or we hit an area that isn't mapped.
25222523
*/
25232524
while (unmapped < size) {
2524-
size_t pgsize = iommu_pgsize(domain, iova, size - unmapped);
2525+
size_t pgsize;
25252526

2527+
pgsize = iommu_pgsize(domain, iova, iova, size - unmapped);
25262528
unmapped_page = ops->unmap(domain, iova, pgsize, iotlb_gather);
25272529
if (!unmapped_page)
25282530
break;

0 commit comments

Comments
 (0)