]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Deallocate DML 2.1 Memory Allocation
authorChris Park <chris.park@amd.com>
Wed, 17 Apr 2024 19:27:01 +0000 (15:27 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 20 May 2024 20:20:24 +0000 (16:20 -0400)
[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 <Rodrigo.Siqueira@amd.com>
Signed-off-by: Chris Park <chris.park@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.h
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c

index cb8b2d77a1ac6bad40db7c3efce7c5db112d4bbf..4e0b7d2d63b296bb67b09644ec7411d324bb683c 100644 (file)
@@ -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)
 {
index 6708f7117fbd9a288ac18276d4becb7834dabda6..b2075b8c363b5cd4e72baf522c9b3a1811c20938 100644 (file)
@@ -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,
index 4be304ebf0b4c17461da5239185cafda43d3fa5a..22f6a59d8ed2be51425e971e1b468b67c61cf96d 100644 (file)
@@ -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);
 }