[PATCH 2/2] drm/amdgpu: added a sysfs interface for thermal throttling

Christian König christian.koenig at amd.com
Tue Feb 14 09:06:35 UTC 2023


Am 14.02.23 um 09:02 schrieb kunliu13:
> implement apu_thermal_cap r/w callback for vangogh
>
> Jira ID: SWDEV-354511
> Signed-off-by: Kun Liu <Kun.Liu2 at amd.com>
> ---
>   .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 23 +++++++++++++++++++
>   1 file changed, 23 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> index cb10c7e31..d211b1dfe 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> @@ -1590,6 +1590,27 @@ static int vangogh_read_sensor(struct smu_context *smu,
>   	return ret;
>   }
>   
> +static int vangogh_get_apu_thermal_limit(struct smu_context *smu, uint32_t *limit)
> +{
> +	int ret = -EINVAL;

Generally please don't initialize return values if it isn't necessary!

This is constantly reported by automated checkers as bad coding style 
since it prevent the compiler from properly warn if an uninitialized 
variable is used.

Regards,
Christian.

> +
> +	ret = smu_cmn_send_smc_msg_with_param(smu,
> +					      SMU_MSG_GetThermalLimit,
> +					      0, limit);
> +	return ret;
> +}
> +
> +int vangogh_set_apu_thermal_limit(struct smu_context *smu, uint32_t limit)
> +{
> +	int ret = -EINVAL;
> +
> +	ret = smu_cmn_send_smc_msg_with_param(smu,
> +					      SMU_MSG_SetReducedThermalLimit,
> +					      limit, NULL);
> +	return ret;
> +}
> +
> +
>   static int vangogh_set_watermarks_table(struct smu_context *smu,
>   				       struct pp_smu_wm_range_sets *clock_ranges)
>   {
> @@ -2425,6 +2446,8 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
>   	.dpm_set_jpeg_enable = vangogh_dpm_set_jpeg_enable,
>   	.is_dpm_running = vangogh_is_dpm_running,
>   	.read_sensor = vangogh_read_sensor,
> +	.get_apu_thermal_limit = vangogh_get_apu_thermal_limit,
> +	.set_apu_thermal_limit = vangogh_set_apu_thermal_limit,
>   	.get_enabled_mask = smu_cmn_get_enabled_mask,
>   	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
>   	.set_watermarks_table = vangogh_set_watermarks_table,



More information about the amd-gfx mailing list