OSDN Git Service

drm/mediatek: Stop iterating dma addresses when sg_dma_len() == 0
authorAnand K Mistry <amistry@chromium.org>
Mon, 20 Apr 2020 06:08:34 +0000 (16:08 +1000)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Wed, 20 May 2020 16:10:08 +0000 (00:10 +0800)
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>
drivers/gpu/drm/mediatek/mtk_drm_gem.c

index b04a3c2..f8fd8b9 100644 (file)
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
        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;