From 62a67b00a8f950b04c15a042593100c3a80082fd Mon Sep 17 00:00:00 2001 From: dongqiang Date: Fri, 2 Jul 2021 00:35:35 +0800 Subject: [PATCH] Fix Smmu IOVA contiguous checking error To allocate larger buffer, MODS code is allocating noncontiguous pages and then calls dma buffer api to do smmu mapping to get a continuous iova address. This change will fix the error when the scatterlist's dma address is 0xffffffffffffffff, skip checking the sg since it's already merged to the head node. JIRA: TM-129 Signed-off-by: Carl Dong Change-Id: I45aa3b0afcf5c86179fb293cd48326b14c2f3efc Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2552672 Reviewed-by: svc_kernel_abi Reviewed-by: svcacv Reviewed-by: Sachin Nikam Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/misc/mods/mods_mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/misc/mods/mods_mem.c b/drivers/misc/mods/mods_mem.c index 34569c26..f795fda7 100644 --- a/drivers/misc/mods/mods_mem.c +++ b/drivers/misc/mods/mods_mem.c @@ -2141,15 +2141,15 @@ int esc_mods_iommu_dma_map_memory(struct mods_client *client, /* Check if IOVAs are contiguous */ iova_offset = 0; for_each_sg(sgt->sgl, sg, sgt->nents, i) { - iova_offset = iova_offset + sg->offset; - if (sg_dma_address(sg) != (iova + iova_offset) - || sg_dma_len(sg) != sg->length) { + if (sg_dma_address(sg) != (~(dma_addr_t)0) && + sg_dma_address(sg) != (iova + iova_offset)) { cl_error("sg not contiguous:dma 0x%llx, iova 0x%llx\n", sg_dma_address(sg), (u64)(iova + iova_offset)); err = -EINVAL; break; } + iova_offset += sg->length; } if (err) { dma_unmap_sg_attrs(smmu_pdev->dev, sgt->sgl, sgt->nents,