summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAnand K Mistry <amistry@chromium.org>2020-04-20 08:08:34 +0200
committerChun-Kuang Hu <chunkuang.hu@kernel.org>2020-05-20 18:10:08 +0200
commit9a67bc4aac82d18132e8a5677926f05d43e44e77 (patch)
treeedd0bd1b54812bee275e4be3582b2cc9fac066e8 /drivers/gpu
parentdrm/mediatek: config mipitx impedance with calibration data (diff)
downloadlinux-9a67bc4aac82d18132e8a5677926f05d43e44e77.tar.xz
linux-9a67bc4aac82d18132e8a5677926f05d43e44e77.zip
drm/mediatek: Stop iterating dma addresses when sg_dma_len() == 0
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>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_gem.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index b04a3c2b111e..f8fd8b98c30e 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -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;