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 <carld@nvidia.com>
Change-Id: I45aa3b0afcf5c86179fb293cd48326b14c2f3efc
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2552672
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
dongqiang
2021-07-02 00:35:35 +08:00
committed by Laxman Dewangan
parent 16bb9a5ba0
commit 62a67b00a8

View File

@@ -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,