Commit b026fd28 authored by David Woodhouse's avatar David Woodhouse

intel-iommu: Change addr_to_dma_pte() to pfn_to_dma_pte()

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 163cc52c
...@@ -692,23 +692,24 @@ static inline unsigned long align_to_level(unsigned long pfn, int level) ...@@ -692,23 +692,24 @@ static inline unsigned long align_to_level(unsigned long pfn, int level)
return (pfn + level_size(level) - 1) & level_mask(level); return (pfn + level_size(level) - 1) & level_mask(level);
} }
static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
unsigned long pfn)
{ {
int addr_width = agaw_to_width(domain->agaw); int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
struct dma_pte *parent, *pte = NULL; struct dma_pte *parent, *pte = NULL;
int level = agaw_to_level(domain->agaw); int level = agaw_to_level(domain->agaw);
int offset; int offset;
unsigned long flags; unsigned long flags;
BUG_ON(!domain->pgd); BUG_ON(!domain->pgd);
BUG_ON(addr >> addr_width); BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width);
parent = domain->pgd; parent = domain->pgd;
spin_lock_irqsave(&domain->mapping_lock, flags); spin_lock_irqsave(&domain->mapping_lock, flags);
while (level > 0) { while (level > 0) {
void *tmp_page; void *tmp_page;
offset = pfn_level_offset(addr >> VTD_PAGE_SHIFT, level); offset = pfn_level_offset(pfn, level);
pte = &parent[offset]; pte = &parent[offset];
if (level == 1) if (level == 1)
break; break;
...@@ -1660,7 +1661,7 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, ...@@ -1660,7 +1661,7 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
end_pfn = (VTD_PAGE_ALIGN(((u64)hpa) + size)) >> VTD_PAGE_SHIFT; end_pfn = (VTD_PAGE_ALIGN(((u64)hpa) + size)) >> VTD_PAGE_SHIFT;
index = 0; index = 0;
while (start_pfn < end_pfn) { while (start_pfn < end_pfn) {
pte = addr_to_dma_pte(domain, iova + VTD_PAGE_SIZE * index); pte = pfn_to_dma_pte(domain, (iova >> VTD_PAGE_SHIFT) + index);
if (!pte) if (!pte)
return -ENOMEM; return -ENOMEM;
/* We don't need lock here, nobody else /* We don't need lock here, nobody else
...@@ -3533,7 +3534,7 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, ...@@ -3533,7 +3534,7 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
struct dma_pte *pte; struct dma_pte *pte;
u64 phys = 0; u64 phys = 0;
pte = addr_to_dma_pte(dmar_domain, iova); pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT);
if (pte) if (pte)
phys = dma_pte_addr(pte); phys = dma_pte_addr(pte);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment