All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qingqing Zhuo <qingqing.zhuo@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Lang Yu <Lang.Yu@amd.com>,
	Eryk.Brol@amd.com, Sunpeng.Li@amd.com, Harry.Wentland@amd.com,
	qingqing.zhuo@amd.com, Rodrigo.Siqueira@amd.com,
	roman.li@amd.com, Anson.Jacob@amd.com, Aurabindo.Pillai@amd.com,
	Bhawanpreet.Lakha@amd.com,
	Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>,
	bindu.r@amd.com
Subject: [PATCH 07/15] drm/amd/display: Fix potential memory leak in DMUB hw_init
Date: Fri, 21 May 2021 13:36:38 -0400	[thread overview]
Message-ID: <20210521173646.1140586-8-qingqing.zhuo@amd.com> (raw)
In-Reply-To: <20210521173646.1140586-1-qingqing.zhuo@amd.com>

From: Roman Li <roman.li@amd.com>

[Why]
On resume we perform DMUB hw_init which allocates memory:
dm_resume->dm_dmub_hw_init->dc_dmub_srv_create->kzalloc
That results in memory leak in suspend/resume scenarios.

[How]
Allocate memory for the DC wrapper to DMUB only if it was not
allocated before.
No need to reallocate it on suspend/resume.

Signed-off-by: Lang Yu <Lang.Yu@amd.com>
Signed-off-by: Roman Li <roman.li@amd.com>
Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 9be4ebb5fac4..c582c424460a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -981,7 +981,8 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
 		abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu);
 	}
 
-	adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv);
+	if (!adev->dm.dc->ctx->dmub_srv)
+		adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv);
 	if (!adev->dm.dc->ctx->dmub_srv) {
 		DRM_ERROR("Couldn't allocate DC DMUB server!\n");
 		return -ENOMEM;
@@ -2003,7 +2004,6 @@ static int dm_suspend(void *handle)
 
 	amdgpu_dm_irq_suspend(adev);
 
-
 	dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
 
 	return 0;
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2021-05-21 17:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 17:36 [PATCH 00/15] DC Patches May 24th, 2021 Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 01/15] drm/amd/display: Added support for individual control for multiple back-light instances Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 02/15] drm/amd/display: disable desktop VRR when using older flip model Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 03/15] drm/amd/display: Retrieve DSC Branch Decoder Caps Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 04/15] drm/amd/display: Update DP link configuration Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 05/15] drm/amd/display: Expand DP module clock recovery API Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 06/15] drm/amd/display: Remove redundant safeguards for dmub-srv destroy() Qingqing Zhuo
2021-05-21 17:36 ` Qingqing Zhuo [this message]
2021-05-21 17:36 ` [PATCH 08/15] drm/amd/display: Implement INBOX0 usage in driver Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 09/15] drm/amd/display: add exit training mode and update channel coding in LT Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 10/15] drm/amd/display: isolate 8b 10b link training sequence into its own function Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 11/15] drm/amd/display: Add Log for SST DSC Determination Policy Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 12/15] drm/amd/display: Refactor " Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 13/15] drm/amd/display: fix odm scaling Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 14/15] drm/amd/display: 3.2.137 Qingqing Zhuo
2021-05-21 17:36 ` [PATCH 15/15] Revert "drm/amd/display: Refactor and add visual confirm for HW Flip Queue" Qingqing Zhuo
2021-05-26 14:29 ` [PATCH 00/15] DC Patches May 24th, 2021 Wheeler, Daniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210521173646.1140586-8-qingqing.zhuo@amd.com \
    --to=qingqing.zhuo@amd.com \
    --cc=Anson.Jacob@amd.com \
    --cc=Aurabindo.Pillai@amd.com \
    --cc=Bhawanpreet.Lakha@amd.com \
    --cc=Eryk.Brol@amd.com \
    --cc=Harry.Wentland@amd.com \
    --cc=Lang.Yu@amd.com \
    --cc=Nicholas.Kazlauskas@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Sunpeng.Li@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bindu.r@amd.com \
    --cc=roman.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.