drm/amd/powerplay: add UMD P-state in powerplay.
Subsystems (2)
PATCH 3/4 drm/amd/powerplay: add UMD P-state in powerplay.
This feature is for UMD to run benchmark in a power state that is as steady as possible. kmd need to fix the power state as stable as possible. now, kmd support four level:
profile_standard,peak,min_sclk,min_mclk
move common related code to amd_powerplay.c
Signed-off-by Rex Zhu <[email protected]>
--- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 47 +++++++++++++++++- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 39 --------------- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 58 ++++------------------ drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 53 +++----------------- drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 4 +- 5 files changed, 66 insertions(+), 135 deletions(-)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +45 -2
@@ -30,7 +30,6 @@#include "pp_instance.h" #include "power_state.h" -static inline int pp_check (struct pp_instance *handle) {if (handle ==NULL || handle->pp_valid !=PP_VALID )
@@ -287,6 +286,42 @@ static int pp_dpm_fw_loading_complete(void *handle)return 0 ; } +static void pp_dpm_en_umd_pstate (struct pp_hwmgr *hwmgr, +enum amd_dpm_forced_level *level) +{ +uint32_t profile_mode_mask =AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD | +AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK | +AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK | +AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ; + +if (!(hwmgr->dpm_level & profile_mode_mask)) { +/* enter umd pstate, save current level, disable gfx cg*/ +if (*level & profile_mode_mask) { + hwmgr->saved_dpm_level = hwmgr->dpm_level; + hwmgr->en_umd_pstate = true; +cgs_set_clockgating_state (hwmgr->device, +AMD_IP_BLOCK_TYPE_GFX , +AMD_CG_STATE_UNGATE ); +cgs_set_powergating_state (hwmgr->device, +AMD_IP_BLOCK_TYPE_GFX , +AMD_PG_STATE_UNGATE ); + } + }else { +/* exit umd pstate, restore level, enable gfx cg*/ +if (!(*level & profile_mode_mask)) { +if (*level ==AMD_DPM_FORCED_LEVEL_PROFILE_EXIT ) + *level = hwmgr->saved_dpm_level; + hwmgr->en_umd_pstate = false; +cgs_set_clockgating_state (hwmgr->device, +AMD_IP_BLOCK_TYPE_GFX , +AMD_CG_STATE_GATE ); +cgs_set_powergating_state (hwmgr->device, +AMD_IP_BLOCK_TYPE_GFX , +AMD_PG_STATE_GATE ); + } + } +} +static int pp_dpm_force_performance_level (void *handle,enum amd_dpm_forced_level level) {
@@ -301,14 +336,22 @@ static int pp_dpm_force_performance_level(void *handle, hwmgr = pp_handle->hwmgr; +if (level == hwmgr->dpm_level) +return 0 ; +if (hwmgr->hwmgr_func->force_dpm_level ==NULL ) {pr_info ("%s was not implemented.\n" , __func__);return 0 ; }mutex_lock (&pp_handle->pp_lock); +pp_dpm_en_umd_pstate (hwmgr, &level); + hwmgr->request_dpm_level = level;hwmgr_handle_task (pp_handle,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ,NULL ); - hwmgr->hwmgr_func->force_dpm_level (hwmgr, level); + ret = hwmgr->hwmgr_func->force_dpm_level (hwmgr, level); +if (!ret) + hwmgr->dpm_level = hwmgr->request_dpm_level; +mutex_unlock (&pp_handle->pp_lock);return 0 ; }
drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +0 -39
@@ -1353,63 +1353,24 @@ static int cz_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, {uint32_t sclk =0 ;int ret =0 ; -uint32_t profile_mode_mask =AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD | -AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK | -AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ; - -if (level == hwmgr->dpm_level) -return ret; - -if (!(hwmgr->dpm_level & profile_mode_mask)) { -/* enter profile mode, save current level, disable gfx cg*/ -if (level & profile_mode_mask) { - hwmgr->saved_dpm_level = hwmgr->dpm_level; -cgs_set_clockgating_state (hwmgr->device, -AMD_IP_BLOCK_TYPE_GFX , -AMD_CG_STATE_UNGATE ); - } - }else { -/* exit profile mode, restore level, enable gfx cg*/ -if (!(level & profile_mode_mask)) { -if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_EXIT ) - level = hwmgr->saved_dpm_level; -cgs_set_clockgating_state (hwmgr->device, -AMD_IP_BLOCK_TYPE_GFX , -AMD_CG_STATE_GATE ); - } - }switch (level) {case AMD_DPM_FORCED_LEVEL_HIGH :case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK : ret =cz_phm_force_dpm_highest (hwmgr); -if (ret) -return ret; - hwmgr->dpm_level = level;break ;case AMD_DPM_FORCED_LEVEL_LOW :case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK : ret =cz_phm_force_dpm_lowest (hwmgr); -if (ret) -return ret; - hwmgr->dpm_level = level;break ;case AMD_DPM_FORCED_LEVEL_AUTO : ret =cz_phm_unforce_dpm_levels (hwmgr); -if (ret) -return ret; - hwmgr->dpm_level = level;break ;case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD : ret =cz_get_profiling_clk (hwmgr, &sclk); -if (ret) -return ret; - hwmgr->dpm_level = level;cz_phm_force_dpm_sclk (hwmgr, sclk);break ;case AMD_DPM_FORCED_LEVEL_MANUAL : - hwmgr->dpm_level = level; -break ;case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT :default :break ;
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +10 -48
96 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +8 -45
90 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +3 -1
@@ -747,6 +747,7 @@ struct pp_hwmgr {enum amd_dpm_forced_level dpm_level;enum amd_dpm_forced_level saved_dpm_level; +enum amd_dpm_forced_level request_dpm_level;bool block_hw_access;struct phm_gfx_arbiter gfx_arbiter;struct phm_acp_arbiter acp_arbiter;
@@ -786,12 +787,13 @@ struct pp_hwmgr {struct amd_pp_display_configuration display_config;uint32_t feature_mask; -/* power profile */ +/* UMD Pstate */ struct amd_pp_profile gfx_power_profile;struct amd_pp_profile compute_power_profile;struct amd_pp_profile default_gfx_power_profile;struct amd_pp_profile default_compute_power_profile;enum amd_pp_profile_type current_power_profile; +bool en_umd_pstate; };extern int hwmgr_early_init (struct pp_instance *handle);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx