aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Park <[email protected]>2024-04-17 15:27:01 -0400
committerAlex Deucher <[email protected]>2024-05-20 16:20:24 -0400
commitccb167104a8fea3cca08d1d1d451858436a4b9c8 (patch)
tree19ce2306bd70deea94662e9dcf1bf8c1989bcecf
parentc6bce984b8917b4a2fba17b5f19f1b44cf69d736 (diff)
drm/amd/display: Deallocate DML 2.1 Memory Allocation
[Why] DML 2.1 allocates two types of memory in its ctx structure but does not destroy them, causing memory leak whenever DML 2.1 instance is created and destroyed. [How] Deallocate two instances of allocated memory whenever DML 2.1 is destroyed. Reviewed-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Chris Park <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c6
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.h1
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c2
3 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c
index cb8b2d77a1ac..4e0b7d2d63b2 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c
@@ -107,6 +107,12 @@ bool dml21_create(const struct dc *in_dc, struct dml2_context **dml_ctx, const s
return true;
}
+void dml21_destroy(struct dml2_context *dml2)
+{
+ kfree(dml2->v21.dml_init.dml2_instance);
+ kfree(dml2->v21.mode_programming.programming);
+}
+
static void dml21_calculate_rq_and_dlg_params(const struct dc *dc, struct dc_state *context, struct resource_context *out_new_hw_state,
struct dml2_context *in_ctx, unsigned int pipe_cnt)
{
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.h b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.h
index 6708f7117fbd..b2075b8c363b 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.h
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.h
@@ -27,6 +27,7 @@ struct dml2_context;
* Return: True if dml2 is successfully created, false otherwise.
*/
bool dml21_create(const struct dc *in_dc, struct dml2_context **dml_ctx, const struct dml2_configuration_options *config);
+void dml21_destroy(struct dml2_context *dml2);
void dml21_copy(struct dml2_context *dst_dml_ctx,
struct dml2_context *src_dml_ctx);
bool dml21_create_copy(struct dml2_context **dst_dml_ctx,
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c
index 4be304ebf0b4..22f6a59d8ed2 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c
@@ -782,6 +782,8 @@ void dml2_destroy(struct dml2_context *dml2)
if (!dml2)
return;
+ if (dml2->architecture == dml2_architecture_21)
+ dml21_destroy(dml2);
kfree(dml2);
}