drm/amd/powerplay: expose vega20 OD features
Subsystems (2)
PATCH 1/1 drm/amd/powerplay: expose vega20 OD features
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191 +++++++++++++++++- drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8 -0
@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +125 -0
143 lines not on this page · raw message
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -0
@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); + int (*set_od8_settings)(void *handle, long *input, uint32_t size); };#endif
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +37 -0
@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle, uint32_t type, long *input, uint3return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); +} + +static int pp_set_od8_settings (void *handle,long *input,uint32_t size) +{ +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle,enum PP_SMC_POWER_PROFILE type,bool en) {
@@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +188 -3
215 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +2 -0
@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input,uint32_t size); };struct pp_table_func {
Signature · 6 lines
2.18.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]
Quoted 4 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal od8_settings API, and one to wire it up to sysfs. A few more comments below.
Quoted 54 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191 +++++++++++++++++- drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +15
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(struct device *dev,return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, voltages, +* power limit, fan speed and temperature. The pp_od8_settings is used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 961
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum
We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 983
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent).
We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 985
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped
spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 986
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the
FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 992
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp.
The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); +} + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, amdgpu_get_dpm_forced_performance_level,
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);
Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
Quoted 324 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) "gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) {DRM_ERROR ("Failed to register debugfs file for dpm!\n" );drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); + int (*set_od8_settings)(void *handle, long *input, uint32_t size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +37
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle, uint32_t type, long *input, uint3return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); +} + +static int pp_set_od8_settings (void *handle,long *input,uint32_t size) +{ +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle,enum PP_SMC_POWER_PROFILE type,bool en) {@@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +188
-3@@ -1099,7 +1099,188 @@ static int vega20_od8_initialize_default_settings(return 0 ; } -static int vega20_od8_set_settings ( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmax" , + od8_settings[OD8_SETTING_GFXCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX ].max_value, + od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkOffsetVolt1" , + od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].max_value, + od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkOffsetVolt2" , + od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].max_value, + od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkOffsetVolt3" , + od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].max_value, + od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"OverDrivePct" , + od8_settings[OD8_SETTING_POWER_PERCENTAGE ].min_value, + od8_settings[OD8_SETTING_POWER_PERCENTAGE ].max_value, + od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"FanMaximumRpm" , + od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].min_value, + od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].max_value, + od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"FanMinimumPwm" , + od8_settings[OD8_SETTING_FAN_MIN_SPEED ].min_value, + od8_settings[OD8_SETTING_FAN_MIN_SPEED ].max_value, + od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"FanTargetTemperautre" , + od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].min_value, + od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].max_value, + od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"MaxOpTemp" , + od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].min_value, + od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].max_value, + od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"FanZeroRpmEnable" , + od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].min_value, + od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].max_value, + od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret =vega20_od8_set_settings (hwmgr,OD8_SETTING_GFXCLK_FMAX , od_sclk); + ret =vega20_od8_set_single_setting (hwmgr,OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret =vega20_od8_set_settings (hwmgr,OD8_SETTING_UCLK_FMAX , od_mclk); + ret =vega20_od8_set_single_setting (hwmgr,OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = { vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit,drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +2
-1@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input,uint32_t size); };struct pp_table_func { --2.18.0
Quoted 4 lines
_______________________________________________
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): CADnq5_PPLej3PUu6ZkHv6muRv_1v8qL7Sfe0zyoKrRAXLan-4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 564 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 961
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 983
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 986
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 992
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings( · line 1183
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings( · line 1207
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
Quoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);
Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);
Regards
Rex
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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): BYAPR12MB27751AEFBBFD1386D9ECAFF5FB360-ZGDeBxoHBPmJeBUhB162ZQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Hi @Deucher, Alexander<mailto:[email protected]> & @Zhu, Rex<mailto:[email protected]>,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old pp_od_clk_voltage APIs.
For the old pp_od_clk_voltage APIs,
1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD ways(that is we need the offset, not the exact value for voltage).
So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD features
Quoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 961
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 983
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 986
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct device *dev, · line 992
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings( · line 1183
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings( · line 1207
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_od8_initialize_default_settings(
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
Quoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);
Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf);
int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
Rex
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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): SN6PR12MB265639A61D343C54EF74CDF9E40B0-kxOKjb6HO/FeL/[email protected]
Quoted 24 lines · Evan
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
Quoted 7 lines
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 588 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
Quoted 15 lines
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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): CADnq5_Pb=HR3h8Bq8UfPifvGea-S_x9drEOrCdf3rtN-=pbaJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi Alex,
Sorry, i cannot get your point.
The OD feature sysfs file used by previous ASICs is "pp_od_clk_voltage". And it binds to two APIs "amdgpu_get_pp_od_clk_voltage" and "amdgpu_set_pp_od_clk_voltage".
static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR,
amdgpu_get_pp_od_clk_voltage,
amdgpu_set_pp_od_clk_voltage);I was saying we cannot reuse these two APIs for vega20 since we have no way to know the exact voltage value for each dpm level(that is what these two APIs required). Thus we cannot share the same sysfs file.
Do you mean we can bind the sysfs file to other APIs? How?
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Monday, August 27, 2018 10:01:49 PM
To: Quan, Evan
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Quoted 24 lines · Evan
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
Quoted 7 lines
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 588 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
Quoted 15 lines
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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): SN6PR12MB2656D9CFE46599866E01CB46E40A0-kxOKjb6HO/FeL/[email protected]
Right. I'm saying use the same sysfs file (pp_od_clk_voltage) for all devices rather than adding a new one. The output of reading that file will be different on each asic that supports a different way of adjusting the clock and voltage parameters and the supported inputs will be different. We do the same thing today for pp_power_profile_mode. Vega10 and smu7 parts have different parameters, but we use the same files. See the attached patch to an example.
Alex
________________________________
From: Quan, Evan
Sent: Tuesday, August 28, 2018 11:51:16 AM
To: Alex Deucher
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Hi Alex,
Sorry, i cannot get your point.
The OD feature sysfs file used by previous ASICs is "pp_od_clk_voltage". And it binds to two APIs "amdgpu_get_pp_od_clk_voltage" and "amdgpu_set_pp_od_clk_voltage".
static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR,
amdgpu_get_pp_od_clk_voltage,
amdgpu_set_pp_od_clk_voltage);I was saying we cannot reuse these two APIs for vega20 since we have no way to know the exact voltage value for each dpm level(that is what these two APIs required). Thus we cannot share the same sysfs file.
Do you mean we can bind the sysfs file to other APIs? How?
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Monday, August 27, 2018 10:01:49 PM
To: Quan, Evan
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Quoted 24 lines · Evan
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
Quoted 7 lines
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 588 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
Quoted 15 lines
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.0
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +49 -41
@@ -509,51 +509,55 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,const char delimiter[3 ] = {' ' ,'\n' ,'\0' };uint32_t type; -if (count >127 ) -return -EINVAL ; - -if (*buf =='s' ) - type =PP_OD_EDIT_SCLK_VDDC_TABLE ; -else if (*buf =='m' ) - type =PP_OD_EDIT_MCLK_VDDC_TABLE ; -else if (*buf =='r' ) - type =PP_OD_RESTORE_DEFAULT_TABLE ; -else if (*buf =='c' ) - type =PP_OD_COMMIT_DPM_TABLE ; -else -return -EINVAL ; +if (adev->asic_type <=CHIP_VEGA10 ) { +if (count >127 ) +return -EINVAL ; -memcpy (buf_cpy, buf, count+1 ); +if (*buf =='s' ) + type =PP_OD_EDIT_SCLK_VDDC_TABLE ; +else if (*buf =='m' ) + type =PP_OD_EDIT_MCLK_VDDC_TABLE ; +else if (*buf =='r' ) + type =PP_OD_RESTORE_DEFAULT_TABLE ; +else if (*buf =='c' ) + type =PP_OD_COMMIT_DPM_TABLE ; +else +return -EINVAL ; - tmp_str = buf_cpy; +memcpy (buf_cpy, buf, count+1 ); -while (isspace (*++tmp_str)); + tmp_str = buf_cpy; -while (tmp_str[0 ]) { - sub_str =strsep (&tmp_str, delimiter); - ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); -if (ret) -return -EINVAL ; - parameter_size++; +while (isspace (*++tmp_str)); -while (isspace (*tmp_str)) - tmp_str++; - } +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; -if (adev->powerplay.pp_funcs->odn_edit_dpm_table) - ret =amdgpu_dpm_odn_edit_dpm_table (adev, type, - parameter, parameter_size); +while (isspace (*tmp_str)) + tmp_str++; + } -if (ret) -return -EINVAL ; +if (adev->powerplay.pp_funcs->odn_edit_dpm_table) + ret =amdgpu_dpm_odn_edit_dpm_table (adev, type, + parameter, parameter_size); -if (type ==PP_OD_COMMIT_DPM_TABLE ) { -if (adev->powerplay.pp_funcs->dispatch_tasks) { -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); -return count; - }else { +if (ret)return -EINVAL ; + +if (type ==PP_OD_COMMIT_DPM_TABLE ) { +if (adev->powerplay.pp_funcs->dispatch_tasks) { +amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); +return count; + }else { +return -EINVAL ; + } } + }else { +/* do the new stuff here */ }return count;
@@ -567,13 +571,17 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,struct amdgpu_device *adev = ddev->dev_private;uint32_t size =0 ; -if (adev->powerplay.pp_funcs->print_clock_levels) { - size =amdgpu_dpm_print_clock_levels (adev,OD_SCLK , buf); - size +=amdgpu_dpm_print_clock_levels (adev,OD_MCLK , buf+size); - size +=amdgpu_dpm_print_clock_levels (adev,OD_RANGE , buf+size); -return size; +if (adev->asic_type <=CHIP_VEGA10 ) { +if (adev->powerplay.pp_funcs->print_clock_levels) { + size =amdgpu_dpm_print_clock_levels (adev,OD_SCLK , buf); + size +=amdgpu_dpm_print_clock_levels (adev,OD_MCLK , buf+size); + size +=amdgpu_dpm_print_clock_levels (adev,OD_RANGE , buf+size); +return size; + }else { +return snprintf (buf,PAGE_SIZE ,"\n" ); + } }else { -return snprintf (buf,PAGE_SIZE ,"\n" ); +/* do the new stuff here */ } }
_______________________________________________
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): BN6PR12MB180998E806A582A0C10F2C1BF70A0-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Got it. Thanks Alex.
I think we can simplify the od_clk_voltage on vega20.
When user cat pp_od_clk_voltage
The output can be simplified as:
Sclk:
0 clock_value voltage_offset
7 clock_value voltage_offset
Mclk
3 mclk_value
Range:
sclk {min, max}
mclk {min, max}
voltage{min, max}
for sclk,
user can only set the sclk in dpm level0 and level7, the clock in other levels will be recalculated by smu automatically based on user's setting.
For voltage, the avfs is enabled, so the voltage in each level is not a unique value. It is reasonable that export voltage offset to user.
The voltage offset is 0 by default.
The voltage offset in dpm_0, dpm_mid_level, dpm7_level can be configured.
But in order to keep in consistent with sclk's od,
We only let user change the offset in dpm0 and dpm7, for dpm_mid_leve's offset, we can calculate in driver by (offset0 + offset7)/2.
For mclk,
Smu just let us change the max clock in dpm3(high level). And the mclk in other dpm levels can not be changed.
Any concerns?
Best Regards
Rex
From: Deucher, Alexander
Sent: Wednesday, August 29, 2018 12:03 AM
To: Quan, Evan <[email protected]>; Alex Deucher <[email protected]>
Cc: Zhu, Rex <[email protected]>; amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Right. I'm saying use the same sysfs file (pp_od_clk_voltage) for all devices rather than adding a new one. The output of reading that file will be different on each asic that supports a different way of adjusting the clock and voltage parameters and the supported inputs will be different. We do the same thing today for pp_power_profile_mode. Vega10 and smu7 parts have different parameters, but we use the same files. See the attached patch to an example.
Alex
________________________________
From: Quan, Evan
Sent: Tuesday, August 28, 2018 11:51:16 AM
To: Alex Deucher
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Hi Alex,
Sorry, i cannot get your point.
The OD feature sysfs file used by previous ASICs is "pp_od_clk_voltage". And it binds to two APIs "amdgpu_get_pp_od_clk_voltage" and "amdgpu_set_pp_od_clk_voltage".
static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR,
amdgpu_get_pp_od_clk_voltage,
amdgpu_set_pp_od_clk_voltage);I was saying we cannot reuse these two APIs for vega20 since we have no way to know the exact voltage value for each dpm level(that is what these two APIs required). Thus we cannot share the same sysfs file.
Do you mean we can bind the sysfs file to other APIs? How?
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Monday, August 27, 2018 10:01:49 PM
To: Quan, Evan
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Quoted 24 lines · On Mon, Aug 27, 2018 at 12:04 AM Quan, Evan…
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
Quoted 7 lines
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 588 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]<mailto:[email protected]>>
Cc: amd-gfx list <[email protected]<mailto:[email protected]>>; Xu, Feifei <[email protected]<mailto:[email protected]>>; Kuehling, Felix <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>; Zhu, Rex <[email protected]<mailto:[email protected]>>; Zhang, Hawking <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · On Fri, Aug 24, 2018 at 3:45 AM Evan Quan…
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]<mailto:[email protected]>>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
Quoted 15 lines
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.0
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[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): BYAPR12MB27757726027B9534A5EDFAF2FB0A0-ZGDeBxoHBPmJeBUhB162ZQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 49 lines · Rex
Got it. Thanks Alex.
I think we can simplify the
od_clk_voltageon vega20.When user cat
pp_od_clk_voltageThe output can be simplified as:
Sclk:
0
clock_valuevoltage_offset7
clock_valuevoltage_offsetMclk
3
mclk_valueRange:
sclk {min, max}
mclk {min, max}
voltage{min, max}
for sclk,
user can only set the sclk in dpm level0 and level7, the clock in other levels will be recalculated by smu automatically based on user’s setting.
For voltage, the avfs is enabled, so the voltage in each level is not a unique value.
It is reasonable that export voltage offset to user.
The voltage offset is 0 by default.
Quoted 6 lines
The voltage offset in
dpm_0,dpm_mid_level,dpm7_levelcan be configured.But in order to keep in consistent with sclk’s od,
We only let user change the offset in dpm0 and dpm7, for dpm_mid_leve’s offset, we can calculate in driver by (offset0 + offset7)/2.
Seems pretty good. How about something like the following:
OD_SCLK:
min: clock_value
max: clock_valueOD_MCLK:
max: clock_valueOD_VDDC:
0: clock_value voltage_offset
1: clock_value voltage_offset
2: clock_value voltage_offsetOD_RANGE:
SCLK: clock_value clock_value MCLK: clock_value clock_value VDDC: voltage_value voltage_value
OD_SCLK:
min: 300Mhz
max: 1200MhzOD_MCLK:
max: 1500MhzOD_VDDC:
0: 300Mhz 0mV
1: 600Mhz 0mV
2: 1200Mhz 0mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
That would give you the fullest control. Alternatively, we could simplify this a bit by deriving the mid point in the voltage curve. E.g.,
OD_SCLK:
min: clock_value
max: clock_valueOD_MCLK:
max: clock_valueOD_VDDC:
min: clock_value voltage_offset
max: clock_value voltage_offsetOD_RANGE:
SCLK: clock_value clock_value MCLK: clock_value clock_value VDDC: voltage_value voltage_value
OD_SCLK:
min: 300Mhz
max: 1200MhzOD_MCLK:
max 1500MhzOD_VDDC:
min: 300Mhz 0mV
max: 1200Mhz 0mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
I think we could also make the interface backwards compatible. E.g.,
OD_SCLK:
0 300Mhz 900mV
7 1200Mhz 1000mVOD_MCLK:
3 1500Mhz 900mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
We can ignore the voltage for OD_MCLK and then calculate the offsets based on the absolute value specified in OD_SCLK (e.g., default value
- specified value = offset), then calculate the midpoint based on the end points. It would be backwards compatible, but somewhat more confusing for users. Probably one of the first two would be better. Thoughts?
Alex
Quoted 117 lines
For mclk,
Smu just let us change the max clock in dpm3(high level). And the mclk in other dpm levels can not be changed.
Any concerns?
Best Regards
Rex
From: Deucher, Alexander
Sent: Wednesday, August 29, 2018 12:03 AM
To: Quan, Evan <[email protected]>; Alex Deucher <[email protected]>
Cc: Zhu, Rex <[email protected]>; amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresRight. I'm saying use the same sysfs file (
pp_od_clk_voltage) for all devices rather than adding a new one. The output of reading that file will be different on each asic that supports a different way of adjusting the clock and voltage parameters and the supported inputs will be different. We do the same thing today forpp_power_profile_mode. Vega10 and smu7 parts have different parameters, but we use the same files. See the attached patch to an example.Alex
________________________________
From: Quan, Evan
Sent: Tuesday, August 28, 2018 11:51:16 AM
To: Alex Deucher
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresHi Alex,
Sorry, i cannot get your point.
The OD feature sysfs file used by previous ASICs is "
pp_od_clk_voltage". And it binds to two APIs "amdgpu_get_pp_od_clk_voltage" and "amdgpu_set_pp_od_clk_voltage".static DEVICE_ATTR(pp_od_clk_voltage,
S_IRUGO|S_IWUSR,amdgpu_get_pp_od_clk_voltage, amdgpu_set_pp_od_clk_voltage);I was saying we cannot reuse these two APIs for vega20 since we have no way to know the exact voltage value for each dpm level(that is what these two APIs required). Thus we cannot share the same sysfs file.
Do you mean we can bind the sysfs file to other APIs? How?
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Monday, August 27, 2018 10:01:49 PM
To: Quan, Evan
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 30 lines · Evan
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).
Quoted 613 lines
Quoted 1 line
So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 603 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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): CADnq5_ODKCsF_PxL+UhxHNVUZP+U8+ko0+O6uxQuSYtOfuDydA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Approach 3 seems not workable since we do not know the default value.
I would prefer approach 1 if we have to fit into original APIs. There needs three pairs of <frequency, offset> to recalculate the voltage curve. Instead of silently calucating dpm_mid_leve’s offset in our driver, i would prefer to have it specified by user.
Also, we may need to update the description for the OD apis to tell user the different behaviors on vega20 and previous ASICs.
/**
* DOC: pp_od_clk_voltage
*
* The amdgpu driver provides a sysfs API for adjusting the clocks and voltages
* in each power level within a power state. The pp_od_clk_voltage is used for
* this.
*
* Reading the file will display:
*
* - a list of engine clock levels and voltages labeled OD_SCLK
*
* - a list of memory clock levels and voltages labeled OD_MCLK
*
* - a list of valid ranges for sclk, mclk, and voltage labeled OD_RANGE *
* To manually adjust these settings, first select manual using
* power_dpm_force_performance_level. Enter a new value for each
* level by writing a string that contains "s/m level clock voltage" to
* the file. E.g., "s 1 500 820" will update sclk level 1 to be 500 MHz
* at 820 mV; "m 0 350 810" will update mclk level 0 to be 350 MHz at
* 810 mV. When you have edited all of the states as needed, write
* "c" (commit) to the file to commit your changes. If you want to reset to the
* default power levels, write "r" (reset) to the file to reset them. *
*/
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Wednesday, August 29, 2018 1:26:42 AM
To: Zhu, Rex
Cc: Deucher, Alexander; Quan, Evan; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Quoted 49 lines · Rex
Got it. Thanks Alex.
I think we can simplify the
od_clk_voltageon vega20.When user cat
pp_od_clk_voltageThe output can be simplified as:
Sclk:
0
clock_valuevoltage_offset7
clock_valuevoltage_offsetMclk
3
mclk_valueRange:
sclk {min, max}
mclk {min, max}
voltage{min, max}
for sclk,
user can only set the sclk in dpm level0 and level7, the clock in other levels will be recalculated by smu automatically based on user’s setting.
For voltage, the avfs is enabled, so the voltage in each level is not a unique value.
It is reasonable that export voltage offset to user.
The voltage offset is 0 by default.
Quoted 6 lines
The voltage offset in
dpm_0,dpm_mid_level,dpm7_levelcan be configured.But in order to keep in consistent with sclk’s od,
We only let user change the offset in dpm0 and dpm7, for dpm_mid_leve’s offset, we can calculate in driver by (offset0 + offset7)/2.
Seems pretty good. How about something like the following:
OD_SCLK:
min: clock_value
max: clock_valueOD_MCLK:
max: clock_valueOD_VDDC:
0: clock_value voltage_offset
1: clock_value voltage_offset
2: clock_value voltage_offsetOD_RANGE:
SCLK: clock_value clock_value MCLK: clock_value clock_value VDDC: voltage_value voltage_value
OD_SCLK:
min: 300Mhz
max: 1200MhzOD_MCLK:
max: 1500MhzOD_VDDC:
0: 300Mhz 0mV
1: 600Mhz 0mV
2: 1200Mhz 0mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
That would give you the fullest control. Alternatively, we could simplify this a bit by deriving the mid point in the voltage curve. E.g.,
OD_SCLK:
min: clock_value
max: clock_valueOD_MCLK:
max: clock_valueOD_VDDC:
min: clock_value voltage_offset
max: clock_value voltage_offsetOD_RANGE:
SCLK: clock_value clock_value MCLK: clock_value clock_value VDDC: voltage_value voltage_value
OD_SCLK:
min: 300Mhz
max: 1200MhzOD_MCLK:
max 1500MhzOD_VDDC:
min: 300Mhz 0mV
max: 1200Mhz 0mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
I think we could also make the interface backwards compatible. E.g.,
OD_SCLK:
0 300Mhz 900mV
7 1200Mhz 1000mVOD_MCLK:
3 1500Mhz 900mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
We can ignore the voltage for OD_MCLK and then calculate the offsets based on the absolute value specified in OD_SCLK (e.g., default value
- specified value = offset), then calculate the midpoint based on the end points. It would be backwards compatible, but somewhat more confusing for users. Probably one of the first two would be better. Thoughts?
Alex
Quoted 117 lines
For mclk,
Smu just let us change the max clock in dpm3(high level). And the mclk in other dpm levels can not be changed.
Any concerns?
Best Regards
Rex
From: Deucher, Alexander
Sent: Wednesday, August 29, 2018 12:03 AM
To: Quan, Evan <[email protected]>; Alex Deucher <[email protected]>
Cc: Zhu, Rex <[email protected]>; amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresRight. I'm saying use the same sysfs file (
pp_od_clk_voltage) for all devices rather than adding a new one. The output of reading that file will be different on each asic that supports a different way of adjusting the clock and voltage parameters and the supported inputs will be different. We do the same thing today forpp_power_profile_mode. Vega10 and smu7 parts have different parameters, but we use the same files. See the attached patch to an example.Alex
________________________________
From: Quan, Evan
Sent: Tuesday, August 28, 2018 11:51:16 AM
To: Alex Deucher
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresHi Alex,
Sorry, i cannot get your point.
The OD feature sysfs file used by previous ASICs is "
pp_od_clk_voltage". And it binds to two APIs "amdgpu_get_pp_od_clk_voltage" and "amdgpu_set_pp_od_clk_voltage".static DEVICE_ATTR(pp_od_clk_voltage,
S_IRUGO|S_IWUSR,amdgpu_get_pp_od_clk_voltage, amdgpu_set_pp_od_clk_voltage);I was saying we cannot reuse these two APIs for vega20 since we have no way to know the exact voltage value for each dpm level(that is what these two APIs required). Thus we cannot share the same sysfs file.
Do you mean we can bind the sysfs file to other APIs? How?
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Monday, August 27, 2018 10:01:49 PM
To: Quan, Evan
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 30 lines · Evan
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).
Quoted 613 lines
Quoted 1 line
So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 603 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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): SN6PR12MB265690C8EFFD1ACFBF696C86E4090-kxOKjb6HO/FeL/[email protected]
I just sent out a new patch which reuses existing APIs. Let's move future discussion there.
Regards,
Evan
________________________________
From: Quan, Evan
Sent: Wednesday, August 29, 2018 9:12 AM
To: Alex Deucher; Zhu, Rex
Cc: Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Approach 3 seems not workable since we do not know the default value.
I would prefer approach 1 if we have to fit into original APIs. There needs three pairs of <frequency, offset> to recalculate the voltage curve. Instead of silently calucating dpm_mid_leve’s offset in our driver, i would prefer to have it specified by user.
Also, we may need to update the description for the OD apis to tell user the different behaviors on vega20 and previous ASICs.
/**
* DOC: pp_od_clk_voltage
*
* The amdgpu driver provides a sysfs API for adjusting the clocks and voltages
* in each power level within a power state. The pp_od_clk_voltage is used for
* this.
*
* Reading the file will display:
*
* - a list of engine clock levels and voltages labeled OD_SCLK
*
* - a list of memory clock levels and voltages labeled OD_MCLK
*
* - a list of valid ranges for sclk, mclk, and voltage labeled OD_RANGE *
* To manually adjust these settings, first select manual using
* power_dpm_force_performance_level. Enter a new value for each
* level by writing a string that contains "s/m level clock voltage" to
* the file. E.g., "s 1 500 820" will update sclk level 1 to be 500 MHz
* at 820 mV; "m 0 350 810" will update mclk level 0 to be 350 MHz at
* 810 mV. When you have edited all of the states as needed, write
* "c" (commit) to the file to commit your changes. If you want to reset to the
* default power levels, write "r" (reset) to the file to reset them. *
*/
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Wednesday, August 29, 2018 1:26:42 AM
To: Zhu, Rex
Cc: Deucher, Alexander; Quan, Evan; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD features
Quoted 49 lines · Rex
Got it. Thanks Alex.
I think we can simplify the
od_clk_voltageon vega20.When user cat
pp_od_clk_voltageThe output can be simplified as:
Sclk:
0
clock_valuevoltage_offset7
clock_valuevoltage_offsetMclk
3
mclk_valueRange:
sclk {min, max}
mclk {min, max}
voltage{min, max}
for sclk,
user can only set the sclk in dpm level0 and level7, the clock in other levels will be recalculated by smu automatically based on user’s setting.
For voltage, the avfs is enabled, so the voltage in each level is not a unique value.
It is reasonable that export voltage offset to user.
The voltage offset is 0 by default.
Quoted 6 lines
The voltage offset in
dpm_0,dpm_mid_level,dpm7_levelcan be configured.But in order to keep in consistent with sclk’s od,
We only let user change the offset in dpm0 and dpm7, for dpm_mid_leve’s offset, we can calculate in driver by (offset0 + offset7)/2.
Seems pretty good. How about something like the following:
OD_SCLK:
min: clock_value
max: clock_valueOD_MCLK:
max: clock_valueOD_VDDC:
0: clock_value voltage_offset
1: clock_value voltage_offset
2: clock_value voltage_offsetOD_RANGE:
SCLK: clock_value clock_value MCLK: clock_value clock_value VDDC: voltage_value voltage_value
OD_SCLK:
min: 300Mhz
max: 1200MhzOD_MCLK:
max: 1500MhzOD_VDDC:
0: 300Mhz 0mV
1: 600Mhz 0mV
2: 1200Mhz 0mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
That would give you the fullest control. Alternatively, we could simplify this a bit by deriving the mid point in the voltage curve. E.g.,
OD_SCLK:
min: clock_value
max: clock_valueOD_MCLK:
max: clock_valueOD_VDDC:
min: clock_value voltage_offset
max: clock_value voltage_offsetOD_RANGE:
SCLK: clock_value clock_value MCLK: clock_value clock_value VDDC: voltage_value voltage_value
OD_SCLK:
min: 300Mhz
max: 1200MhzOD_MCLK:
max 1500MhzOD_VDDC:
min: 300Mhz 0mV
max: 1200Mhz 0mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
I think we could also make the interface backwards compatible. E.g.,
OD_SCLK:
0 300Mhz 900mV
7 1200Mhz 1000mVOD_MCLK:
3 1500Mhz 900mVOD_RANGE:
SCLK: 300MHz 1200MHz MCLK: 300MHz 1500MHz VDDC: 700mV 1200mV
We can ignore the voltage for OD_MCLK and then calculate the offsets based on the absolute value specified in OD_SCLK (e.g., default value
- specified value = offset), then calculate the midpoint based on the end points. It would be backwards compatible, but somewhat more confusing for users. Probably one of the first two would be better. Thoughts?
Alex
Quoted 117 lines
For mclk,
Smu just let us change the max clock in dpm3(high level). And the mclk in other dpm levels can not be changed.
Any concerns?
Best Regards
Rex
From: Deucher, Alexander
Sent: Wednesday, August 29, 2018 12:03 AM
To: Quan, Evan <[email protected]>; Alex Deucher <[email protected]>
Cc: Zhu, Rex <[email protected]>; amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresRight. I'm saying use the same sysfs file (
pp_od_clk_voltage) for all devices rather than adding a new one. The output of reading that file will be different on each asic that supports a different way of adjusting the clock and voltage parameters and the supported inputs will be different. We do the same thing today forpp_power_profile_mode. Vega10 and smu7 parts have different parameters, but we use the same files. See the attached patch to an example.Alex
________________________________
From: Quan, Evan
Sent: Tuesday, August 28, 2018 11:51:16 AM
To: Alex Deucher
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresHi Alex,
Sorry, i cannot get your point.
The OD feature sysfs file used by previous ASICs is "
pp_od_clk_voltage". And it binds to two APIs "amdgpu_get_pp_od_clk_voltage" and "amdgpu_set_pp_od_clk_voltage".static DEVICE_ATTR(pp_od_clk_voltage,
S_IRUGO|S_IWUSR,amdgpu_get_pp_od_clk_voltage, amdgpu_set_pp_od_clk_voltage);I was saying we cannot reuse these two APIs for vega20 since we have no way to know the exact voltage value for each dpm level(that is what these two APIs required). Thus we cannot share the same sysfs file.
Do you mean we can bind the sysfs file to other APIs? How?
Regards,
Evan
________________________________
From: Alex Deucher <[email protected]>
Sent: Monday, August 27, 2018 10:01:49 PM
To: Quan, Evan
Cc: Zhu, Rex; Deucher, Alexander; amd-gfx list; Xu, Feifei; Kuehling, Felix; Zhang, Hawking
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 30 lines · Evan
Hi @Deucher, Alexander & @Zhu, Rex,
I can remove the od setings for power limit and fan speed related since they seem redundant with other sysfs apis.
But for the clock/voltage related, i can not see how to reuse old
pp_od_clk_voltageAPIs.For the old
pp_od_clk_voltageAPIs,1. they output/input the voltages in their exact values. E.g. "s 1 500 820" will update sclk level 1 to be 500 MHz at 820 mV
But for vega20, we did not know its original voltage value. The output/input for voltage are just offest from its original value.
So, if to reuse these APIs, we will make them have two different explanations(
on vega20 or later, the voltage is offset. On previous ASICs, the voltage is exact value). I think that will confuse the users.
2. they support voltage set for each level. But for vega20, it supports only three pairs of clock/voltage set. And per suggestion,
these three pairs should be: voltage offset of minimum clock level, voltage offset for middle clock level and voltage offset
for maximum clock level.
Also, i believe the future ASICs will also take the vega20 OD
ways(that is we need the offset, not the exact value for voltage).
Quoted 613 lines
Quoted 1 line
So, based on previous considerations, i decide to have new APIs instead of reusing existing ones.
I'm not saying to use the same API. Use the new API, but expose the API using the same sysfs file rather than adding a new one. Same way we handle the power profiles; E.g., the API is different between smu7 and vega10, but they both use the same sysfs file.
Alex
Quoted 603 lines
Regards,
Evan
________________________________
From: Zhu, Rex
Sent: Saturday, August 25, 2018 12:32 AM
To: Alex Deucher; Quan, Evan
Cc: amd-gfx list; Xu, Feifei; Kuehling, Felix; Deucher, Alexander; Zhang, Hawking
Subject: RE: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 562 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 24, 2018 11:48 PM
To: Quan, Evan <[email protected]>
Cc: amd-gfx list <[email protected]>; Xu, Feifei <[email protected]>; Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Zhu, Rex <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: expose vega20 OD featuresQuoted 3 lines · Evan Quan
Vega20 simplifies the OD logics and it can not fit old OD interfaces. Thus we design new OD interfaces for vega20.
Please split this into two patches, one to add the internal
od8_settingsAPI, and one to wire it up to sysfs. A few more comments below.Quoted 9 lines
Change-Id I888faec46a81287ae24f452ce16b42c1f6d06d7dSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 8 + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 125 ++++++++++++ .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 37 ++++ .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 191+++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct
Quoted 30 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 + 6 files changed, 362 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +8
-0@@ -357,6 +357,14 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_get_od8_settings (adev, buf) \ + ((adev)->powerplay.pp_funcs->get_od8_settings(\ + (adev)->powerplay.pp_handle, buf)) + +#define amdgpu_dpm_set_od8_settings (adev, parameter, size) \ + ((adev)->powerplay.pp_funcs->set_od8_settings(\ + (adev)->powerplay.pp_handle, parameter, size)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
indexdaa55fb06171..94cd7c503372100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -934,6 +934,121 @@ static ssize_t amdgpu_get_busy_percent(structdevice *dev,
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17
-0return snprintf (buf,PAGE_SIZE ,"%d\n" , value); } +/** +* DOC: pp_od8_settings +* +* The amdgpu driver provides a sysfs API for adjusting the clocks, +voltages, +* power limit, fan speed and temperature. The pp_od8_settings is +used for +* this. +* +* Reading the file will display: +* +* - a name list of the features that are able to be adjusted +* +* - the mininum and maximum allowed value for each supported +* feature labeled in format of "[mininum - maximum]" +* +* - the current value for each supported feature labeled after drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 962
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* ":" +* +* To manually adjust these settings: +* +* - write a string that contains the new value for each supported +* feature. For those which do not need to be changed, just enter +* their old value +* +* - make sure the new value is within the allowed ranges between +* the minimum and maximum We should probably also make it a set and commit model like we do for previous asics for consistency. That way you can see the changes, and then apply them.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12
-0+* +* All the possible supported features: +* +* - Gfx clock +* The min and max frequency can be specified by GfxclkFmin +* and GfxclkFmax(both in Mhz). Intermediate levels are +* stretched/shrunk according to ratio in original table. +* +* - Gfx voltage +* With three pairs of gfx clk(in Mhz) and offset voltage(in mV) +* combinations specified, smu fw can calibrate the voltage +* curve automatically. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 984
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+* - GfxclkFreq1 <-> GfxclkOffsetVolt1 +* - GfxclkFreq2 <-> GfxclkOffsetVolt2 +* - GfxclkFreq3 <-> GfxclkOffsetVolt3 +* +* - Uclk +* The max memory clock can be specified by UclkFmax(in Mhz). +* +* - Power limit +* The power limit can be increased or descreased by +* OverDrivePct(in percent). We already expose the power limit via hwmon. Do we still need it here?
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 986
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0+* +* - Fan spped spped -> speed
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 987
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-0+* The max fan speed can be set by FanMaxinumRpm and the FanMaxinumRpm -> FanMaximumRpm
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_busy_percent(struct · line 993
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6
-0+* min fan speed by FanMinimumPwm. Also zero rpm enablement +* is specified by FanZeroRpmEnable. +* +* - Temperature +* The fan target temperature can be set by FanTargetTemperature +* and max Tj temperature by MaxOpTemp. The fan and temp stuff might be a better fit for the hwmon interfaces:
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interfaceQuoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +59
-0+* +*/ + +static ssize_t amdgpu_get_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; + +if (adev->powerplay.pp_funcs->get_od8_settings) +return amdgpu_dpm_get_od8_settings (adev, buf); + +return snprintf (buf,PAGE_SIZE ,"\n" ); } + +static ssize_t amdgpu_set_pp_od8_settings (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +char *sub_str, *tmp_str, buf_cpy[128 ]; +const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +uint32_t parameter_size =0 ; +long parameter[64 ]; +int ret =0xff ; + +if (count >=sizeof (buf_cpy) /sizeof (buf_cpy[0 ])) +return -EINVAL ; + +memcpy (buf_cpy, buf, count); + buf_cpy[count] ='\0' ; + + tmp_str = buf_cpy; + +while (isspace (*tmp_str)) tmp_str++; + +while (tmp_str[0 ]) { + sub_str =strsep (&tmp_str, delimiter); + ret =kstrtol (sub_str,0 , ¶meter[parameter_size]); +if (ret) +return -EINVAL ; + parameter_size++; + +while (isspace (*tmp_str)) + tmp_str++; + } + +if (adev->powerplay.pp_funcs->set_od8_settings) + ret =amdgpu_dpm_set_od8_settings (adev, parameter, + parameter_size); + +if (ret) +return -EINVAL ; + +return count; +} + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR,Quoted 1 line
amdgpu_get_dpm_state,amdgpu_set_dpm_state); staticDEVICE_ATTR(power_dpm_force_performance_level,
S_IRUGO|S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO
Quoted 2 lines
amdgpu_get_dpm_forced_performance_level,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -969,6 +1084,9 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO|
S_IWUSR,drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO · line 1089
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3
-0amdgpu_set_pp_od_clk_voltage); static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, amdgpu_get_busy_percent, NULL); +static DEVICE_ATTR(pp_od8_settings, S_IRUGO | S_IWUSR, + amdgpu_get_pp_od8_settings, + amdgpu_set_pp_od8_settings);Rather than adding a new file, would it make more sense to expose this new API on the same file we use for older asics? Otherwise, every time the interface changes, we'll need to add a new file. We already handle asic specific differences in the power profile sysfs files.
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c int amdgpu_pm_sysfs_init(struct
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1879,6 +1997,13 @@ int amdgpu_pm_sysfs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_odn_edit_dpm_table(void *handle,
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7
-0"gpu_busy_level\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_pp_od8_settings); +if (ret) { +DRM_ERROR ("failed to create device file " +"pp_od8_settings\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) { DRM_ERROR("Failed to register debugfs file fordpm!\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.hb/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index6a41b81c7325..e23746ba53bf100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +3
-0@@ -269,6 +269,8 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); +int (*get_od8_settings)(void *handle,char *buf); +int (*set_od8_settings)(void *handle,long *input,uint32_t + size); };#endif drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -883,6 +883,41 @@ static int pp_odn_edit_dpm_table(void *handle,
uint32_ttype, long *input, uint3drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int
Quoted 53 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +36
-0return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_get_od8_settings (void *handle,char *buf) { +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en || !buf) +return -EINVAL ; + +if (hwmgr->hwmgr_func->get_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return snprintf (buf,PAGE_SIZE ,"\n" ); + } + +return hwmgr->hwmgr_func->get_od8_settings (hwmgr, buf); } + +static int pp_set_od8_settings (void *handle,long *input,uint32_t +size) { +struct pp_hwmgr *hwmgr = handle; +int ret = -EINVAL ; + +if (!hwmgr || !hwmgr->pm_en) +return ret; + +if (hwmgr->hwmgr_func->set_od8_settings ==NULL ) { +pr_info ("%s was not implemented.\n" , __func__); +return ret; + } + +mutex_lock (&hwmgr->smu_lock); + ret = hwmgr->hwmgr_func->set_od8_settings (hwmgr, input, size); +mutex_unlock (&hwmgr->smu_lock); + +return ret; +} +static int pp_dpm_switch_power_profile (void *handle, enum PP_SMC_POWER_PROFILE type, bool en) { @@ -1272,6 +1307,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .get_od8_settings = pp_get_od8_settings, + .set_od8_settings = pp_set_od8_settings, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -1099,7 +1099,188 @@ static intvega20_od8_initialize_default_settings(
Quoted 36 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +32
-1return 0 ; } -static int vega20_od8_set_settings( +static int vega20_get_od8_settings ( +struct pp_hwmgr *hwmgr, +char *buf) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint32_t size =0 ; +int ret =0 ; + +if (!buf) +return -EINVAL ; + + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +if (od8_settings[OD8_SETTING_GFXCLK_FMIN ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFmin" , + od8_settings[OD8_SETTING_GFXCLK_FMIN ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMIN ].max_value, + od_table.GfxclkFmin); + +if (od8_settings[OD8_SETTING_GFXCLK_FMAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "GfxclkFmax", + od8_settings[OD8_SETTING_GFXCLK_FMAX].min_value, + od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1143
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkFmax); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq1" , + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ1 ].max_value, + od_table.GfxclkFreq1); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt1",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1144
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1145
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1155
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt1); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq2" , + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ2 ].max_value, + od_table.GfxclkFreq2); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt2",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1156
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1157
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1167
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +10
-0+ od_table.GfxclkOffsetVolt2); + +if (od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"GfxclkFreq3" , + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].min_value, + od8_settings[OD8_SETTING_GFXCLK_FREQ3 ].max_value, + od_table.GfxclkFreq3); + +if (od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3 ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","GfxclkOffsetVolt3",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1168
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1169
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1180
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +11
-0+ od_table.GfxclkOffsetVolt3); + +if (od8_settings[OD8_SETTING_UCLK_FMAX ].feature_id) + size +=sprintf (buf + size,"%22s[%d - %d]: %u\n" ,"UclkFmax" , + od8_settings[OD8_SETTING_UCLK_FMAX ].min_value, + od8_settings[OD8_SETTING_UCLK_FMAX ].max_value, + od_table.UclkFmax); + +if (od8_settings[OD8_SETTING_POWER_PERCENTAGE ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "OverDrivePct", +od8_settings[OD8_SETTING_POWER_PERCENTAGE].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1181
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_POWER_PERCENTAGE].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1185
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.OverDrivePct); + +if (od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMaximumRpm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1186
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1187
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1191
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMaximumRpm); + +if (od8_settings[OD8_SETTING_FAN_MIN_SPEED ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanMinimumPwm",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1192
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1193
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_MIN_SPEED].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1197
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.FanMinimumPwm); + +if (od8_settings[OD8_SETTING_FAN_TARGET_TEMP ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanTargetTemperautre",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1198
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1199
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_TARGET_TEMP].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1204
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +5
-0+ od_table.FanTargetTemperature); + +if (od8_settings[OD8_SETTING_OPERATING_TEMP_MAX ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n", "MaxOpTemp", +od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1205
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_OPERATING_TEMP_MAX].max_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1209
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0+ od_table.MaxOpTemp); + +if (od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL ].feature_id) + size += sprintf(buf + size, "%22s[%d - %d]: %u\n","FanZeroRpmEnable",
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1210
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].min_value,
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int · line 1211
Quoted 1 line
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+od8_settings[OD8_SETTING_FAN_ZERO_RPM_CONTROL].max_value,
Quoted 76 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +72
-0+ od_table.FanZeroRpmEnable); + +return size; +} + +static int vega20_set_od8_settings ( +struct pp_hwmgr *hwmgr, +long *input, +uint32_t size) +{ +struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +struct vega20_od8_single_setting *od8_settings = + data->od8_settings.od8_settings_array; +OverDriveTable_t od_table; +uint16_t *buf = (uint16_t *)(&od_table); +uint32_t i, j =0 , k; +int ret =0 ; + +/* retrieve current overdrive settings */ + ret =vega20_copy_table_from_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to export over drive table!" , + return ret); + +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { +/* overdrive table supports no dram timing setting */ + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +/* +* Not all OD settings are supported and exported +* to user. +* So, updated only those which are supported and +* exported to user. +*/ +if (od8_settings[k].feature_id) { +if (input[j] < od8_settings[k].min_value || + input[j] > od8_settings[k].max_value) +return -EINVAL ; + + buf[i] = input[j]; +if (j++ >= size -1 ) +break ; + } + } + +/* enable the new overdrive settings */ + ret =vega20_copy_table_to_smc (hwmgr, + (uint8_t *)(&od_table), +TABLE_OVERDRIVE ); +PP_ASSERT_WITH_CODE (!ret, +"Failed to import over drive table!" , + return ret); + +/* update the current_value of overdrive settings */ +for (i =0 ; + i < (sizeof (OverDriveTable_t) /sizeof (uint16_t )) -1 ; + i++) { + k = (i ==OD8_SETTING_AC_TIMING ) ? +OD8_SETTING_FAN_ZERO_RPM_CONTROL : i; +if (od8_settings[k].feature_id) + od8_settings[k].current_value = buf[i]; + } + +return 0 ; +} + +static int vega20_od8_set_single_setting (struct pp_hwmgr *hwmgr,uint32_t index,uint32_t value)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_sclk_od( · line 1202
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1@@ -1198,7 +1379,7 @@ static int vega20_set_sclk_od(do_div (od_sclk,100 ); od_sclk += golden_sclk_table->dpm_levels[golden_sclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_GFXCLK_FMAX,
od_sclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static int vega20_set_mclk_od( · line 1249
Quoted 11 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-1+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_GFXCLK_FMAX , od_sclk);PP_ASSERT_WITH_CODE (!ret,"[SetSclkOD] failed to set od gfxclk!" , return ret);@@ -1245,7 +1426,7 @@ static int vega20_set_mclk_od(do_div (od_mclk,100 ); od_mclk += golden_mclk_table->dpm_levels[golden_mclk_table->count -1 ].value; - ret = vega20_od8_set_settings(hwmgr, OD8_SETTING_UCLK_FMAX,
od_mclk);drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c static const struct pp_hwmgr_func
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2
-0+ ret =vega20_od8_set_single_setting (hwmgr, +OD8_SETTING_UCLK_FMAX , od_mclk);PP_ASSERT_WITH_CODE (!ret,"[SetMclkOD] failed to set od memclk!" , return ret);@@ -2966,6 +3147,10 @@ static const struct pp_hwmgr_func
vega20_hwmgr_funcs= {Quoted 14 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +4
-0vega20_get_power_profile_mode, .set_power_profile_mode = vega20_set_power_profile_mode, + .get_od8_settings = + vega20_get_od8_settings, + .set_od8_settings = + vega20_set_od8_settings,/* od related */ .set_power_limit = vega20_set_power_limit, diff --git
a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hb/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
indexa6d92128b19c..285af1728e2e100644
---a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hQuoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c struct pp_hwmgr_func { · line 333
Quoted 8 lines
+++
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.hdrivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0@@ -328,6 +328,8 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*get_od8_settings)(struct pp_hwmgr *hwmgr,char *buf); +int (*set_od8_settings)(struct pp_hwmgr *hwmgr,long *input, +uint32_t size);Those new added interfaces for OD parameters get/set seems have no difference with the old interface.
int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, enum PP_OD_DPM_TABLE_COMMAND type, long *input, uint32_t size);Regards
RexQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-1};struct pp_table_func { --2.18.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