drm/amd/pm: enable runpm support over BACO for SMU13.0.0
authorEvan Quan <evan.quan@amd.com>
Tue, 8 Nov 2022 07:44:46 +0000 (15:44 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Nov 2022 18:28:09 +0000 (13:28 -0500)
Enable SMU13.0.0 runpm support.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org # 6.0.x
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c

index e2fa3b0..f816b1d 100644 (file)
@@ -1388,6 +1388,14 @@ enum smu_cmn2asic_mapping_type {
        CMN2ASIC_MAPPING_WORKLOAD,
 };
 
+enum smu_baco_seq {
+       BACO_SEQ_BACO = 0,
+       BACO_SEQ_MSR,
+       BACO_SEQ_BAMACO,
+       BACO_SEQ_ULPS,
+       BACO_SEQ_COUNT,
+};
+
 #define MSG_MAP(msg, index, valid_in_vf) \
        [SMU_MSG_##msg] = {1, (index), (valid_in_vf)}
 
index a921549..d466db6 100644 (file)
@@ -147,14 +147,6 @@ struct smu_11_5_power_context {
        uint32_t        max_fast_ppt_limit;
 };
 
-enum smu_v11_0_baco_seq {
-       BACO_SEQ_BACO = 0,
-       BACO_SEQ_MSR,
-       BACO_SEQ_BAMACO,
-       BACO_SEQ_ULPS,
-       BACO_SEQ_COUNT,
-};
-
 #if defined(SWSMU_CODE_LAYER_L2) || defined(SWSMU_CODE_LAYER_L3)
 
 int smu_v11_0_init_microcode(struct smu_context *smu);
@@ -257,7 +249,7 @@ int smu_v11_0_baco_enter(struct smu_context *smu);
 int smu_v11_0_baco_exit(struct smu_context *smu);
 
 int smu_v11_0_baco_set_armd3_sequence(struct smu_context *smu,
-                                     enum smu_v11_0_baco_seq baco_seq);
+                                     enum smu_baco_seq baco_seq);
 
 int smu_v11_0_mode1_reset(struct smu_context *smu);
 
index 80fb583..b7f4569 100644 (file)
@@ -124,14 +124,6 @@ struct smu_13_0_power_context {
        enum smu_13_0_power_state power_state;
 };
 
-enum smu_v13_0_baco_seq {
-       BACO_SEQ_BACO = 0,
-       BACO_SEQ_MSR,
-       BACO_SEQ_BAMACO,
-       BACO_SEQ_ULPS,
-       BACO_SEQ_COUNT,
-};
-
 #if defined(SWSMU_CODE_LAYER_L2) || defined(SWSMU_CODE_LAYER_L3)
 
 int smu_v13_0_init_microcode(struct smu_context *smu);
@@ -218,6 +210,9 @@ int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu);
 int smu_v13_0_get_max_sustainable_clocks_by_dc(struct smu_context *smu,
                                               struct pp_smu_nv_clock_table *max_clocks);
 
+int smu_v13_0_baco_set_armd3_sequence(struct smu_context *smu,
+                                     enum smu_baco_seq baco_seq);
+
 bool smu_v13_0_baco_is_support(struct smu_context *smu);
 
 enum smu_baco_state smu_v13_0_baco_get_state(struct smu_context *smu);
index dccbd9f..70b5607 100644 (file)
@@ -1576,7 +1576,7 @@ int smu_v11_0_set_azalia_d3_pme(struct smu_context *smu)
 }
 
 int smu_v11_0_baco_set_armd3_sequence(struct smu_context *smu,
-                                     enum smu_v11_0_baco_seq baco_seq)
+                                     enum smu_baco_seq baco_seq)
 {
        return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ArmD3, baco_seq, NULL);
 }
index 43fb102..89f0f6e 100644 (file)
@@ -2230,6 +2230,15 @@ int smu_v13_0_gfx_ulv_control(struct smu_context *smu,
        return ret;
 }
 
+int smu_v13_0_baco_set_armd3_sequence(struct smu_context *smu,
+                                     enum smu_baco_seq baco_seq)
+{
+       return smu_cmn_send_smc_msg_with_param(smu,
+                                              SMU_MSG_ArmD3,
+                                              baco_seq,
+                                              NULL);
+}
+
 bool smu_v13_0_baco_is_support(struct smu_context *smu)
 {
        struct smu_baco_context *smu_baco = &smu->smu_baco;
index 2952932..f0121d1 100644 (file)
@@ -120,6 +120,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] =
        MSG_MAP(Mode1Reset,                     PPSMC_MSG_Mode1Reset,                  0),
        MSG_MAP(PrepareMp1ForUnload,            PPSMC_MSG_PrepareMp1ForUnload,         0),
        MSG_MAP(DFCstateControl,                PPSMC_MSG_SetExternalClientDfCstateAllow, 0),
+       MSG_MAP(ArmD3,                          PPSMC_MSG_ArmD3,                       0),
 };
 
 static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = {
@@ -1566,6 +1567,31 @@ 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 ? 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;
+
+       if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
+               /* Wait for PMFW handling for the Dstate change */
+               usleep_range(10000, 11000);
+               return smu_v13_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
+       } else {
+               return smu_v13_0_baco_exit(smu);
+       }
+}
+
 static bool smu_v13_0_0_is_mode1_reset_supported(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
@@ -1827,8 +1853,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_baco_enter,
-       .baco_exit = smu_v13_0_baco_exit,
+       .baco_enter = smu_v13_0_0_baco_enter,
+       .baco_exit = smu_v13_0_0_baco_exit,
        .mode1_reset_is_support = smu_v13_0_0_is_mode1_reset_supported,
        .mode1_reset = smu_v13_0_mode1_reset,
        .set_mp1_state = smu_v13_0_0_set_mp1_state,