drm/amd/pm: Move some functions to smu_v13_0.c as generic code
authorMa Jun <Jun.Ma2@amd.com>
Fri, 3 Nov 2023 01:48:06 +0000 (09:48 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Nov 2023 14:29:54 +0000 (09:29 -0500)
Use generic functions and remove the duplicate code

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c

index cf1b84060bc3da46c12ace3b878b03144288afd1..b446f860baf684ab0545c99a84f2067299ce97d3 100644 (file)
@@ -2283,22 +2283,40 @@ int smu_v13_0_baco_set_state(struct smu_context *smu,
 
 int smu_v13_0_baco_enter(struct smu_context *smu)
 {
-       int ret = 0;
-
-       ret = smu_v13_0_baco_set_state(smu,
-                                      SMU_BACO_STATE_ENTER);
-       if (ret)
-               return ret;
+       struct smu_baco_context *smu_baco = &smu->smu_baco;
+       struct amdgpu_device *adev = smu->adev;
+       int ret;
 
-       msleep(10);
+       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
+               return smu_v13_0_baco_set_armd3_sequence(smu,
+                               (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
+                                       BACO_SEQ_BAMACO : BACO_SEQ_BACO);
+       } else {
+               ret = smu_v13_0_baco_set_state(smu, SMU_BACO_STATE_ENTER);
+               if (!ret)
+                       usleep_range(10000, 11000);
 
-       return ret;
+               return ret;
+       }
 }
 
 int smu_v13_0_baco_exit(struct smu_context *smu)
 {
-       return smu_v13_0_baco_set_state(smu,
-                                       SMU_BACO_STATE_EXIT);
+       struct amdgpu_device *adev = smu->adev;
+       int ret;
+
+       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
+               /* Wait for PMFW handling for the Dstate change */
+               usleep_range(10000, 11000);
+               ret = smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
+       } else {
+               ret = smu_v13_0_baco_set_state(smu, SMU_BACO_STATE_EXIT);
+       }
+
+       if (!ret)
+               adev->gfx.is_poweron = false;
+
+       return ret;
 }
 
 int smu_v13_0_set_gfx_power_up_by_imu(struct smu_context *smu)
index 82c4e1f1c6f075d09dbb9e407e69a8405a9e8c5b..a4debd7ab8bd0a2d94083ec89fb39a95c82b7833 100644 (file)
@@ -2558,38 +2558,6 @@ static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu,
                                               NULL);
 }
 
-static int smu_v13_0_0_baco_enter(struct smu_context *smu)
-{
-       struct smu_baco_context *smu_baco = &smu->smu_baco;
-       struct amdgpu_device *adev = smu->adev;
-
-       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))
-               return smu_v13_0_baco_set_armd3_sequence(smu,
-                               (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
-                                       BACO_SEQ_BAMACO : BACO_SEQ_BACO);
-       else
-               return smu_v13_0_baco_enter(smu);
-}
-
-static int smu_v13_0_0_baco_exit(struct smu_context *smu)
-{
-       struct amdgpu_device *adev = smu->adev;
-       int ret;
-
-       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
-               /* Wait for PMFW handling for the Dstate change */
-               usleep_range(10000, 11000);
-               ret = smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
-       } else {
-               ret = smu_v13_0_baco_exit(smu);
-       }
-
-       if (!ret)
-               adev->gfx.is_poweron = false;
-
-       return ret;
-}
-
 static bool smu_v13_0_0_is_mode1_reset_supported(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
@@ -3037,8 +3005,8 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
        .baco_is_support = smu_v13_0_baco_is_support,
        .baco_get_state = smu_v13_0_baco_get_state,
        .baco_set_state = smu_v13_0_baco_set_state,
-       .baco_enter = smu_v13_0_0_baco_enter,
-       .baco_exit = smu_v13_0_0_baco_exit,
+       .baco_enter = smu_v13_0_baco_enter,
+       .baco_exit = smu_v13_0_baco_exit,
        .mode1_reset_is_support = smu_v13_0_0_is_mode1_reset_supported,
        .mode1_reset = smu_v13_0_0_mode1_reset,
        .mode2_reset = smu_v13_0_0_mode2_reset,
index 81eafed76045e97ac9f5dfdb92c7412f082ea496..f5596f031d00c376dcfc85a067668b8ba33e7921 100644 (file)
@@ -2515,38 +2515,6 @@ static int smu_v13_0_7_set_mp1_state(struct smu_context *smu,
        return ret;
 }
 
-static int smu_v13_0_7_baco_enter(struct smu_context *smu)
-{
-       struct smu_baco_context *smu_baco = &smu->smu_baco;
-       struct amdgpu_device *adev = smu->adev;
-
-       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))
-               return smu_v13_0_baco_set_armd3_sequence(smu,
-                               (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
-                                       BACO_SEQ_BAMACO : BACO_SEQ_BACO);
-       else
-               return smu_v13_0_baco_enter(smu);
-}
-
-static int smu_v13_0_7_baco_exit(struct smu_context *smu)
-{
-       struct amdgpu_device *adev = smu->adev;
-       int ret;
-
-       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
-               /* Wait for PMFW handling for the Dstate change */
-               usleep_range(10000, 11000);
-               ret = smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
-       } else {
-               ret = smu_v13_0_baco_exit(smu);
-       }
-
-       if (!ret)
-               adev->gfx.is_poweron = false;
-
-       return ret;
-}
-
 static bool smu_v13_0_7_is_mode1_reset_supported(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
@@ -2628,8 +2596,8 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = {
        .baco_is_support = smu_v13_0_baco_is_support,
        .baco_get_state = smu_v13_0_baco_get_state,
        .baco_set_state = smu_v13_0_baco_set_state,
-       .baco_enter = smu_v13_0_7_baco_enter,
-       .baco_exit = smu_v13_0_7_baco_exit,
+       .baco_enter = smu_v13_0_baco_enter,
+       .baco_exit = smu_v13_0_baco_exit,
        .mode1_reset_is_support = smu_v13_0_7_is_mode1_reset_supported,
        .mode1_reset = smu_v13_0_mode1_reset,
        .set_mp1_state = smu_v13_0_7_set_mp1_state,