diff mbox

[v2,7/7] drm/rockchip: Call drm_gem_object_release() to destroy GEM base

Message ID 1486456773-19233-1-git-send-email-mark.yao@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

yao mark Feb. 7, 2017, 8:39 a.m. UTC
From: Tomasz Figa <tfiga@chromium.org>

When converting the driver to use shmem-backed GEMs for IOMMU-enabled
systems, we forgot to add calls to drm_gem_object_release(), which gave
us a quite nice memory leak. This patch adds the missing calls.

Fixes: f11d5f0 ("FROMLIST: drm/rockchip: Do not use DMA mapping API if
attached to IOMMU domain")

TEST=while true; do backlight_dbus_tool --set --percent=0 && sleep 8 &&
 backlight_dbus_tool --set --percent=100 && sleep 3 ; done

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/385456
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Thierry Reding Feb. 7, 2017, 12:37 p.m. UTC | #1
On Tue, Feb 07, 2017 at 04:39:33PM +0800, Mark Yao wrote:
> From: Tomasz Figa <tfiga@chromium.org>
> 
> When converting the driver to use shmem-backed GEMs for IOMMU-enabled
> systems, we forgot to add calls to drm_gem_object_release(), which gave
> us a quite nice memory leak. This patch adds the missing calls.
> 
> Fixes: f11d5f0 ("FROMLIST: drm/rockchip: Do not use DMA mapping API if
> attached to IOMMU domain")
> 
> TEST=while true; do backlight_dbus_tool --set --percent=0 && sleep 8 &&
>  backlight_dbus_tool --set --percent=100 && sleep 3 ; done

Ugh... please clean up your commit messages before posting to the
mailing list. FROMLIST: patches clearly aren't what will be merged
upstream and the SHA1 isn't going to match, so nobody but you will
find this anywhere.

> Signed-off-by: Tomasz Figa <tfiga@chromium.org>
> Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
> Reviewed-on: https://chromium-review.googlesource.com/385456

This is also present in some of the patches you posted, but it's not
typical for these to be included in upstream patches because usually
by the time patches from some gerrit make it to upstream, upstream
can have diverged significantly enough for the review to no longer
apply.

Thierry
Tomasz Figa Feb. 7, 2017, 1:05 p.m. UTC | #2
Hi Mark,

On Tue, Feb 7, 2017 at 9:37 PM, Thierry Reding <thierry.reding@gmail.com> wrote:
> On Tue, Feb 07, 2017 at 04:39:33PM +0800, Mark Yao wrote:
>> From: Tomasz Figa <tfiga@chromium.org>
>>
>> When converting the driver to use shmem-backed GEMs for IOMMU-enabled
>> systems, we forgot to add calls to drm_gem_object_release(), which gave
>> us a quite nice memory leak. This patch adds the missing calls.
>>
>> Fixes: f11d5f0 ("FROMLIST: drm/rockchip: Do not use DMA mapping API if
>> attached to IOMMU domain")

Since the patch being fixed is also a part of this series, the fix
could be just squashed directly (with sign-off lists merged). Same for
patch 6/7.

Best regards,
Tomasz
diff mbox

Patch

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 1769146..df9e570 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -301,6 +301,12 @@  int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	return rockchip_drm_gem_object_mmap(obj, vma);
 }
 
+static void rockchip_gem_release_object(struct rockchip_gem_object *rk_obj)
+{
+	drm_gem_object_release(&rk_obj->base);
+	kfree(rk_obj);
+}
+
 struct rockchip_gem_object *
 	rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
 				   bool alloc_kmap)
@@ -326,7 +332,7 @@  struct rockchip_gem_object *
 	return rk_obj;
 
 err_free_rk_obj:
-	kfree(rk_obj);
+	rockchip_gem_release_object(rk_obj);
 	return ERR_PTR(ret);
 }
 
@@ -338,13 +344,11 @@  void rockchip_gem_free_object(struct drm_gem_object *obj)
 {
 	struct rockchip_gem_object *rk_obj;
 
-	drm_gem_free_mmap_offset(obj);
-
 	rk_obj = to_rockchip_obj(obj);
 
 	rockchip_gem_free_buf(rk_obj);
 
-	kfree(rk_obj);
+	rockchip_gem_release_object(rk_obj);
 }
 
 /*