From 962bad7d0a9c2d089ea68d3c2e676ee7432eef7a Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Mon, 27 Jul 2020 21:12:41 -0700 Subject: [PATCH] dma-mapping-fast: Fix sg-list length calculation in fast_smmu_unmap_sg() The length of an IOVA mapped to an sg-list in fast_smmu_unmap_sg() is determined using the DMA length of the data in the sg-list. Using the DMA length of the entries in the sg-list may result in incorrectly calculating the length of the IOVA range that needs to be freed, as the buffers are mapped at an IOMMU granule. Thus, align the IOVA length to the IOMMU granule when unmapping IOVAs in fast_smmu_unmap_sg(). Change-Id: I7dbe88ed2db46b1c9b278f92c2a23a9ebc2d503a Signed-off-by: Isaac J. Manjarres --- drivers/iommu/dma-mapping-fast.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/dma-mapping-fast.c b/drivers/iommu/dma-mapping-fast.c index 9ee2d572687a..8a940e7d2a78 100644 --- a/drivers/iommu/dma-mapping-fast.c +++ b/drivers/iommu/dma-mapping-fast.c @@ -378,7 +378,8 @@ static void fast_smmu_unmap_sg(struct device *dev, break; sg = tmp; } - len = sg_dma_address(sg) + sg_dma_len(sg) - start; + len = ALIGN(sg_dma_address(sg) + sg_dma_len(sg) - start, + FAST_PAGE_SIZE); av8l_fast_unmap_public(mapping->pgtbl_ops, start, len);