[PATCH 26/39] drm/amd/dal: Memory leak fixes

Harry Wentland harry.wentland at amd.com
Thu Nov 24 02:02:55 UTC 2016


From: Leon Elazar <leon.elazar at amd.com>

[Problem]
DC Hw sequencer wansn't released during the destructor.
DC Context was set to NULL before was actually released.

Change-Id: If2c0caf0cc49d2f023adcdb083ef869d8712326d
Signed-off-by: Leon Elazar <leon.elazar at amd.com>
Acked-by: Harry Wentland <harry.wentland at amd.com>
---
 drivers/gpu/drm/amd/dal/dc/core/dc.c          |  6 +++---
 drivers/gpu/drm/amd/dal/dc/core/dc_resource.c | 10 ++++++++++
 drivers/gpu/drm/amd/dal/dc/inc/resource.h     |  3 +--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c
index 7b11cb0ee737..c42d0d49ca92 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c
@@ -455,8 +455,7 @@ static void destruct(struct core_dc *dc)
 
 	destroy_links(dc);
 
-	if (dc->res_pool)
-		dc->res_pool->funcs->destroy(&dc->res_pool);
+	dc_destroy_resource_pool(dc);
 
 	if (dc->ctx->gpio_service)
 		dal_gpio_service_destroy(&dc->ctx->gpio_service);
@@ -471,8 +470,9 @@ static void destruct(struct core_dc *dc)
 		dal_logger_destroy(&dc->ctx->logger);
 
 	dm_free(dc->current_context);
-	dm_free(dc->ctx);
+	dc->current_context = NULL;
 
+	dm_free(dc->ctx);
 	dc->ctx = NULL;
 }
 
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c b/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
index a9b2784f8168..bd53d27e5414 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
@@ -98,6 +98,16 @@ struct resource_pool *dc_create_resource_pool(
 	return false;
 }
 
+void dc_destroy_resource_pool(struct core_dc *dc)
+{
+	if (dc) {
+		if (dc->res_pool)
+			dc->res_pool->funcs->destroy(&dc->res_pool);
+
+		if (dc->hwseq)
+			dm_free(dc->hwseq);
+	}
+}
 
 static void update_num_audio(
 	const struct resource_straps *straps,
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/resource.h b/drivers/gpu/drm/amd/dal/dc/inc/resource.h
index 33fb7d98b294..dae94706e5da 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/resource.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/resource.h
@@ -76,8 +76,7 @@ struct resource_pool *dc_create_resource_pool(
 				enum dce_version dc_version,
 				struct hw_asic_id asic_id);
 
-void dc_destroy_resource_pool(struct resource_pool **pool,
-				enum dce_version dc_version);
+void dc_destroy_resource_pool(struct core_dc *dc);
 
 enum dc_status resource_map_pool_resources(
 		const struct core_dc *dc,
-- 
2.10.1



More information about the amd-gfx mailing list