<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div dir="ltr">
<div></div>
<div>
<div dir="ltr">Reviewed-by: Yang Wang <kevinyang.wang@amd.com></div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Best Regards,</div>
<div dir="ltr">Kevin</div>
<div id="mail-editor-reference-message-container" class="ms-outlook-mobile-reference-message">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif"><b>From:</b> Ma, Jun <Jun.Ma2@amd.com><br>
<b>Sent:</b> Monday, November 6, 2023 09:59<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com><br>
<b>Cc:</b> Ma, Jun <Jun.Ma2@amd.com><br>
<b>Subject:</b> [PATCH v2] drm/amd/pm: Move some functions to smu_v13_0.c as generic code
<div> </div>
</font></div>
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Use generic functions and remove the duplicate code<br>
<br>
Signed-off-by: Ma Jun <Jun.Ma2@amd.com><br>
---<br>
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 38 ++++++++++++++-----<br>
.../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 36 +-----------------<br>
.../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 36 +-----------------<br>
3 files changed, 32 insertions(+), 78 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
index 281c3cb707a5..438fd5d3ede2 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
@@ -2282,22 +2282,40 @@ int smu_v13_0_baco_set_state(struct smu_context *smu,<br>
<br>
int smu_v13_0_baco_enter(struct smu_context *smu)<br>
{<br>
- int ret = 0;<br>
-<br>
- ret = smu_v13_0_baco_set_state(smu,<br>
- SMU_BACO_STATE_ENTER);<br>
- if (ret)<br>
- return ret;<br>
+ struct smu_baco_context *smu_baco = &smu->smu_baco;<br>
+ struct amdgpu_device *adev = smu->adev;<br>
+ int ret;<br>
<br>
- msleep(10);<br>
+ if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {<br>
+ return smu_v13_0_baco_set_armd3_sequence(smu,<br>
+ (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?<br>
+ BACO_SEQ_BAMACO : BACO_SEQ_BACO);<br>
+ } else {<br>
+ ret = smu_v13_0_baco_set_state(smu, SMU_BACO_STATE_ENTER);<br>
+ if (!ret)<br>
+ usleep_range(10000, 11000);<br>
<br>
- return ret;<br>
+ return ret;<br>
+ }<br>
}<br>
<br>
int smu_v13_0_baco_exit(struct smu_context *smu)<br>
{<br>
- return smu_v13_0_baco_set_state(smu,<br>
- SMU_BACO_STATE_EXIT);<br>
+ struct amdgpu_device *adev = smu->adev;<br>
+ int ret;<br>
+<br>
+ if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {<br>
+ /* Wait for PMFW handling for the Dstate change */<br>
+ usleep_range(10000, 11000);<br>
+ ret = smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);<br>
+ } else {<br>
+ ret = smu_v13_0_baco_set_state(smu, SMU_BACO_STATE_EXIT);<br>
+ }<br>
+<br>
+ if (!ret)<br>
+ adev->gfx.is_poweron = false;<br>
+<br>
+ return ret;<br>
}<br>
<br>
int smu_v13_0_set_gfx_power_up_by_imu(struct smu_context *smu)<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c<br>
index a94b57e7c509..9be41a2b8659 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c<br>
@@ -2558,38 +2558,6 @@ static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu,<br>
NULL);<br>
}<br>
<br>
-static int smu_v13_0_0_baco_enter(struct smu_context *smu)<br>
-{<br>
- struct smu_baco_context *smu_baco = &smu->smu_baco;<br>
- struct amdgpu_device *adev = smu->adev;<br>
-<br>
- if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))<br>
- return smu_v13_0_baco_set_armd3_sequence(smu,<br>
- (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?<br>
- BACO_SEQ_BAMACO : BACO_SEQ_BACO);<br>
- else<br>
- return smu_v13_0_baco_enter(smu);<br>
-}<br>
-<br>
-static int smu_v13_0_0_baco_exit(struct smu_context *smu)<br>
-{<br>
- struct amdgpu_device *adev = smu->adev;<br>
- int ret;<br>
-<br>
- if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {<br>
- /* Wait for PMFW handling for the Dstate change */<br>
- usleep_range(10000, 11000);<br>
- ret = smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);<br>
- } else {<br>
- ret = smu_v13_0_baco_exit(smu);<br>
- }<br>
-<br>
- if (!ret)<br>
- adev->gfx.is_poweron = false;<br>
-<br>
- return ret;<br>
-}<br>
-<br>
static bool smu_v13_0_0_is_mode1_reset_supported(struct smu_context *smu)<br>
{<br>
struct amdgpu_device *adev = smu->adev;<br>
@@ -3036,8 +3004,8 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {<br>
.baco_is_support = smu_v13_0_baco_is_support,<br>
.baco_get_state = smu_v13_0_baco_get_state,<br>
.baco_set_state = smu_v13_0_baco_set_state,<br>
- .baco_enter = smu_v13_0_0_baco_enter,<br>
- .baco_exit = smu_v13_0_0_baco_exit,<br>
+ .baco_enter = smu_v13_0_baco_enter,<br>
+ .baco_exit = smu_v13_0_baco_exit,<br>
.mode1_reset_is_support = smu_v13_0_0_is_mode1_reset_supported,<br>
.mode1_reset = smu_v13_0_0_mode1_reset,<br>
.mode2_reset = smu_v13_0_0_mode2_reset,<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c<br>
index 81eafed76045..f5596f031d00 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c<br>
@@ -2515,38 +2515,6 @@ static int smu_v13_0_7_set_mp1_state(struct smu_context *smu,<br>
return ret;<br>
}<br>
<br>
-static int smu_v13_0_7_baco_enter(struct smu_context *smu)<br>
-{<br>
- struct smu_baco_context *smu_baco = &smu->smu_baco;<br>
- struct amdgpu_device *adev = smu->adev;<br>
-<br>
- if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))<br>
- return smu_v13_0_baco_set_armd3_sequence(smu,<br>
- (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?<br>
- BACO_SEQ_BAMACO : BACO_SEQ_BACO);<br>
- else<br>
- return smu_v13_0_baco_enter(smu);<br>
-}<br>
-<br>
-static int smu_v13_0_7_baco_exit(struct smu_context *smu)<br>
-{<br>
- struct amdgpu_device *adev = smu->adev;<br>
- int ret;<br>
-<br>
- if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {<br>
- /* Wait for PMFW handling for the Dstate change */<br>
- usleep_range(10000, 11000);<br>
- ret = smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);<br>
- } else {<br>
- ret = smu_v13_0_baco_exit(smu);<br>
- }<br>
-<br>
- if (!ret)<br>
- adev->gfx.is_poweron = false;<br>
-<br>
- return ret;<br>
-}<br>
-<br>
static bool smu_v13_0_7_is_mode1_reset_supported(struct smu_context *smu)<br>
{<br>
struct amdgpu_device *adev = smu->adev;<br>
@@ -2628,8 +2596,8 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = {<br>
.baco_is_support = smu_v13_0_baco_is_support,<br>
.baco_get_state = smu_v13_0_baco_get_state,<br>
.baco_set_state = smu_v13_0_baco_set_state,<br>
- .baco_enter = smu_v13_0_7_baco_enter,<br>
- .baco_exit = smu_v13_0_7_baco_exit,<br>
+ .baco_enter = smu_v13_0_baco_enter,<br>
+ .baco_exit = smu_v13_0_baco_exit,<br>
.mode1_reset_is_support = smu_v13_0_7_is_mode1_reset_supported,<br>
.mode1_reset = smu_v13_0_mode1_reset,<br>
.set_mp1_state = smu_v13_0_7_set_mp1_state,<br>
-- <br>
2.34.1<br>
<br>
</div>
</span></font></div>
</div>
</div>
</div>
</body>
</html>