For Some ASICs, with the PMFW default settings, we may see the power consumption reported via metrics table is "Very Erratic". With the socket power alpha filter set as 10/100ms, we can correct that issue. Signed-off-by: Evan Quan <evan.quan@xxxxxxx> Change-Id: Ia352579e1cc7a531cb1de5c835fe5bf132d5dd20 --- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 14 ++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 10 ++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 2 ++ 4 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h index ef44c8c3d616..d3424cc586aa 100644 --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h @@ -293,6 +293,18 @@ struct amdgpu_smu_i2c_bus { struct mutex mutex; }; +struct config_table_setting +{ + uint16_t gfxclk_average_tau; + uint16_t socclk_average_tau; + uint16_t uclk_average_tau; + uint16_t gfx_activity_average_tau; + uint16_t mem_activity_average_tau; + uint16_t socket_power_average_tau; + uint16_t apu_socket_power_average_tau; + uint16_t fclk_average_tau; +}; + struct amdgpu_pm { struct mutex mutex; u32 current_sclk; @@ -341,6 +353,8 @@ struct amdgpu_pm { struct mutex stable_pstate_ctx_lock; struct amdgpu_ctx *stable_pstate_ctx; + + struct config_table_setting config_table; }; int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensor, diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index c6a42ac8ba78..9e1ea9d54f50 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -601,6 +601,18 @@ static int smu_set_default_dpm_table(struct smu_context *smu) return ret; } +static int smu_apply_default_config_table_settings(struct smu_context *smu) +{ + struct amdgpu_device *adev = smu->adev; + int ret = 0; + + ret = smu_get_default_config_table_settings(smu, + &adev->pm.config_table); + if (ret) + return ret; + + return smu_set_config_table(smu, &adev->pm.config_table); +} static int smu_late_init(void *handle) { @@ -655,6 +667,12 @@ static int smu_late_init(void *handle) smu->smu_dpm.dpm_level, AMD_PP_TASK_COMPLETE_INIT); + ret = smu_apply_default_config_table_settings(smu); + if (ret && (ret != -EOPNOTSUPP)) { + dev_err(adev->dev, "Failed to apply default DriverSmuConfig settings!\n"); + return ret; + } + smu_restore_dpm_user_profile(smu); return 0; diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 51a32ac39990..f0894676b20e 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -1275,6 +1275,16 @@ struct pptable_funcs { * @stb_collect_info: Collects Smart Trace Buffers data. */ int (*stb_collect_info)(struct smu_context *smu, void *buf, uint32_t size); + + /** + * @get_default_config_table_settings: Get the ASIC default DriverSmuConfig table settings. + */ + int (*get_default_config_table_settings)(struct smu_context *smu, struct config_table_setting *table); + + /** + * @set_config_table: Apply the input DriverSmuConfig table settings. + */ + int (*set_config_table)(struct smu_context *smu, struct config_table_setting *table); }; typedef enum { diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h index 48e80ec9b258..2d18b39d7c2a 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h @@ -92,6 +92,8 @@ #define smu_gpo_control(smu, enablement) smu_ppt_funcs(gpo_control, 0, smu, enablement) #define smu_set_fine_grain_gfx_freq_parameters(smu) smu_ppt_funcs(set_fine_grain_gfx_freq_parameters, 0, smu) #define smu_bump_power_profile_mode(smu, param, param_size) smu_ppt_funcs(set_power_profile_mode, -EOPNOTSUPP, smu, param, param_size) +#define smu_get_default_config_table_settings(smu, config_table) smu_ppt_funcs(get_default_config_table_settings, -EOPNOTSUPP, smu, config_table) +#define smu_set_config_table(smu, config_table) smu_ppt_funcs(set_config_table, -EOPNOTSUPP, smu, config_table) #endif #endif -- 2.29.0