Commit b24b1b63 authored by Joerg Roedel's avatar Joerg Roedel

iommu/amd: Optimize amd_iommu_iova_to_phys for new fetch_pte interface

Now that fetch_pte returns the page-size of the pte, this
function can be optimized too.
Tested-by: default avatarSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 5d7c94c3
...@@ -3375,7 +3375,6 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom, ...@@ -3375,7 +3375,6 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
{ {
struct protection_domain *domain = dom->priv; struct protection_domain *domain = dom->priv;
unsigned long offset_mask, pte_pgsize; unsigned long offset_mask, pte_pgsize;
phys_addr_t paddr;
u64 *pte, __pte; u64 *pte, __pte;
if (domain->mode == PAGE_MODE_NONE) if (domain->mode == PAGE_MODE_NONE)
...@@ -3386,15 +3385,10 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom, ...@@ -3386,15 +3385,10 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
if (!pte || !IOMMU_PTE_PRESENT(*pte)) if (!pte || !IOMMU_PTE_PRESENT(*pte))
return 0; return 0;
if (PM_PTE_LEVEL(*pte) == 0) offset_mask = pte_pgsize - 1;
offset_mask = PAGE_SIZE - 1; __pte = *pte & PM_ADDR_MASK;
else
offset_mask = PTE_PAGE_SIZE(*pte) - 1;
__pte = *pte & PM_ADDR_MASK;
paddr = (__pte & ~offset_mask) | (iova & offset_mask);
return paddr; return (__pte & ~offset_mask) | (iova & offset_mask);
} }
static bool amd_iommu_capable(enum iommu_cap cap) static bool amd_iommu_capable(enum iommu_cap cap)
......
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