[PATCH] drm/amd/powerplay: Add the interface for geting dpm current power state

Quan, Evan Evan.Quan at amd.com
Mon Sep 9 08:31:04 UTC 2019


Reviewed-by: Evan Quan <evan.quan at amd.com>

> -----Original Message-----
> From: Liang, Prike <Prike.Liang at amd.com>
> Sent: 2019年9月9日 13:22
> To: amd-gfx at lists.freedesktop.org
> Cc: Quan, Evan <Evan.Quan at amd.com>; Feng, Kenneth
> <Kenneth.Feng at amd.com>; Huang, Ray <Ray.Huang at amd.com>; Liu, Aaron
> <Aaron.Liu at amd.com>; Liang, Prike <Prike.Liang at amd.com>
> Subject: [PATCH] drm/amd/powerplay: Add the interface for geting dpm
> current power state
> 
> implement the sysfs power_dpm_state
> 
> Signed-off-by: Prike Liang <Prike.Liang at amd.com>
> ---
>  drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 34
> ++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
> b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
> index a5cf846..2c22ba4 100644
> --- a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
> @@ -246,6 +246,38 @@ static int renoir_print_clk_levels(struct smu_context
> *smu,
>  	return size;
>  }
> 
> +static enum amd_pm_state_type renoir_get_current_power_state(struct
> +smu_context *smu) {
> +	enum amd_pm_state_type pm_type;
> +	struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
> +
> +	if (!smu_dpm_ctx->dpm_context ||
> +	    !smu_dpm_ctx->dpm_current_power_state)
> +		return -EINVAL;
> +
> +	mutex_lock(&(smu->mutex));
> +	switch (smu_dpm_ctx->dpm_current_power_state-
> >classification.ui_label) {
> +	case SMU_STATE_UI_LABEL_BATTERY:
> +		pm_type = POWER_STATE_TYPE_BATTERY;
> +		break;
> +	case SMU_STATE_UI_LABEL_BALLANCED:
> +		pm_type = POWER_STATE_TYPE_BALANCED;
> +		break;
> +	case SMU_STATE_UI_LABEL_PERFORMANCE:
> +		pm_type = POWER_STATE_TYPE_PERFORMANCE;
> +		break;
> +	default:
> +		if (smu_dpm_ctx->dpm_current_power_state-
> >classification.flags & SMU_STATE_CLASSIFICATION_FLAG_BOOT)
> +			pm_type = POWER_STATE_TYPE_INTERNAL_BOOT;
> +		else
> +			pm_type = POWER_STATE_TYPE_DEFAULT;
> +		break;
> +	}
> +	mutex_unlock(&(smu->mutex));
> +
> +	return pm_type;
> +}
> +
>  static const struct pptable_funcs renoir_ppt_funcs = {
>  	.get_smu_msg_index = renoir_get_smu_msg_index,
>  	.get_smu_table_index = renoir_get_smu_table_index, @@ -253,6
> +285,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
>  	.set_power_state = NULL,
>  	.get_dpm_uclk_limited = renoir_get_dpm_uclk_limited,
>  	.print_clk_levels = renoir_print_clk_levels,
> +	.get_current_power_state = renoir_get_current_power_state,
> +
>  };
> 
>  void renoir_set_ppt_funcs(struct smu_context *smu)
> --
> 2.7.4



More information about the amd-gfx mailing list