diff options
author | Hiroshi Doyu <hdoyu@nvidia.com> | 2014-04-10 10:32:55 +0300 |
---|---|---|
committer | Hiroshi Doyu <hdoyu@nvidia.com> | 2014-04-10 05:21:55 -0700 |
commit | 598c37582f8ee66e244053d9e06abbfbc8009425 (patch) | |
tree | 78cfd336fb4d90e36a83f3974c057eeb42035762 /drivers | |
parent | 930e8ede6aa15ea17271e4540ad4c3ccba68a72d (diff) |
iommu/tegra: smmu: sg_num_pages(sg) calc number of pages
Introduced a new macro sg_num_pages() to calculate the number of pages
in sg.
Bug 1418514
Change-Id: I0d48ce3e4d9f28d3a1cfab118508eadcc59c3a9b
Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>
Reviewed-on: http://git-master/r/394580
Reviewed-by: Sri Krishna Chowdary <schowdary@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/iommu/tegra-smmu.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 17793a2a7359..93986d6eddb5 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -1143,6 +1143,9 @@ out: return err; } +#define sg_num_pages(sg) \ + (PAGE_ALIGN((sg)->offset + (sg)->length) >> PAGE_SHIFT) + static int smmu_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sgl, int npages, unsigned long prot) { @@ -1154,8 +1157,7 @@ static int smmu_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, struct smmu_device *smmu = as->smmu; int attrs = as->pte_attr; size_t total = npages; - size_t sg_remaining = - PAGE_ALIGN(sgl->offset + sgl->length) >> PAGE_SHIFT; + size_t sg_remaining = sg_num_pages(sgl); unsigned long sg_pfn = page_to_pfn(sg_page(sgl)); if (dma_get_attr(DMA_ATTR_READ_ONLY, (struct dma_attrs *)prot)) @@ -1202,9 +1204,7 @@ static int smmu_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, sgl = sg_next(sgl); if (sgl) { sg_pfn = page_to_pfn(sg_page(sgl)); - sg_remaining = - PAGE_ALIGN(sgl->offset + sgl->length) - >> PAGE_SHIFT; + sg_remaining = sg_num_pages(sgl); } } |