drm/rockchip: gem: fixup iommu_map_sg error path
authorMark Yao <mark.yao@rock-chips.com>
Tue, 17 Jan 2017 09:30:39 +0000 (17:30 +0800)
committerMark Yao <mark.yao@rock-chips.com>
Tue, 17 Jan 2017 09:37:22 +0000 (17:37 +0800)
If iommu_map_sg is error, it's return value is zero, but
rockchip_gem_iommu_map feel the zero return value is success,
bug happen:

[    5.227458] [drm:rockchip_gem_iommu_map] *ERROR* failed to map buffer: 0
[   12.291590] WARNING: at drivers/gpu/drm/drm_mm.c:369
[   12.291611] Modules linked in:
[   12.291634]
[   12.291658] CPU: 4 PID: 338 Comm: cameraserver Not tainted 4.4.41 #196
[   12.291680] Hardware name: rockchip,rk3399-mid (DT)
[   12.291703] task: ffffffc0e5a23100 ti: ffffffc0e5a64000 task.ti: ffffffc0e5a64000
[   12.291739] PC is at drm_mm_remove_node+0xc/0xf8
[   12.291766] LR is at rockchip_gem_iommu_unmap+0x3c/0x54
[   12.303799] [<ffffff80084526e0>] drm_mm_remove_node+0xc/0xf8
[   12.303827] [<ffffff8008475430>] rockchip_gem_free_object+0x98/0x168
[   12.303854] [<ffffff8008449e80>] drm_gem_object_free+0x2c/0x34
[   12.303878] [<ffffff80084626c4>] drm_gem_dmabuf_release+0x90/0xa4
[   12.303904] [<ffffff80084ee73c>] dma_buf_release+0x64/0x15c
[   12.303929] [<ffffff80081aa8dc>] __fput+0xe0/0x1a4
[   12.303950] [<ffffff80081aa9f8>] ____fput+0xc/0x14
[   12.303977] [<ffffff80080b65ec>] task_work_run+0xa0/0xc0
[   12.304004] [<ffffff8008087f18>] do_notify_resume+0x40/0x54
[   12.304026] [<ffffff80080825e4>] work_pending+0x10/0x14

Change-Id: Id79c052691270553c1c60086f9926f39a5296354
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_gem.c

index 4c44e992b468084f4f8454c1ae104a0c41b0c2bc..58b6ecf8b4ca1d9003218be6550d89a33ea1bfb8 100644 (file)
@@ -52,7 +52,9 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
        ret = iommu_map_sg(private->domain, rk_obj->dma_addr, rk_obj->sgt->sgl,
                           rk_obj->sgt->nents, prot);
        if (ret < rk_obj->base.size) {
-               DRM_ERROR("failed to map buffer: %zd\n", ret);
+               DRM_ERROR("failed to map buffer: size=%zd request_size=%zd\n",
+                         ret, rk_obj->base.size);
+               ret = -ENOMEM;
                goto err_remove_node;
        }