If dma_map_sg() merges pages when creating the mapping, only the first
entries will have a valid sg_dma_address() and sg_dma_len(), followed by
entries with sg_dma_len() == 0.
Signed-off-by: Anand K Mistry <amistry@google.com>
Signed-off-by: Anand K Mistry <amistry@chromium.org>
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
expected = sg_dma_address(sg->sgl);
for_each_sg(sg->sgl, s, sg->nents, i) {
+ if (!sg_dma_len(s))
+ break;
+
if (sg_dma_address(s) != expected) {
DRM_ERROR("sg_table is not contiguous");
ret = -EINVAL;