Skip to content

Commit

Permalink
iommu/amd: Optimize alloc_new_range for new fetch_pte interface
Browse files Browse the repository at this point in the history
Now that fetch_pte returns the page-size of the pte, the
call in this function can also be optimized a little bit.

Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Joerg Roedel committed Apr 2, 2015
1 parent 71b390e commit 5d7c94c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
{
int index = dma_dom->aperture_size >> APERTURE_RANGE_SHIFT;
struct amd_iommu *iommu;
unsigned long i, old_size;
unsigned long i, old_size, pte_pgsize;

#ifdef CONFIG_IOMMU_STRESS
populate = false;
Expand Down Expand Up @@ -1664,13 +1664,13 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
*/
for (i = dma_dom->aperture[index]->offset;
i < dma_dom->aperture_size;
i += PAGE_SIZE) {
unsigned long pte_pgsize;
i += pte_pgsize) {
u64 *pte = fetch_pte(&dma_dom->domain, i, &pte_pgsize);
if (!pte || !IOMMU_PTE_PRESENT(*pte))
continue;

dma_ops_reserve_addresses(dma_dom, i >> PAGE_SHIFT, 1);
dma_ops_reserve_addresses(dma_dom, i >> PAGE_SHIFT,
pte_pgsize >> 12);
}

update_domain(&dma_dom->domain);
Expand Down

0 comments on commit 5d7c94c

Please sign in to comment.