From: Tomasz Figa Date: Wed, 14 Sep 2016 11:50:29 +0000 (+0900) Subject: CHROMIUM: drm/rockchip: Call drm_gem_object_release() to destroy GEM base X-Git-Tag: firefly_0821_release~1139 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=31bae78bcce53079d6fab80631ad15259bf5dc51;p=firefly-linux-kernel-4.4.55.git CHROMIUM: drm/rockchip: Call drm_gem_object_release() to destroy GEM base 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") BUG=chrome-os-partner:57158 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 Reviewed-on: https://chromium-review.googlesource.com/385456 Reviewed-by: Douglas Anderson Reviewed-by: Daniel Kurtz Conflicts: drivers/gpu/drm/rockchip/rockchip_drm_gem.c Change-Id: I3c7b21ed22cfb38f512150f76fced3b0cc2b296d Signed-off-by: Randy Li --- diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 9d544d1ba547..c1cf3dff8e24 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -313,6 +313,12 @@ rockchip_gem_alloc_object(struct drm_device *drm, unsigned int size) return rk_obj; } +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) @@ -331,7 +337,7 @@ rockchip_gem_create_object(struct drm_device *drm, unsigned int size, return rk_obj; err_free_rk_obj: - kfree(rk_obj); + rockchip_gem_release_object(rk_obj); return ERR_PTR(ret); } @@ -345,8 +351,6 @@ void rockchip_gem_free_object(struct drm_gem_object *obj) struct rockchip_drm_private *private = drm->dev_private; struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); - drm_gem_free_mmap_offset(obj); - if (obj->import_attach) { if (private->domain) { rockchip_gem_iommu_unmap(rk_obj); @@ -363,7 +367,7 @@ void rockchip_gem_free_object(struct drm_gem_object *obj) drm_fence_signal_and_put(&rk_obj->acquire_fence); #endif - kfree(rk_obj); + rockchip_gem_release_object(rk_obj); } /* @@ -806,7 +810,7 @@ rockchip_gem_prime_import_sg_table(struct drm_device *drm, return &rk_obj->base; err_free_rk_obj: - kfree(rk_obj); + rockchip_gem_release_object(rk_obj); return ERR_PTR(ret); }