From: Mark Yao <mark.yao@rock-chips.com>
To: David Airlie <airlied@linux.ie>, Heiko Stuebner <heiko@sntech.de>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/7] drm/rockchip: gem: fixup iommu_map_sg error path
Date: Tue, 7 Feb 2017 16:35:39 +0800 [thread overview]
Message-ID: <1486456542-18675-5-git-send-email-mark.yao@rock-chips.com> (raw)
In-Reply-To: <1486456542-18675-1-git-send-email-mark.yao@rock-chips.com>
The return value of iommu_map_sg is size_t, it's unsigned,
So check ret < 0 is wrong.
And 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 | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 8d27965..cc48673 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -44,8 +44,10 @@ 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 < 0) {
- DRM_ERROR("failed to map buffer: %zd\n", ret);
+ if (ret < rk_obj->base.size) {
+ DRM_ERROR("failed to map buffer: size=%zd request_size=%zd\n",
+ ret, rk_obj->base.size);
+ ret = -ENOMEM;
goto err_remove_node;
}
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-02-07 8:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 8:35 [PATCH v2 0/7] drm/rockchip: switch to drm_mm for support arm64 iommu Mark Yao
2017-02-07 8:35 ` [PATCH v2 1/7] drm/rockchip: Do not use DMA mapping API if attached to IOMMU domain Mark Yao
2017-02-07 8:35 ` [PATCH v2 2/7] drm/rockchip: Use common IOMMU API to attach devices Mark Yao
2017-02-07 8:35 ` [PATCH v2 3/7] drm/rockchip: gem: add mutex lock for drm mm Mark Yao
2017-02-07 12:19 ` Thierry Reding
2017-02-08 0:28 ` Mark yao
2017-02-07 8:35 ` Mark Yao [this message]
2017-02-07 8:39 ` [PATCH v2 6/7] drm/rockchip: Respect page offset in IOMMU mmap Mark Yao
2017-02-07 12:33 ` Thierry Reding
2017-02-07 8:39 ` [PATCH v2 7/7] drm/rockchip: Call drm_gem_object_release() to destroy GEM base Mark Yao
2017-02-07 12:37 ` Thierry Reding
2017-02-07 13:05 ` Tomasz Figa
2017-02-07 12:38 ` [PATCH v2 0/7] drm/rockchip: switch to drm_mm for support arm64 iommu Thierry Reding
2017-02-08 1:15 ` Mark yao
2017-02-08 23:36 ` Heiko Stübner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486456542-18675-5-git-send-email-mark.yao@rock-chips.com \
--to=mark.yao@rock-chips.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox