Skip to content

Commit 13b6eb6

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Streamline iommu_iova_to_phys()
If people are going to insist on calling iommu_iova_to_phys() pointlessly and expecting it to work, we can at least do ourselves a favour by handling those cases in the core code, rather than repeatedly across an inconsistent handful of drivers. Since all the existing drivers implement the internal callback, and any future ones are likely to want to work with iommu-dma which relies on iova_to_phys a fair bit, we may as well remove that currently-redundant check as well and consider it mandatory. Reviewed-by: Lu Baolu <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/f564f3f6ff731b898ff7a898919bf871c2c7745a.1626354264.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 308723e commit 13b6eb6

File tree

4 files changed

+4
-10
lines changed

4 files changed

+4
-10
lines changed

drivers/iommu/amd/io_pgtable.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,6 @@ static phys_addr_t iommu_v1_iova_to_phys(struct io_pgtable_ops *ops, unsigned lo
493493
unsigned long offset_mask, pte_pgsize;
494494
u64 *pte, __pte;
495495

496-
if (pgtable->mode == PAGE_MODE_NONE)
497-
return iova;
498-
499496
pte = fetch_pte(pgtable, iova, &pte_pgsize);
500497

501498
if (!pte || !IOMMU_PTE_PRESENT(*pte))

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,9 +2488,6 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
24882488
{
24892489
struct io_pgtable_ops *ops = to_smmu_domain(domain)->pgtbl_ops;
24902490

2491-
if (domain->type == IOMMU_DOMAIN_IDENTITY)
2492-
return iova;
2493-
24942491
if (!ops)
24952492
return 0;
24962493

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,9 +1322,6 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
13221322
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
13231323
struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops;
13241324

1325-
if (domain->type == IOMMU_DOMAIN_IDENTITY)
1326-
return iova;
1327-
13281325
if (!ops)
13291326
return 0;
13301327

drivers/iommu/iommu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,10 @@ EXPORT_SYMBOL_GPL(iommu_detach_group);
23722372

23732373
phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
23742374
{
2375-
if (unlikely(domain->ops->iova_to_phys == NULL))
2375+
if (domain->type == IOMMU_DOMAIN_IDENTITY)
2376+
return iova;
2377+
2378+
if (domain->type == IOMMU_DOMAIN_BLOCKED)
23762379
return 0;
23772380

23782381
return domain->ops->iova_to_phys(domain, iova);

0 commit comments

Comments
 (0)