drm/amd/powerplay: enable df cstate control on powerplay routine
Subsystems (2)
PATCH 1/2 drm/amd/powerplay: enable df cstate control on powerplay routine
Currently this is only supported on Vega20 with 40.50 and later SMC firmware.
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 6 ++++++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++++++++++++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 19 +++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 + .../gpu/drm/amd/powerplay/inc/vega20_ppsmc.h | 3 ++- 5 files changed, 46 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +6 -0
@@ -179,6 +179,11 @@ enum pp_mp1_state { PP_MP1_STATE_RESET, }; +enum pp_df_cstate { +DF_CSTATE_DISALLOW =0 , +DF_CSTATE_ALLOW , +}; +#define PP_GROUP_MASK 0xF0000000#define PP_GROUP_SHIFT 28
@@ -312,6 +317,7 @@ struct amd_pm_funcs {int (*get_ppfeature_status)(void *handle,char *buf);int (*set_ppfeature_status)(void *handle,uint64_t ppfeature_masks);int (*asic_reset_mode_2)(void *handle); + int (*set_df_cstate)(void *handle, enum pp_df_cstate state); };#endif
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +18 -0
@@ -1548,6 +1548,23 @@ static int pp_smu_i2c_bus_access(void *handle, bool acquire)return ret; } +static int pp_set_df_cstate (void *handle,enum pp_df_cstate state) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr) +return -EINVAL ; + +if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_df_cstate) +return 0 ; + +mutex_lock (&hwmgr->smu_lock); + hwmgr->hwmgr_func->set_df_cstate (hwmgr, state); +mutex_unlock (&hwmgr->smu_lock); + +return 0 ; +} +static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
@@ -1606,4 +1623,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .set_ppfeature_status = pp_set_ppfeature_status, .asic_reset_mode_2 = pp_asic_reset_mode_2, .smu_i2c_bus_access = pp_smu_i2c_bus_access, + .set_df_cstate = pp_set_df_cstate, };
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +19 -0
@@ -4155,6 +4155,24 @@ static int vega20_smu_i2c_bus_access(struct pp_hwmgr *hwmgr, bool acquire)return res; } +static int vega20_set_df_cstate (struct pp_hwmgr *hwmgr, +enum pp_df_cstate state) +{ +int ret; + +/* PPSMC_MSG_DFCstateControl is supported with 40.50 and later fws */ +if (hwmgr->smu_version <0x283200 ) { +pr_err ("Df cstate control is supported with 40.50 and later SMC fw!\n" ); +return -EINVAL ; + } + + ret =smum_send_msg_to_smc_with_parameter (hwmgr, PPSMC_MSG_DFCstateControl, state); +if (ret) +pr_err ("SetDfCstate failed!\n" ); + +return ret; +} +static const struct pp_hwmgr_func vega20_hwmgr_funcs = {/* init/fini related */ .backend_init = vega20_hwmgr_backend_init,
@@ -4223,6 +4241,7 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = { .set_asic_baco_state = vega20_baco_set_state, .set_mp1_state = vega20_set_mp1_state, .smu_i2c_bus_access = vega20_smu_i2c_bus_access, + .set_df_cstate = vega20_set_df_cstate, };int vega20_hwmgr_init (struct pp_hwmgr *hwmgr)
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
@@ -355,6 +355,7 @@ struct pp_hwmgr_func {int (*set_mp1_state)(struct pp_hwmgr *hwmgr,enum pp_mp1_state mp1_state);int (*asic_reset)(struct pp_hwmgr *hwmgr,enum SMU_ASIC_RESET_MODE mode);int (*smu_i2c_bus_access)(struct pp_hwmgr *hwmgr,bool aquire); +int (*set_df_cstate)(struct pp_hwmgr *hwmgr,enum pp_df_cstate state); };struct pp_table_func {
drivers/gpu/drm/amd/powerplay/inc/vega20_ppsmc.h +2 -1
@@ -120,7 +120,8 @@#define PPSMC_MSG_SetMGpuFanBoostLimitRpm 0x5D#define PPSMC_MSG_GetAVFSVoltageByDpm 0x5F#define PPSMC_MSG_BacoWorkAroundFlushVDCI 0x60 -#define PPSMC_Message_Count 0x61 +#define PPSMC_MSG_DFCstateControl 0x63 +#define PPSMC_Message_Count 0x64typedef uint32_t PPSMC_Result ;typedef uint32_t PPSMC_Msg ;
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/2 drm/amd/powerplay: enable df cstate control on swSMU routine
Currently this is only supported on Vega20 with 40.50 and later SMC firmware.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 23 +++++++++++++++++ .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 1 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 25 ++++++++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +23 -0
@@ -1834,6 +1834,29 @@ int smu_set_mp1_state(struct smu_context *smu,return ret; } +int smu_set_df_cstate (struct smu_context *smu, +enum pp_df_cstate state) +{ +int ret =0 ; + +/* +* The SMC is not fully ready. That may be +* expected as the IP may be masked. +* So, just return without error. +*/ +if (!smu->pm_enabled) +return 0 ; + +if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate) +return 0 ; + + ret = smu->ppt_funcs->set_df_cstate (smu, state); +if (ret) +pr_err ("[SetDfCstate] failed!\n" ); + +return ret; +} +const struct amd_ip_funcs smu_ip_funcs = { .name ="smu" , .early_init = smu_early_init,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -468,6 +468,7 @@ struct pptable_funcs {int (*get_power_limit)(struct smu_context *smu,uint32_t *limit,bool asic_default);int (*get_dpm_clk_limited)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t dpm_level,uint32_t *freq); +int (*set_df_cstate)(struct smu_context *smu,enum pp_df_cstate state); };struct smu_funcs
@@ -852,5 +853,7 @@ int smu_force_clk_levels(struct smu_context *smu, uint32_t mask);int smu_set_mp1_state (struct smu_context *smu,enum pp_mp1_state mp1_state); +int smu_set_df_cstate (struct smu_context *smu, +enum pp_df_cstate state);#endif
drivers/gpu/drm/amd/powerplay/inc/smu_types.h +1 -0
@@ -169,6 +169,7 @@__SMU_DUMMY_MAP (PowerGateAtHub), \__SMU_DUMMY_MAP (SetSoftMinJpeg), \__SMU_DUMMY_MAP (SetHardMinFclkByFreq), \ +__SMU_DUMMY_MAP (DFCstateControl), \ #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +24 -1
@@ -143,6 +143,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (PrepareMp1ForShutdown),MSG_MAP (SetMGpuFanBoostLimitRpm ),MSG_MAP (GetAVFSVoltageByDpm ), + MSG_MAP(DFCstateControl), };static struct smu_11_0_cmn2aisc_mapping vega20_clk_map[SMU_CLK_COUNT ] = {
@@ -3135,6 +3136,27 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu,return 0 ; } +static int vega20_set_df_cstate (struct smu_context *smu, +enum pp_df_cstate state) +{ +uint32_t smu_version; +int ret; + + ret =smu_get_smc_version (smu,NULL , &smu_version); +if (ret) { +pr_err ("Failed to get smu version!\n" ); +return ret; + } + +/* PPSMC_MSG_DFCstateControl is supported with 40.50 and later fws */ +if (smu_version <0x283200 ) { +pr_err ("Df cstate control is supported with 40.50 and later SMC fw!\n" ); +return -EINVAL ; + } + +return smu_send_smc_msg_with_param (smu, SMU_MSG_DFCstateControl, state); +} +static const struct pptable_funcs vega20_ppt_funcs = { .tables_init = vega20_tables_init, .alloc_dpm_context = vega20_allocate_dpm_context,
@@ -3177,7 +3199,8 @@ static const struct pptable_funcs vega20_ppt_funcs = { .get_fan_speed_percent = vega20_get_fan_speed_percent, .get_fan_speed_rpm = vega20_get_fan_speed_rpm, .set_watermarks_table = vega20_set_watermarks_table, - .get_thermal_temperature_range = vega20_get_thermal_temperature_range + .get_thermal_temperature_range = vega20_get_thermal_temperature_range, + .set_df_cstate = vega20_set_df_cstate, };void vega20_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
Hi Evan,
Is there any use case for this interface?
Thanks.
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Quan, Evan
Sent: Thursday, October 10, 2019 11:45 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
[CAUTION: External Email]
Currently this is only supported on Vega20 with 40.50 and later SMC firmware.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 23 +++++++++++++++++ .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 1 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 25 ++++++++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +22 -0
@@ -1834,6 +1834,29 @@ int smu_set_mp1_state(struct smu_context *smu,return ret; } +int smu_set_df_cstate (struct smu_context *smu, +enum pp_df_cstate state) { +int ret =0 ; + +/* +* The SMC is not fully ready. That may be +* expected as the IP may be masked. +* So, just return without error. +*/ +if (!smu->pm_enabled) +return 0 ; + +if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate) +return 0 ; + + ret = smu->ppt_funcs->set_df_cstate (smu, state); +if (ret) +pr_err ("[SetDfCstate] failed!\n" ); + +return ret; +} +const struct amd_ip_funcs smu_ip_funcs = { .name ="smu" , .early_init = smu_early_init,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -468,6 +468,7 @@ struct pptable_funcs {int (*get_power_limit)(struct smu_context *smu,uint32_t *limit,bool asic_default);int (*get_dpm_clk_limited)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t dpm_level,uint32_t *freq); +int (*set_df_cstate)(struct smu_context *smu,enum pp_df_cstate + state); };
struct smu_funcs
@@ -852,5 +853,7 @@ int smu_force_clk_levels(struct smu_context *smu,
uint32_t mask); int smu_set_mp1_state(struct smu_context *smu,
enum pp_mp1_state mp1_state);
+int smu_set_df_cstate(struct smu_context *smu,
+ enum pp_df_cstate state);
#endif
drivers/gpu/drm/amd/powerplay/inc/smu_types.h +1 -0
@@ -169,6 +169,7 @@__SMU_DUMMY_MAP (PowerGateAtHub), \__SMU_DUMMY_MAP (SetSoftMinJpeg), \__SMU_DUMMY_MAP (SetHardMinFclkByFreq), \ +__SMU_DUMMY_MAP (DFCstateControl), \ #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 99effde33ac1..1050566cb69a 100644
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -0
@@ -143,6 +143,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (PrepareMp1ForShutdown),MSG_MAP (SetMGpuFanBoostLimitRpm ),MSG_MAP (GetAVFSVoltageByDpm ), + MSG_MAP(DFCstateControl), }; static struct smu_11_0_cmn2aisc_mapping vega20_clk_map[SMU_CLK_COUNT] = { @@ -3135,6 +3136,27 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu,
return 0;
}
+static int vega20_set_df_cstate(struct smu_context *smu,
+ enum pp_df_cstate state) {
+ uint32_t smu_version;
+ int ret;
+
+ ret = smu_get_smc_version(smu, NULL, &smu_version);
+ if (ret) {
+ pr_err("Failed to get smu version!\n");
+ return ret;
+ }
+
+ /* PPSMC_MSG_DFCstateControl is supported with 40.50 and later fws */
+ if (smu_version < 0x283200) {
+ pr_err("Df cstate control is supported with 40.50 and later SMC fw!\n");
+ return -EINVAL;
+ }
+
+ return smu_send_smc_msg_with_param(smu, SMU_MSG_DFCstateControl,
+state); }
+
static const struct pptable_funcs vega20_ppt_funcs = {
.tables_init = vega20_tables_init,
.alloc_dpm_context = vega20_allocate_dpm_context, @@ -3177,7 +3199,8 @@ static const struct pptable_funcs vega20_ppt_funcs = { .get_fan_speed_percent = vega20_get_fan_speed_percent,
.get_fan_speed_rpm = vega20_get_fan_speed_rpm,
.set_watermarks_table = vega20_set_watermarks_table,
- .get_thermal_temperature_range = vega20_get_thermal_temperature_range + .get_thermal_temperature_range = vega20_get_thermal_temperature_range, + .set_df_cstate = vega20_set_df_cstate,
};
void vega20_set_ppt_funcs(struct smu_context *smu)
--
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): DM6PR12MB3596E2691614B9C3330F6AFB8E940-lmeGfMZKVrEMjCUbWpWtxgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
Yes, we have to toggle DF-C state before/after programming DF Perf counter registers. The series is to provide interface for such case.
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Feng, Kenneth
Sent: 2019年10月10日 12:50
To: Quan, Evan <[email protected]>; [email protected]
Cc: Quan, Evan <[email protected]>
Subject: RE: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
Hi Evan,
Is there any use case for this interface?
Thanks.
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Quan, Evan
Sent: Thursday, October 10, 2019 11:45 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
[CAUTION: External Email]
Currently this is only supported on Vega20 with 40.50 and later SMC firmware.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 23 +++++++++++++++++ .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 1 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 25 ++++++++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +22 -0
@@ -1834,6 +1834,29 @@ int smu_set_mp1_state(struct smu_context *smu,return ret; } +int smu_set_df_cstate (struct smu_context *smu, +enum pp_df_cstate state) { +int ret =0 ; + +/* +* The SMC is not fully ready. That may be +* expected as the IP may be masked. +* So, just return without error. +*/ +if (!smu->pm_enabled) +return 0 ; + +if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate) +return 0 ; + + ret = smu->ppt_funcs->set_df_cstate (smu, state); +if (ret) +pr_err ("[SetDfCstate] failed!\n" ); + +return ret; +} +const struct amd_ip_funcs smu_ip_funcs = { .name ="smu" , .early_init = smu_early_init,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -468,6 +468,7 @@ struct pptable_funcs {int (*get_power_limit)(struct smu_context *smu,uint32_t *limit,bool asic_default);int (*get_dpm_clk_limited)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t dpm_level,uint32_t *freq); +int (*set_df_cstate)(struct smu_context *smu,enum pp_df_cstate + state); };
struct smu_funcs
@@ -852,5 +853,7 @@ int smu_force_clk_levels(struct smu_context *smu,
uint32_t mask); int smu_set_mp1_state(struct smu_context *smu,
enum pp_mp1_state mp1_state);
+int smu_set_df_cstate(struct smu_context *smu,
+ enum pp_df_cstate state);
#endif
drivers/gpu/drm/amd/powerplay/inc/smu_types.h +1 -0
@@ -169,6 +169,7 @@__SMU_DUMMY_MAP (PowerGateAtHub), \__SMU_DUMMY_MAP (SetSoftMinJpeg), \__SMU_DUMMY_MAP (SetHardMinFclkByFreq), \ +__SMU_DUMMY_MAP (DFCstateControl), \ #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 99effde33ac1..1050566cb69a 100644
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -0
@@ -143,6 +143,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (PrepareMp1ForShutdown),MSG_MAP (SetMGpuFanBoostLimitRpm ),MSG_MAP (GetAVFSVoltageByDpm ), + MSG_MAP(DFCstateControl), }; static struct smu_11_0_cmn2aisc_mapping vega20_clk_map[SMU_CLK_COUNT] = { @@ -3135,6 +3136,27 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu,
return 0;
}
+static int vega20_set_df_cstate(struct smu_context *smu,
+ enum pp_df_cstate state) {
+ uint32_t smu_version;
+ int ret;
+
+ ret = smu_get_smc_version(smu, NULL, &smu_version);
+ if (ret) {
+ pr_err("Failed to get smu version!\n");
+ return ret;
+ }
+
+ /* PPSMC_MSG_DFCstateControl is supported with 40.50 and later fws */
+ if (smu_version < 0x283200) {
+ pr_err("Df cstate control is supported with 40.50 and later SMC fw!\n");
+ return -EINVAL;
+ }
+
+ return smu_send_smc_msg_with_param(smu, SMU_MSG_DFCstateControl,
+state); }
+
static const struct pptable_funcs vega20_ppt_funcs = {
.tables_init = vega20_tables_init,
.alloc_dpm_context = vega20_allocate_dpm_context, @@ -3177,7 +3199,8 @@ static const struct pptable_funcs vega20_ppt_funcs = { .get_fan_speed_percent = vega20_get_fan_speed_percent,
.get_fan_speed_rpm = vega20_get_fan_speed_rpm,
.set_watermarks_table = vega20_set_watermarks_table,
- .get_thermal_temperature_range = vega20_get_thermal_temperature_range + .get_thermal_temperature_range = vega20_get_thermal_temperature_range, + .set_df_cstate = vega20_set_df_cstate,
};
void vega20_set_ppt_funcs(struct smu_context *smu)
--
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Feng, Kenneth
Reviewed-by Kenneth FengRE: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
In reply to a message not in the archive-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Quan, Evan
Sent: Thursday, October 10, 2019 11:45 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amd/powerplay: enable df cstate control on swSMU routine
[CAUTION: External Email]
Currently this is only supported on Vega20 with 40.50 and later SMC firmware.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 23 +++++++++++++++++ .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 1 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 25 ++++++++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +22 -0
@@ -1834,6 +1834,29 @@ int smu_set_mp1_state(struct smu_context *smu,return ret; } +int smu_set_df_cstate (struct smu_context *smu, +enum pp_df_cstate state) { +int ret =0 ; + +/* +* The SMC is not fully ready. That may be +* expected as the IP may be masked. +* So, just return without error. +*/ +if (!smu->pm_enabled) +return 0 ; + +if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate) +return 0 ; + + ret = smu->ppt_funcs->set_df_cstate (smu, state); +if (ret) +pr_err ("[SetDfCstate] failed!\n" ); + +return ret; +} +const struct amd_ip_funcs smu_ip_funcs = { .name ="smu" , .early_init = smu_early_init,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -468,6 +468,7 @@ struct pptable_funcs {int (*get_power_limit)(struct smu_context *smu,uint32_t *limit,bool asic_default);int (*get_dpm_clk_limited)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t dpm_level,uint32_t *freq); +int (*set_df_cstate)(struct smu_context *smu,enum pp_df_cstate + state); };
struct smu_funcs
@@ -852,5 +853,7 @@ int smu_force_clk_levels(struct smu_context *smu,
uint32_t mask); int smu_set_mp1_state(struct smu_context *smu,
enum pp_mp1_state mp1_state);
+int smu_set_df_cstate(struct smu_context *smu,
+ enum pp_df_cstate state);
#endif
drivers/gpu/drm/amd/powerplay/inc/smu_types.h +1 -0
@@ -169,6 +169,7 @@__SMU_DUMMY_MAP (PowerGateAtHub), \__SMU_DUMMY_MAP (SetSoftMinJpeg), \__SMU_DUMMY_MAP (SetHardMinFclkByFreq), \ +__SMU_DUMMY_MAP (DFCstateControl), \ #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 99effde33ac1..1050566cb69a 100644
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -0
@@ -143,6 +143,7 @@ static struct smu_11_0_cmn2aisc_mapping vega20_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (PrepareMp1ForShutdown),MSG_MAP (SetMGpuFanBoostLimitRpm ),MSG_MAP (GetAVFSVoltageByDpm ), + MSG_MAP(DFCstateControl), }; static struct smu_11_0_cmn2aisc_mapping vega20_clk_map[SMU_CLK_COUNT] = { @@ -3135,6 +3136,27 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu,
return 0;
}
+static int vega20_set_df_cstate(struct smu_context *smu,
+ enum pp_df_cstate state) {
+ uint32_t smu_version;
+ int ret;
+
+ ret = smu_get_smc_version(smu, NULL, &smu_version);
+ if (ret) {
+ pr_err("Failed to get smu version!\n");
+ return ret;
+ }
+
+ /* PPSMC_MSG_DFCstateControl is supported with 40.50 and later fws */
+ if (smu_version < 0x283200) {
+ pr_err("Df cstate control is supported with 40.50 and later SMC fw!\n");
+ return -EINVAL;
+ }
+
+ return smu_send_smc_msg_with_param(smu, SMU_MSG_DFCstateControl,
+state); }
+
static const struct pptable_funcs vega20_ppt_funcs = {
.tables_init = vega20_tables_init,
.alloc_dpm_context = vega20_allocate_dpm_context, @@ -3177,7 +3199,8 @@ static const struct pptable_funcs vega20_ppt_funcs = { .get_fan_speed_percent = vega20_get_fan_speed_percent,
.get_fan_speed_rpm = vega20_get_fan_speed_rpm,
.set_watermarks_table = vega20_set_watermarks_table,
- .get_thermal_temperature_range = vega20_get_thermal_temperature_range + .get_thermal_temperature_range = vega20_get_thermal_temperature_range, + .set_df_cstate = vega20_set_df_cstate,
};
void vega20_set_ppt_funcs(struct smu_context *smu)
--
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Feng, Kenneth
Reviewed-by Kenneth Feng-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Quan, Evan
Sent: Thursday, October 10, 2019 11:45 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>
Subject: [PATCH 1/2] drm/amd/powerplay: enable df cstate control on powerplay routine
[CAUTION: External Email]
Currently this is only supported on Vega20 with 40.50 and later SMC firmware.
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 6 ++++++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++++++++++++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 19 +++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 + .../gpu/drm/amd/powerplay/inc/vega20_ppsmc.h | 3 ++- 5 files changed, 46 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +6 -0
@@ -179,6 +179,11 @@ enum pp_mp1_state { PP_MP1_STATE_RESET, }; +enum pp_df_cstate { +DF_CSTATE_DISALLOW =0 , +DF_CSTATE_ALLOW , +}; +#define PP_GROUP_MASK 0xF0000000#define PP_GROUP_SHIFT 28
@@ -312,6 +317,7 @@ struct amd_pm_funcs {int (*get_ppfeature_status)(void *handle,char *buf);int (*set_ppfeature_status)(void *handle,uint64_t ppfeature_masks);int (*asic_reset_mode_2)(void *handle); + int (*set_df_cstate)(void *handle, enum pp_df_cstate state); };#endif
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +16 -0
@@ -1548,6 +1548,23 @@ static int pp_smu_i2c_bus_access(void *handle, bool acquire)return ret; } +static int pp_set_df_cstate (void *handle,enum pp_df_cstate state) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr) +return -EINVAL ; + +if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_df_cstate) +return 0 ; + +mutex_lock (&hwmgr->smu_lock); + hwmgr->hwmgr_func->set_df_cstate (hwmgr, state); +mutex_unlock (&hwmgr->smu_lock); + +return 0 ; +} + static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, @@ -1606,4 +1623,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.set_ppfeature_status = pp_set_ppfeature_status,
.asic_reset_mode_2 = pp_asic_reset_mode_2,
.smu_i2c_bus_access = pp_smu_i2c_bus_access,+ .set_df_cstate = pp_set_df_cstate,
};
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +17 -0
@@ -4155,6 +4155,24 @@ static int vega20_smu_i2c_bus_access(struct pp_hwmgr *hwmgr, bool acquire)return res; } +static int vega20_set_df_cstate (struct pp_hwmgr *hwmgr, +enum pp_df_cstate state) { +int ret; + +/* PPSMC_MSG_DFCstateControl is supported with 40.50 and later fws */ +if (hwmgr->smu_version <0x283200 ) { +pr_err ("Df cstate control is supported with 40.50 and later SMC fw!\n" ); +return -EINVAL ; + } + + ret =smum_send_msg_to_smc_with_parameter (hwmgr, PPSMC_MSG_DFCstateControl, state); +if (ret) +pr_err ("SetDfCstate failed!\n" ); + +return ret; +} + static const struct pp_hwmgr_func vega20_hwmgr_funcs = { /* init/fini related */ .backend_init = vega20_hwmgr_backend_init, @@ -4223,6 +4241,7 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = {
.set_asic_baco_state = vega20_baco_set_state,
.set_mp1_state = vega20_set_mp1_state,
.smu_i2c_bus_access = vega20_smu_i2c_bus_access,+ .set_df_cstate = vega20_set_df_cstate,
};
int vega20_hwmgr_init(struct pp_hwmgr *hwmgr) diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 7bf9a14bfa0b..bd8c922dfd3e 100644
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +2 -0
@@ -355,6 +355,7 @@ struct pp_hwmgr_func {int (*set_mp1_state)(struct pp_hwmgr *hwmgr,enum pp_mp1_state mp1_state);int (*asic_reset)(struct pp_hwmgr *hwmgr,enum SMU_ASIC_RESET_MODE mode);int (*smu_i2c_bus_access)(struct pp_hwmgr *hwmgr,bool aquire); +int (*set_df_cstate)(struct pp_hwmgr *hwmgr,enum pp_df_cstate + state); };
struct pp_table_func {
drivers/gpu/drm/amd/powerplay/inc/vega20_ppsmc.h +2 -1
@@ -120,7 +120,8 @@#define PPSMC_MSG_SetMGpuFanBoostLimitRpm 0x5D#define PPSMC_MSG_GetAVFSVoltageByDpm 0x5F#define PPSMC_MSG_BacoWorkAroundFlushVDCI 0x60 -#define PPSMC_Message_Count 0x61 +#define PPSMC_MSG_DFCstateControl 0x63 +#define PPSMC_Message_Count 0x64typedef uint32_t PPSMC_Result ;typedef uint32_t PPSMC_Msg ;
--
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx