Skip to content

Commit a8653e5

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/vt-d: Use virt_to_phys()
If all the inlines are unwound virt_to_dma_pfn() is simply: return page_to_pfn(virt_to_page(p)) << (PAGE_SHIFT - VTD_PAGE_SHIFT); Which can be re-arranged to: (page_to_pfn(virt_to_page(p)) << PAGE_SHIFT) >> VTD_PAGE_SHIFT The only caller is: ((uint64_t)virt_to_dma_pfn(tmp_page) << VTD_PAGE_SHIFT) re-arranged to: ((page_to_pfn(virt_to_page(tmp_page)) << PAGE_SHIFT) >> VTD_PAGE_SHIFT) << VTD_PAGE_SHIFT Which simplifies to: page_to_pfn(virt_to_page(tmp_page)) << PAGE_SHIFT That is the same as virt_to_phys(tmp_page), so just remove all of this. Reviewed-by: Lu Baolu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 9ce7603 commit a8653e5

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,8 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
737737
return NULL;
738738

739739
domain_flush_cache(domain, tmp_page, VTD_PAGE_SIZE);
740-
pteval = ((uint64_t)virt_to_dma_pfn(tmp_page) << VTD_PAGE_SHIFT) | DMA_PTE_READ | DMA_PTE_WRITE;
740+
pteval = virt_to_phys(tmp_page) | DMA_PTE_READ |
741+
DMA_PTE_WRITE;
741742
if (domain->use_first_level)
742743
pteval |= DMA_FL_PTE_US | DMA_FL_PTE_ACCESS;
743744

drivers/iommu/intel/iommu.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -953,25 +953,6 @@ static inline unsigned long lvl_to_nr_pages(unsigned int lvl)
953953
return 1UL << min_t(int, (lvl - 1) * LEVEL_STRIDE, MAX_AGAW_PFN_WIDTH);
954954
}
955955

956-
/* VT-d pages must always be _smaller_ than MM pages. Otherwise things
957-
are never going to work. */
958-
static inline unsigned long mm_to_dma_pfn_start(unsigned long mm_pfn)
959-
{
960-
return mm_pfn << (PAGE_SHIFT - VTD_PAGE_SHIFT);
961-
}
962-
static inline unsigned long mm_to_dma_pfn_end(unsigned long mm_pfn)
963-
{
964-
return ((mm_pfn + 1) << (PAGE_SHIFT - VTD_PAGE_SHIFT)) - 1;
965-
}
966-
static inline unsigned long page_to_dma_pfn(struct page *pg)
967-
{
968-
return mm_to_dma_pfn_start(page_to_pfn(pg));
969-
}
970-
static inline unsigned long virt_to_dma_pfn(void *p)
971-
{
972-
return page_to_dma_pfn(virt_to_page(p));
973-
}
974-
975956
static inline void context_set_present(struct context_entry *context)
976957
{
977958
context->lo |= 1;

0 commit comments

Comments
 (0)