Commit 88ed9fb7 authored by Jun Lei's avatar Jun Lei Committed by Alex Deucher

drm/amd/display: fix memory leak in resource pools

[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: default avatarJun Lei <Jun.Lei@amd.com>
Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5e174ce6
...@@ -689,7 +689,9 @@ static void destruct(struct dce110_resource_pool *pool) ...@@ -689,7 +689,9 @@ static void destruct(struct dce110_resource_pool *pool)
kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
pool->base.timing_generators[i] = NULL; pool->base.timing_generators[i] = NULL;
} }
}
for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
if (pool->base.engines[i] != NULL) if (pool->base.engines[i] != NULL)
dce110_engine_destroy(&pool->base.engines[i]); dce110_engine_destroy(&pool->base.engines[i]);
if (pool->base.hw_i2cs[i] != NULL) { if (pool->base.hw_i2cs[i] != NULL) {
......
...@@ -719,7 +719,9 @@ static void destruct(struct dce110_resource_pool *pool) ...@@ -719,7 +719,9 @@ static void destruct(struct dce110_resource_pool *pool)
kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
pool->base.timing_generators[i] = NULL; pool->base.timing_generators[i] = NULL;
} }
}
for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
if (pool->base.engines[i] != NULL) if (pool->base.engines[i] != NULL)
dce110_engine_destroy(&pool->base.engines[i]); dce110_engine_destroy(&pool->base.engines[i]);
if (pool->base.hw_i2cs[i] != NULL) { if (pool->base.hw_i2cs[i] != NULL) {
......
...@@ -693,9 +693,6 @@ static void destruct(struct dce110_resource_pool *pool) ...@@ -693,9 +693,6 @@ static void destruct(struct dce110_resource_pool *pool)
if (pool->base.opps[i] != NULL) if (pool->base.opps[i] != NULL)
dce110_opp_destroy(&pool->base.opps[i]); 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) if (pool->base.transforms[i] != NULL)
dce112_transform_destroy(&pool->base.transforms[i]); dce112_transform_destroy(&pool->base.transforms[i]);
...@@ -711,6 +708,11 @@ static void destruct(struct dce110_resource_pool *pool) ...@@ -711,6 +708,11 @@ static void destruct(struct dce110_resource_pool *pool)
kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
pool->base.timing_generators[i] = NULL; 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) { if (pool->base.hw_i2cs[i] != NULL) {
kfree(pool->base.hw_i2cs[i]); kfree(pool->base.hw_i2cs[i]);
pool->base.hw_i2cs[i] = NULL; pool->base.hw_i2cs[i] = NULL;
......
...@@ -533,7 +533,9 @@ static void destruct(struct dce110_resource_pool *pool) ...@@ -533,7 +533,9 @@ static void destruct(struct dce110_resource_pool *pool)
kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
pool->base.timing_generators[i] = NULL; pool->base.timing_generators[i] = NULL;
} }
}
for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
if (pool->base.engines[i] != NULL) if (pool->base.engines[i] != NULL)
dce110_engine_destroy(&pool->base.engines[i]); dce110_engine_destroy(&pool->base.engines[i]);
if (pool->base.hw_i2cs[i] != NULL) { if (pool->base.hw_i2cs[i] != NULL) {
......
...@@ -738,7 +738,9 @@ static void destruct(struct dce110_resource_pool *pool) ...@@ -738,7 +738,9 @@ static void destruct(struct dce110_resource_pool *pool)
kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
pool->base.timing_generators[i] = NULL; pool->base.timing_generators[i] = NULL;
} }
}
for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
if (pool->base.engines[i] != NULL) if (pool->base.engines[i] != NULL)
dce110_engine_destroy(&pool->base.engines[i]); dce110_engine_destroy(&pool->base.engines[i]);
if (pool->base.hw_i2cs[i] != NULL) { if (pool->base.hw_i2cs[i] != NULL) {
......
...@@ -896,7 +896,9 @@ static void destruct(struct dcn10_resource_pool *pool) ...@@ -896,7 +896,9 @@ static void destruct(struct dcn10_resource_pool *pool)
kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
pool->base.timing_generators[i] = NULL; pool->base.timing_generators[i] = NULL;
} }
}
for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
if (pool->base.engines[i] != NULL) if (pool->base.engines[i] != NULL)
pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]); pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]);
if (pool->base.hw_i2cs[i] != NULL) { if (pool->base.hw_i2cs[i] != NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment