drm/amdgpu: added a sysfs interface for thermal throttling
Subsystems (3)
PATCH 1/2 drm/amdgpu: added a sysfs interface for thermal throttling
added a sysfs interface for thermal throttling, then userspace can get/update thermal limit
Signed-off-by Kun Liu <[email protected]>
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 28 +++++++ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 76 +++++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 3 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 24 ++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 12 +++ 6 files changed, 145 insertions(+)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -0
@@ -331,6 +331,8 @@ struct amd_pm_funcs {int (*get_mclk_od)(void *handle);int (*set_mclk_od)(void *handle,uint32_t value);int (*read_sensor)(void *handle,int idx,void *value,int *size); +int (*get_apu_thermal_limit)(void *handle,uint32_t *limit); +int (*set_apu_thermal_limit)(void *handle,uint32_t limit);enum amd_dpm_forced_level (*get_performance_level)(void *handle);enum amd_pm_state_type (*get_current_power_state)(void *handle);int (*get_fan_speed_rpm)(void *handle,uint32_t *rpm);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +28 -0
@@ -438,6 +438,34 @@ int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensoreturn ret; } +int amdgpu_dpm_get_apu_thermal_limit (struct amdgpu_device *adev,uint32_t *limit) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret = -EINVAL ; + +if (pp_funcs && pp_funcs->get_apu_thermal_limit) { +mutex_lock (&adev->pm.mutex); + ret = pp_funcs->get_apu_thermal_limit (adev->powerplay.pp_handle, limit); +mutex_unlock (&adev->pm.mutex); + } + +return ret; +} + +int amdgpu_dpm_set_apu_thermal_limit (struct amdgpu_device *adev,uint32_t limit) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret = -EINVAL ; + +if (pp_funcs && pp_funcs->set_apu_thermal_limit) { +mutex_lock (&adev->pm.mutex); + ret = pp_funcs->set_apu_thermal_limit (adev->powerplay.pp_handle, limit); +mutex_unlock (&adev->pm.mutex); + } + +return ret; +} +void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +76 -0
88 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3 -0
@@ -369,6 +369,9 @@ struct amdgpu_pm {int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size); +int amdgpu_dpm_get_apu_thermal_limit (struct amdgpu_device *adev,uint32_t *limit); +int amdgpu_dpm_set_apu_thermal_limit (struct amdgpu_device *adev,uint32_t limit); +int amdgpu_dpm_set_powergating_by_smu (struct amdgpu_device *adev,uint32_t block_type,bool gate);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +24 -0
@@ -2514,6 +2514,28 @@ static int smu_read_sensor(void *handle,return ret; } +static int smu_get_apu_thermal_limit (void *handle,uint32_t *limit) +{ +int ret = -EINVAL ; +struct smu_context *smu = handle; + +if (smu->ppt_funcs && smu->ppt_funcs->get_apu_thermal_limit) + ret = smu->ppt_funcs->get_apu_thermal_limit (smu, limit); + +return ret; +} + +static int smu_set_apu_thermal_limit (void *handle,uint32_t limit) +{ +int ret = -EINVAL ; +struct smu_context *smu = handle; + +if (smu->ppt_funcs && smu->ppt_funcs->set_apu_thermal_limit) + ret = smu->ppt_funcs->set_apu_thermal_limit (smu, limit); + +return ret; +} +static int smu_get_power_profile_mode (void *handle,char *buf) {struct smu_context *smu = handle;
@@ -2998,6 +3020,8 @@ static const struct amd_pm_funcs swsmu_pm_funcs = { .emit_clock_levels = smu_emit_ppclk_levels, .force_performance_level = smu_force_performance_level, .read_sensor = smu_read_sensor, + .get_apu_thermal_limit = smu_get_apu_thermal_limit, + .set_apu_thermal_limit = smu_set_apu_thermal_limit, .get_performance_level = smu_get_performance_level, .get_current_power_state = smu_get_current_power_state, .get_fan_speed_rpm = smu_get_fan_speed_rpm,
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +12 -0
@@ -721,6 +721,18 @@ struct pptable_funcs {int (*read_sensor)(struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size); +/** +* @get_apu_thermal_limit: get apu core limit from smu +* &limit: current limit temperature in millidegrees Celsius +*/ +int (*get_apu_thermal_limit)(struct smu_context *smu,uint32_t *limit); + +/** +* @set_apu_thermal_limit: update all controllers with new limit +* &limit: limit temperature to be setted, in millidegrees Celsius +*/ +int (*set_apu_thermal_limit)(struct smu_context *smu,uint32_t limit); +/** * @pre_display_config_changed: Prepare GPU for a display configuration * change.
Signature · 1 line
2.25.1