drm/amd/display: fix memory leak in resource pools
authorJun Lei <Jun.Lei@amd.com>
Tue, 18 Sep 2018 13:38:20 +0000 (09:38 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 9 Oct 2018 22:03:31 +0000 (17:03 -0500)
[why]
ddc engines were recently changed to be independently tracked
from pipe count.  the change was reflected in resource constructor
but not in destructor.  this manifests as a memory leak when
pipe harvesting is enabled, since not all constructed ddc engines
are freed

[how]
make destructor symmetric with constructor for all dcX_resource

Signed-off-by: Jun Lei <Jun.Lei@amd.com>
Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c

index 5b75460525ac41d1354c305d63daf061d84dba2d..14754a87156c53fe70269aaa9f883b4074bdfd79 100644 (file)
@@ -689,7 +689,9 @@ static void destruct(struct dce110_resource_pool *pool)
                        kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
                        pool->base.timing_generators[i] = NULL;
                }
+       }
 
+       for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
                if (pool->base.engines[i] != NULL)
                        dce110_engine_destroy(&pool->base.engines[i]);
                if (pool->base.hw_i2cs[i] != NULL) {
index 4607a6af445162b75964421373fdb99061b55184..de190935f0a456000cbabbdcc723b7c1a43667b7 100644 (file)
@@ -719,7 +719,9 @@ static void destruct(struct dce110_resource_pool *pool)
                        kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
                        pool->base.timing_generators[i] = NULL;
                }
+       }
 
+       for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
                if (pool->base.engines[i] != NULL)
                        dce110_engine_destroy(&pool->base.engines[i]);
                if (pool->base.hw_i2cs[i] != NULL) {
index 8b5a2696a4e82926ee3d330d3f1fc7612b0ad30f..3ce79c208ddfb8297766e9453da3097a78e022f6 100644 (file)
@@ -693,9 +693,6 @@ static void destruct(struct dce110_resource_pool *pool)
                if (pool->base.opps[i] != NULL)
                        dce110_opp_destroy(&pool->base.opps[i]);
 
-               if (pool->base.engines[i] != NULL)
-                       dce110_engine_destroy(&pool->base.engines[i]);
-
                if (pool->base.transforms[i] != NULL)
                        dce112_transform_destroy(&pool->base.transforms[i]);
 
@@ -711,6 +708,11 @@ static void destruct(struct dce110_resource_pool *pool)
                        kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
                        pool->base.timing_generators[i] = NULL;
                }
+       }
+
+       for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
+               if (pool->base.engines[i] != NULL)
+                       dce110_engine_destroy(&pool->base.engines[i]);
                if (pool->base.hw_i2cs[i] != NULL) {
                        kfree(pool->base.hw_i2cs[i]);
                        pool->base.hw_i2cs[i] = NULL;
index 53a7a2f2ef76dba0f26bb0d539a48d444113db9d..79ab5f9f9115640fa85b4b079e8887b0f3a61232 100644 (file)
@@ -533,7 +533,9 @@ static void destruct(struct dce110_resource_pool *pool)
                        kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
                        pool->base.timing_generators[i] = NULL;
                }
+       }
 
+       for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
                if (pool->base.engines[i] != NULL)
                        dce110_engine_destroy(&pool->base.engines[i]);
                if (pool->base.hw_i2cs[i] != NULL) {
index 79e5c5c0de5604ddc1714068c8b346f1f0c17bb8..d68f951f98694b5e68c27152e7728d7c549ffab8 100644 (file)
@@ -738,7 +738,9 @@ static void destruct(struct dce110_resource_pool *pool)
                        kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
                        pool->base.timing_generators[i] = NULL;
                }
+       }
 
+       for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
                if (pool->base.engines[i] != NULL)
                        dce110_engine_destroy(&pool->base.engines[i]);
                if (pool->base.hw_i2cs[i] != NULL) {
index affadd7bfe8d1cc7c71c7e520af89bef3274a6ff..563847c2dd42426155acade5ee7416f36a2dee0a 100644 (file)
@@ -896,7 +896,9 @@ static void destruct(struct dcn10_resource_pool *pool)
                        kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
                        pool->base.timing_generators[i] = NULL;
                }
+       }
 
+       for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
                if (pool->base.engines[i] != NULL)
                        pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]);
                if (pool->base.hw_i2cs[i] != NULL) {