summaryrefslogtreecommitdiff
path: root/drivers/iommu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/tegra-smmu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 9e3c7b2cbc88..17793a2a7359 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -1154,7 +1154,8 @@ 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 = sgl->length >> PAGE_SHIFT;
+ size_t sg_remaining =
+ PAGE_ALIGN(sgl->offset + sgl->length) >> PAGE_SHIFT;
unsigned long sg_pfn = page_to_pfn(sg_page(sgl));
if (dma_get_attr(DMA_ATTR_READ_ONLY, (struct dma_attrs *)prot))
@@ -1201,7 +1202,9 @@ 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 = sgl->length >> PAGE_SHIFT;
+ sg_remaining =
+ PAGE_ALIGN(sgl->offset + sgl->length)
+ >> PAGE_SHIFT;
}
}