drm/amd/pm: refactor PPT limit runtime policy
Subsystems (3)
cover drm/amd/pm: refactor PPT limit runtime policy
PPT limit handling combines controller identity, AC/DC source, immutable capabilities, PMFW runtime state, and persistent user policy in scalar state. This prevents the driver from representing PPT0/PPT1 independently and leaves user limits vulnerable to PMFW reset.
The runtime model requires separate ownership for each class of data:
- PPTable-derived ranges define normal and OD capabilities.
- PMFW messages and tables define the effective runtime limit.
- Common user-profile state defines persistent policy by source and controller.
The four patches establish these boundaries:
- Index common ranges by AC/DC source and PPT0/PPT1 controller; pass the controller through get and set callbacks.
- Account for PMFW protocols that represent an effective limit as a message base plus an OD percentage.
- Save user values and validity masks by source and controller; restore them after suspend and live AC/DC transitions.
- Restore the saved PPT policy after GPU reset reinitializes PMFW and the platform power table.
The resulting policy preserves explicit user limits without caching mutable PMFW current values.
Yang Wang (4):
drm/amd/pm: refactor PPT limits by controller and power source drm/amd/pm: account for OD percentage in effective PPT limits drm/amd/pm: refactor user PPT policy save and restore drm/amd/pm: restore user PPT limits after GPU reset
drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 222 ++++++++++-------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 63 ++--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h | 15 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 11 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h | 11 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h | 11 +- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 52 ++-- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 78 +++--- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 122 +++++----- .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 23 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 118 ++++------ .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 93 ++++---- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 23 +- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 123 ++++++---- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 124 +++++----- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 123 ++++++---- .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c | 23 +- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 123 ++++++---- .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 23 +- .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 122 +++++----- drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 +- 22 files changed, 792 insertions(+), 716 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/4 drm/amd/pm: refactor PPT limits by controller and power source
The scalar PPT model has several structural limitations:
- Controller identity, power source, capability, and PMFW state share the same fields.
- Combined callbacks cannot address PPT0 and PPT1 independently.
- Cached current limits can become stale after PMFW reset.
Refactor the model around these rules:
- Index ranges by AC/DC source and PPT0/PPT1 controller.
- Store normal and overdrive capabilities separately.
- Pass the controller to get and set callbacks.
- Keep slow and fast names as semantic aliases.
Assign each value to a single owner:
- PPTable or platform initialization supplies constant capabilities.
- PMFW supplies runtime state.
- Common code selects the active source and overdrive range.
Van Gogh defaults are initialized once, while firmware without PPT query support remains usable. Capable SMU 13.0.6 and SMU 15.0.8 platforms expose PPT1 through the same interface. A writable controller must also provide a setter callback.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 150 +++++++++--------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 60 +++---- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h | 15 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 11 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h | 11 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h | 11 +- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 52 +++--- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 78 ++++----- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 122 +++++++------- .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 23 +-- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 118 ++++++-------- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 93 +++++------ .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 23 +-- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 114 +++++++------ .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 124 +++++++-------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 114 +++++++------ .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c | 23 +-- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 112 +++++++------ .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 23 +-- .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 122 +++++++------- drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 +- 21 files changed, 707 insertions(+), 695 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +72 -78
@@ -70,7 +70,7 @@ static int smu_handle_task(struct smu_context *smu,static int smu_reset (struct smu_context *smu);static int smu_set_fan_speed_pwm (void *handle,u32 speed);static int smu_set_fan_control_mode (void *handle,u32 value); -static int smu_set_power_limit (void *handle,uint32_t limit_type,uint32_t limit); +static int smu_set_ppt_limit (void *handle,uint32_t limit_type,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);static int smu_set_mp1_state (void *handle,enum pp_mp1_state mp1_state);
@@ -493,8 +493,7 @@ static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_* * @smu: smu_context pointer * -* Restore the saved user power configurations include power limit, -* clock frequencies, fan control mode and fan speed. +* Restore saved user power limits, clock frequencies and fan settings. */ static void smu_restore_dpm_user_profile (struct smu_context *smu) {
@@ -511,13 +510,14 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu) smu->user_dpm_profile.flags |=SMU_DPM_USER_PROFILE_RESTORE ;/* set the user dpm power limits */ -for (int i =SMU_DEFAULT_PPT_LIMIT ; i <SMU_LIMIT_TYPE_COUNT ; i++) { -if (!smu->user_dpm_profile.power_limits[i]) +for (int i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { +if (!smu->user_dpm_profile.ppt_limits[i])continue ; - ret =smu_set_power_limit (smu, i, - smu->user_dpm_profile.power_limits[i]); + ret =smu_set_ppt_limit (smu, i, + smu->user_dpm_profile.ppt_limits[i]);if (ret) -dev_err (smu->adev->dev,"Failed to set %d power limit value\n" , i); +dev_err (smu->adev->dev, +"Failed to set %d PPT limit value\n" , i); }/* set the user dpm clock configurations */
@@ -687,6 +687,7 @@ static int smu_sys_set_pp_table(void *handle, smu_table->hardcode_pptable = hardcode_pptable; smu_table->power_play_table = smu_table->hardcode_pptable; smu_table->power_play_table_size = size; +memset (&smu->ppt_limits,0 ,sizeof (smu->ppt_limits));/* * Special hw_fini action(for Navi1x, the DPMs disablement will be
@@ -951,16 +952,6 @@ static int smu_late_init(struct amdgpu_ip_block *ip_block)return ret; } - ret =smu_get_asic_power_limits (smu, - &smu->current_power_limit, - &smu->default_power_limit, - &smu->max_power_limit, - &smu->min_power_limit); -if (ret) { -dev_err (adev->dev,"Failed to get asic power limits!\n" ); -return ret; - } -if (!amdgpu_sriov_vf (adev))smu_get_unique_id (smu);
@@ -2904,7 +2895,7 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed) }/** -* smu_get_power_limit - Request one of the SMU Power Limits +* smu_get_ppt_limit - Request one of the SMU PPT limits * * @handle: pointer to smu context * @limit: requested limit is written back to this variable
@@ -2913,13 +2904,13 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)* Return: 0 on success, <0 on error * */ -int smu_get_power_limit (void *handle, +int smu_get_ppt_limit (void *handle,uint32_t *limit,enum pp_power_limit_level pp_limit_level,enum pp_power_type pp_power_type) {struct smu_context *smu = handle; -struct amdgpu_device *adev = smu->adev; +enum smu_power_src_type power_source;enum smu_ppt_limit_level limit_level;uint32_t limit_type;int ret =0 ;
@@ -2930,9 +2921,12 @@ int smu_get_power_limit(void *handle,if (!limit)return -EINVAL ; + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; +switch (pp_power_type) {case PP_PWR_TYPE_SUSTAINED : - limit_type =SMU_DEFAULT_PPT_LIMIT ; + limit_type =SMU_SLOW_PPT_LIMIT ;break ;case PP_PWR_TYPE_FAST : limit_type =SMU_FAST_PPT_LIMIT ;
@@ -2958,77 +2952,77 @@ int smu_get_power_limit(void *handle,return -EOPNOTSUPP ; } -if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) { -if (smu->ppt_funcs->get_ppt_limit) - ret = smu->ppt_funcs->get_ppt_limit (smu, limit, limit_type, limit_level); -else -return -EOPNOTSUPP ; - }else { -switch (limit_level) { -case SMU_PPT_LIMIT_CURRENT : -switch (amdgpu_ip_version (adev,MP1_HWIP ,0 )) { -case IP_VERSION (13 ,0 ,2 ): -case IP_VERSION (13 ,0 ,6 ): -case IP_VERSION (13 ,0 ,12 ): -case IP_VERSION (13 ,0 ,14 ): -case IP_VERSION (11 ,0 ,7 ): -case IP_VERSION (11 ,0 ,11 ): -case IP_VERSION (11 ,0 ,12 ): -case IP_VERSION (11 ,0 ,13 ): -case IP_VERSION (15 ,0 ,8 ): - ret =smu_get_asic_power_limits (smu, - &smu->current_power_limit, -NULL ,NULL ,NULL ); -break ; -default : -break ; - } - *limit = smu->current_power_limit; -break ; -case SMU_PPT_LIMIT_DEFAULT : - *limit = smu->default_power_limit; -break ; -case SMU_PPT_LIMIT_MAX : - *limit = smu->max_power_limit; -break ; -case SMU_PPT_LIMIT_MIN : - *limit = smu->min_power_limit; -break ; -default : -return -EINVAL ; - } +if (!(smu->ppt_limits.supported_mask &BIT (limit_type))) +return -EOPNOTSUPP ; + +switch (limit_level) { +case SMU_PPT_LIMIT_CURRENT : + ret =smu_get_asic_ppt_limit (smu, limit_type, limit); +break ; +case SMU_PPT_LIMIT_DEFAULT : + *limit = smu->ppt_limits.range[power_source][limit_type].default_value; +break ; +case SMU_PPT_LIMIT_MAX : + *limit = smu->od_enabled ? + smu->ppt_limits.range[power_source][limit_type].od_max : + smu->ppt_limits.range[power_source][limit_type].max; +break ; +case SMU_PPT_LIMIT_MIN : + *limit = smu->od_enabled ? + smu->ppt_limits.range[power_source][limit_type].od_min : + smu->ppt_limits.range[power_source][limit_type].min; +break ; +default : +return -EINVAL ; }return ret; } -static int smu_set_power_limit (void *handle,uint32_t limit_type,uint32_t limit) +static int smu_set_ppt_limit (void *handle,uint32_t limit_type,uint32_t limit) {struct smu_context *smu = handle; +enum smu_power_src_type power_source; +struct smu_ppt_limit_range *range; +uint32_t min_limit, max_limit;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (limit_type >=SMU_LIMIT_TYPE_COUNT ) +return -EINVAL ; -if (limit_type ==SMU_DEFAULT_PPT_LIMIT ) { -if (!limit) - limit = smu->current_power_limit; -if ((limit > smu->max_power_limit) || (limit < smu->min_power_limit)) { -dev_err (smu->adev->dev, -"New power limit (%d) is out of range [%d,%d]\n" , - limit, smu->min_power_limit, smu->max_power_limit); -return -EINVAL ; - } - } + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; + range = &smu->ppt_limits.range[power_source][limit_type]; + min_limit = smu->od_enabled ? range->od_min : range->min; + max_limit = smu->od_enabled ? range->od_max : range->max; -if (smu->ppt_funcs->set_power_limit) { - ret = smu->ppt_funcs->set_power_limit (smu, limit_type, limit); +if (!(smu->ppt_limits.supported_mask &BIT (limit_type))) +return -EOPNOTSUPP ; + +if (limit_type ==SMU_DEFAULT_PPT_LIMIT && !limit) { + ret =smu_get_asic_ppt_limit (smu, limit_type, &limit);if (ret)return ret; -if (!(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) - smu->user_dpm_profile.power_limits[limit_type] = limit; } +if (limit > max_limit || limit < min_limit) { +dev_err (smu->adev->dev, +"New PPT limit (%d) is out of range [%d,%d]\n" , + limit, min_limit, max_limit); +return -EINVAL ; + } + +if (!smu->ppt_funcs->set_ppt_limit) +return -EOPNOTSUPP ; + + ret = smu->ppt_funcs->set_ppt_limit (smu, limit_type, limit); +if (ret) +return ret; +if (!(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) + smu->user_dpm_profile.ppt_limits[limit_type] = limit; +return 0 ; }
@@ -3974,8 +3968,8 @@ static const struct amd_pm_funcs swsmu_pm_funcs = { .dispatch_tasks = smu_handle_dpm_task, .load_firmware = smu_load_microcode, .set_powergating_by_smu = smu_dpm_set_power_gate, - .set_power_limit = smu_set_power_limit, - .get_power_limit = smu_get_power_limit, + .set_power_limit = smu_set_ppt_limit, + .get_power_limit = smu_get_ppt_limit, .get_power_profile_mode = smu_get_power_profile_mode, .set_power_profile_mode = smu_set_power_profile_mode, .odn_edit_dpm_table = smu_od_edit_dpm_table,
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +33 -27
105 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h +6 -9
@@ -108,10 +108,6 @@ struct smu_11_5_power_context {uint32_t power_source;uint8_t in_power_limit_boost_mode;enum smu_11_0_power_state power_state; - -uint32_t current_fast_ppt_limit; -uint32_t default_fast_ppt_limit; -uint32_t max_fast_ppt_limit; };#if defined(SWSMU_CODE_LAYER_L2 ) || defined(SWSMU_CODE_LAYER_L3 )
@@ -151,12 +147,13 @@ int smu_v11_0_set_allowed_mask(struct smu_context *smu);int smu_v11_0_notify_display_change (struct smu_context *smu); -int smu_v11_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit); +int smu_v11_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit); -int smu_v11_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit); +int smu_v11_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit);int smu_v11_0_init_max_sustainable_clocks (struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +6 -5
@@ -145,12 +145,13 @@ int smu_v13_0_set_allowed_mask(struct smu_context *smu);int smu_v13_0_notify_display_change (struct smu_context *smu); -int smu_v13_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit); +int smu_v13_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit); -int smu_v13_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit); +int smu_v13_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit);int smu_v13_0_init_max_sustainable_clocks (struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h +6 -5
@@ -132,12 +132,13 @@ int smu_v14_0_set_allowed_mask(struct smu_context *smu);int smu_v14_0_notify_display_change (struct smu_context *smu); -int smu_v14_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit); +int smu_v14_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit); -int smu_v14_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit); +int smu_v14_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit);int smu_v14_0_gfx_off_control (struct smu_context *smu,bool enable);
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h +6 -5
@@ -142,12 +142,13 @@ int smu_v15_0_set_allowed_mask(struct smu_context *smu);int smu_v15_0_notify_display_change (struct smu_context *smu); -int smu_v15_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit); +int smu_v15_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit); -int smu_v15_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit); +int smu_v15_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit);int smu_v15_0_gfx_off_control (struct smu_context *smu,bool enable);
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +29 -23
91 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +40 -38
126 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +68 -54
185 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +12 -11
@@ -770,14 +770,17 @@ int smu_v11_0_init_max_sustainable_clocks(struct smu_context *smu)return 0 ; } -int smu_v11_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit) +int smu_v11_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit) {int power_src;int ret =0 ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT ))return -EINVAL ; +if (limit_type !=SMU_PPT_LIMIT_PPT0 ) +return -EOPNOTSUPP ; power_src = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_PWR,
@@ -794,26 +797,26 @@ int smu_v11_0_get_current_power_limit(struct smu_context *smu, ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_GetPptLimit, (0 <<24 ) | (power_src <<16 ), - power_limit); + ppt_limit);if (ret)dev_err (smu->adev->dev,"[%s] get PPT limit failed!" , __func__);return ret; } -int smu_v11_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit) +int smu_v11_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit) {int power_src;int ret =0 ;uint32_t limit_param; -if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) +if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT )) { -dev_err (smu->adev->dev,"Setting new power limit is not supported!\n" ); +dev_err (smu->adev->dev,"Setting new PPT limit is not supported!\n" );return -EOPNOTSUPP ; }
@@ -835,12 +838,10 @@ int smu_v11_0_set_power_limit(struct smu_context *smu, limit_param |= (power_src) <<16 ; ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetPptLimit, limit_param,NULL );if (ret) { -dev_err (smu->adev->dev,"[%s] Set power limit Failed!\n" , __func__); +dev_err (smu->adev->dev,"[%s] Set PPT limit failed!\n" , __func__);return ret; } - smu->current_power_limit = limit; -return 0 ; }
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +49 -69
183 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +43 -50
144 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +12 -11
@@ -815,14 +815,17 @@ int smu_v13_0_init_max_sustainable_clocks(struct smu_context *smu)return 0 ; } -int smu_v13_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit) +int smu_v13_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit) {int power_src;int ret =0 ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT ))return -EINVAL ; +if (limit_type !=SMU_PPT_LIMIT_PPT0 ) +return -EOPNOTSUPP ; power_src = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_PWR,
@@ -835,35 +838,33 @@ int smu_v13_0_get_current_power_limit(struct smu_context *smu, ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_GetPptLimit, power_src <<16 , - power_limit); + ppt_limit);if (ret)dev_err (smu->adev->dev,"[%s] get PPT limit failed!" , __func__);return ret; } -int smu_v13_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit) +int smu_v13_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit) {int ret =0 ; -if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) +if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT )) { -dev_err (smu->adev->dev,"Setting new power limit is not supported!\n" ); +dev_err (smu->adev->dev,"Setting new PPT limit is not supported!\n" );return -EOPNOTSUPP ; } ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetPptLimit, limit,NULL );if (ret) { -dev_err (smu->adev->dev,"[%s] Set power limit Failed!\n" , __func__); +dev_err (smu->adev->dev,"[%s] Set PPT limit failed!\n" , __func__);return ret; } - smu->current_power_limit = limit; -return 0 ; }
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +63 -51
180 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +59 -65
184 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +63 -51
180 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c +12 -11
@@ -667,14 +667,17 @@ int smu_v14_0_notify_display_change(struct smu_context *smu)return ret; } -int smu_v14_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit) +int smu_v14_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit) {int power_src;int ret =0 ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT ))return -EINVAL ; +if (limit_type !=SMU_PPT_LIMIT_PPT0 ) +return -EOPNOTSUPP ; power_src = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_PWR,
@@ -687,35 +690,33 @@ int smu_v14_0_get_current_power_limit(struct smu_context *smu, ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_GetPptLimit, power_src <<16 , - power_limit); + ppt_limit);if (ret)dev_err (smu->adev->dev,"[%s] get PPT limit failed!" , __func__);return ret; } -int smu_v14_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit) +int smu_v14_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit) {int ret =0 ; -if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) +if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT )) { -dev_err (smu->adev->dev,"Setting new power limit is not supported!\n" ); +dev_err (smu->adev->dev,"Setting new PPT limit is not supported!\n" );return -EOPNOTSUPP ; } ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetPptLimit, limit,NULL );if (ret) { -dev_err (smu->adev->dev,"[%s] Set power limit Failed!\n" , __func__); +dev_err (smu->adev->dev,"[%s] Set PPT limit failed!\n" , __func__);return ret; } - smu->current_power_limit = limit; -return 0 ; }
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +61 -51
179 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +12 -11
@@ -618,14 +618,17 @@ int smu_v15_0_notify_display_change(struct smu_context *smu)return ret; } -int smu_v15_0_get_current_power_limit (struct smu_context *smu, -uint32_t *power_limit) +int smu_v15_0_get_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t *ppt_limit) {int power_src;int ret =0 ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT ))return -EINVAL ; +if (limit_type !=SMU_PPT_LIMIT_PPT0 ) +return -EOPNOTSUPP ; power_src = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_PWR,
@@ -638,35 +641,33 @@ int smu_v15_0_get_current_power_limit(struct smu_context *smu, ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_GetPptLimit, power_src <<16 , - power_limit); + ppt_limit);if (ret)dev_err (smu->adev->dev,"[%s] get PPT limit failed!" , __func__);return ret; } -int smu_v15_0_set_power_limit (struct smu_context *smu, -enum smu_ppt_limit_type limit_type, -uint32_t limit) +int smu_v15_0_set_ppt_limit (struct smu_context *smu, +enum smu_ppt_limit_type limit_type, +uint32_t limit) {int ret =0 ; -if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) +if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ;if (!smu_cmn_feature_is_enabled (smu,SMU_FEATURE_PPT_BIT )) { -dev_err (smu->adev->dev,"Setting new power limit is not supported!\n" ); +dev_err (smu->adev->dev,"Setting new PPT limit is not supported!\n" );return -EOPNOTSUPP ; } ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetPptLimit, limit,NULL );if (ret) { -dev_err (smu->adev->dev,"[%s] Set power limit Failed!\n" , __func__); +dev_err (smu->adev->dev,"[%s] Set PPT limit failed!\n" , __func__);return ret; } - smu->current_power_limit = limit; -return 0 ; }
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +53 -69
173 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +2 -1
@@ -82,7 +82,8 @@#define smu_i2c_fini (smu) smu_ppt_funcs(i2c_fini, 0, smu)#define smu_get_unique_id (smu) smu_ppt_funcs(get_unique_id, 0, smu)#define smu_log_thermal_throttling (smu) smu_ppt_funcs(log_thermal_throttling_event, 0, smu) -#define smu_get_asic_power_limits (smu, current, default, max, min) smu_ppt_funcs(get_power_limit, 0, smu, current, default, max, min) +#define smu_get_asic_ppt_limit (smu, type, current) \ + smu_ppt_funcs(get_ppt_limit, -EOPNOTSUPP, smu, type, current)#define smu_get_pp_feature_mask (smu, buf) smu_ppt_funcs(get_pp_feature_mask, 0, smu, buf)#define smu_set_pp_feature_mask (smu, new_mask) smu_ppt_funcs(set_pp_feature_mask, 0, smu, new_mask)#define smu_gfx_ulv_control (smu, enablement) smu_ppt_funcs(gfx_ulv_control, 0, smu, enablement)
Signature · 1 line
2.54.0
PATCH 2/4 drm/amd/pm: account for OD percentage in effective PPT limits
In reply to Yang WangSMU 13.0.0, SMU 13.0.7, and SMU 14.0.2 represent limits above the message limit as a base value plus an overdrive percentage. GetPptLimit returns only the base, which causes two incorrect results:
- hwmon reports the message limit instead of the effective limit.
- Lowering the cap can leave the previous OD percentage active.
Export the active overdrive table from PMFW and combine its PPT percentage with the message result. Use the exported percentage to clear OD state before programming a limit within the message range.
--- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 +++++++++++------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 +++++++++++------- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 37 ++++++++++++------- 3 files changed, 65 insertions(+), 42 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +21 -14
@@ -2394,17 +2394,23 @@ static int smu_v13_0_0_get_ppt_limit(struct smu_context *smu,enum smu_ppt_limit_type limit_type, uint32_t *ppt_limit) { - PPTable_t *pptable = smu->smu_table.driver_pptable; -SkuTable_t *skutable = &pptable->SkuTable; -uint32_t pp_limit = smu->adev->pm.ac_power ? - skutable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ] : - skutable->SocketPowerLimitDc[PPT_THROTTLER_PPT0 ]; + OverDriveTableExternal_t od_table; +int ret;if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EOPNOTSUPP ; -if (smu_v13_0_get_ppt_limit (smu, limit_type, ppt_limit)) - *ppt_limit = pp_limit; + ret =smu_v13_0_get_ppt_limit (smu, limit_type, ppt_limit); +if (ret) +return ret; + + ret =smu_v13_0_0_get_overdrive_table (smu, &od_table); +if (ret) +return ret; + +if (od_table.OverDriveTable.Ppt >0 ) + *ppt_limit = *ppt_limit * + (100 + od_table.OverDriveTable.Ppt) /100 ;return 0 ; }
@@ -3045,22 +3051,23 @@ static int smu_v13_0_0_set_ppt_limit(struct smu_context *smu, {PPTable_t *pptable = smu->smu_table.driver_pptable;SkuTable_t *skutable = &pptable->SkuTable; -uint32_t msg_limit = skutable->MsgLimits.Power[PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ]; +uint32_t msg_limit = skutable->MsgLimits.Power + [PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ];struct smu_table_context *table_context = &smu->smu_table;OverDriveTableExternal_t *od_table = (OverDriveTableExternal_t *)table_context->overdrive_table; -uint32_t current_limit; +OverDriveTableExternal_t current_od_table;int ret =0 ;if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ; - ret =smu_v13_0_0_get_ppt_limit (smu, limit_type, ¤t_limit); -if (ret) -return ret; -if (limit <= msg_limit) { -if (current_limit > msg_limit) { + ret =smu_v13_0_0_get_overdrive_table (smu, ¤t_od_table); +if (ret) +return ret; + +if (current_od_table.OverDriveTable.Ppt) { od_table->OverDriveTable.Ppt =0 ; od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +21 -14
@@ -2376,17 +2376,23 @@ static int smu_v13_0_7_get_ppt_limit(struct smu_context *smu,enum smu_ppt_limit_type limit_type, uint32_t *ppt_limit) { - PPTable_t *pptable = smu->smu_table.driver_pptable; -SkuTable_t *skutable = &pptable->SkuTable; -uint32_t pp_limit = smu->adev->pm.ac_power ? - skutable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ] : - skutable->SocketPowerLimitDc[PPT_THROTTLER_PPT0 ]; + OverDriveTableExternal_t od_table; +int ret;if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EOPNOTSUPP ; -if (smu_v13_0_get_ppt_limit (smu, limit_type, ppt_limit)) - *ppt_limit = pp_limit; + ret =smu_v13_0_get_ppt_limit (smu, limit_type, ppt_limit); +if (ret) +return ret; + + ret =smu_v13_0_7_get_overdrive_table (smu, &od_table); +if (ret) +return ret; + +if (od_table.OverDriveTable.Ppt >0 ) + *ppt_limit = *ppt_limit * + (100 + od_table.OverDriveTable.Ppt) /100 ;return 0 ; }
@@ -2665,22 +2671,23 @@ static int smu_v13_0_7_set_ppt_limit(struct smu_context *smu, {PPTable_t *pptable = smu->smu_table.driver_pptable;SkuTable_t *skutable = &pptable->SkuTable; -uint32_t msg_limit = skutable->MsgLimits.Power[PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ]; +uint32_t msg_limit = skutable->MsgLimits.Power + [PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ];struct smu_table_context *table_context = &smu->smu_table;OverDriveTableExternal_t *od_table = (OverDriveTableExternal_t *)table_context->overdrive_table; -uint32_t current_limit; +OverDriveTableExternal_t current_od_table;int ret =0 ;if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ; - ret =smu_v13_0_7_get_ppt_limit (smu, limit_type, ¤t_limit); -if (ret) -return ret; -if (limit <= msg_limit) { -if (current_limit > msg_limit) { + ret =smu_v13_0_7_get_overdrive_table (smu, ¤t_od_table); +if (ret) +return ret; + +if (current_od_table.OverDriveTable.Ppt) { od_table->OverDriveTable.Ppt =0 ; od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ;
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +23 -14
@@ -60,6 +60,8 @@ static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu,int od_feature_bit, int32_t *min, int32_t *max);static int smu_v14_0_2_init_ppt_limits (struct smu_context *smu); +static int smu_v14_0_2_get_overdrive_table (struct smu_context *smu, +OverDriveTableExternal_t *od_table);static const struct smu_feature_bits smu_v14_0_2_dpm_features = { .bits = {SMU_FEATURE_BIT_INIT (FEATURE_DPM_GFXCLK_BIT ),
@@ -1615,17 +1617,23 @@ static int smu_v14_0_2_get_ppt_limit(struct smu_context *smu,enum smu_ppt_limit_type limit_type, uint32_t *ppt_limit) { - PPTable_t *pptable = smu->smu_table.driver_pptable; -CustomSkuTable_t *skutable = &pptable->CustomSkuTable; -uint32_t pp_limit = smu->adev->pm.ac_power ? - skutable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ] : - skutable->SocketPowerLimitDc[PPT_THROTTLER_PPT0 ]; + OverDriveTableExternal_t od_table; +int ret;if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EOPNOTSUPP ; -if (smu_v14_0_get_ppt_limit (smu, limit_type, ppt_limit)) - *ppt_limit = pp_limit; + ret =smu_v14_0_get_ppt_limit (smu, limit_type, ppt_limit); +if (ret) +return ret; + + ret =smu_v14_0_2_get_overdrive_table (smu, &od_table); +if (ret) +return ret; + +if (od_table.OverDriveTable.Ppt >0 ) + *ppt_limit = *ppt_limit * + (100 + od_table.OverDriveTable.Ppt) /100 ;return 0 ; }
@@ -2800,22 +2808,23 @@ static int smu_v14_0_2_set_ppt_limit(struct smu_context *smu, uint32_t limit) {PPTable_t *pptable = smu->smu_table.driver_pptable; -uint32_t msg_limit = pptable->SkuTable.MsgLimits.Power[PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ]; +uint32_t msg_limit = pptable->SkuTable.MsgLimits.Power + [PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ];struct smu_table_context *table_context = &smu->smu_table;OverDriveTableExternal_t *od_table = (OverDriveTableExternal_t *)table_context->overdrive_table; -uint32_t current_limit; +OverDriveTableExternal_t current_od_table;int ret =0 ;if (limit_type !=SMU_PPT_LIMIT_PPT0 )return -EINVAL ; - ret =smu_v14_0_2_get_ppt_limit (smu, limit_type, ¤t_limit); -if (ret) -return ret; -if (limit <= msg_limit) { -if (current_limit > msg_limit) { + ret =smu_v14_0_2_get_overdrive_table (smu, ¤t_od_table); +if (ret) +return ret; + +if (current_od_table.OverDriveTable.Ppt) { od_table->OverDriveTable.Ppt =0 ; od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ;
Signature · 1 line
2.54.0
PATCH 3/4 drm/amd/pm: refactor user PPT policy save and restore
In reply to Yang WangThe existing user policy representation has three ambiguities:
- A numeric value cannot distinguish explicit zero from an unset policy.
- One value per controller cannot preserve independent AC and DC requests.
- Suspend-only restore misses runtime resume, GPU reset, and table reload.
Refactor policy storage and restore as follows:
- Store values and validity masks by power source and PPT controller.
- Save writes against the active source.
- Restore the active source after default SMU setup.
- Reapply the target policy after live AC/DC transitions.
- Use the target source default when no explicit request exists.
The late-init path now covers system resume, runtime resume, GPU reset, and custom PPTable reload. Common code owns persistent policy; PMFW continues to own effective current limits.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 89 +++++++++++++------ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 +- 3 files changed, 68 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
@@ -508,7 +508,7 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)amdgpu_dpm_notify_ac_dc (adev);if (is_support_sw_smu (adev)) -smu_set_ac_dc (adev->powerplay.pp_handle); +smu_set_ac_dc (adev->powerplay.pp_handle, true);mutex_unlock (&adev->pm.mutex); }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +64 -25
138 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +3 -2
@@ -251,7 +251,8 @@ enum smu_memory_pool_size {struct smu_user_dpm_profile {uint32_t fan_mode; -uint32_t ppt_limits[SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limits[SMU_POWER_SOURCE_COUNT ][SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limit_user_mask[SMU_POWER_SOURCE_COUNT ];uint32_t fan_speed_pwm;uint32_t fan_speed_rpm;uint32_t flags;
@@ -1953,7 +1954,7 @@ int smu_set_soft_freq_range(struct smu_context *smu, enum pp_clock_type clk_typeint smu_set_gfx_power_up_by_imu (struct smu_context *smu); -int smu_set_ac_dc (struct smu_context *smu); +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy);int smu_set_xgmi_plpd_mode (struct smu_context *smu,enum pp_xgmi_plpd_mode mode);
Signature · 1 line
2.54.0
PATCH 4/4 drm/amd/pm: restore user PPT limits after GPU reset
In reply to Yang WangGPU reset reinitializes PMFW and reloads the platform power table. The saved user policy remains valid, but suspend-only restore does not run because adev->in_suspend is clear.
Restore the active PPT policy from SMU late initialization while the device is in reset recovery. Route each value through the common range validation and ASIC setter before updating PMFW.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
@@ -28,6 +28,7 @@#include <linux/reboot.h> #include "amdgpu.h" +#include "amdgpu_reset.h" #include "amdgpu_smu.h" #include "smu_internal.h" #include "atom.h"
@@ -996,7 +997,7 @@ static int smu_late_init(struct amdgpu_ip_block *ip_block)return ret; } -if (adev->in_suspend) +if (adev->in_suspend ||amdgpu_reset_in_recovery (adev))smu_restore_ppt_limits (smu, false);smu_restore_dpm_user_profile (smu);
Signature · 1 line
2.54.0
Feng, Kenneth
maintainerAMD General
Series is Reviewed-by: Kenneth Feng <[email protected]>
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yang Wang
Sent: Friday, July 31, 2026 11:10 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 0/4] drm/amd/pm: refactor PPT limit runtime policy
PPT limit handling combines controller identity, AC/DC source, immutable capabilities, PMFW runtime state, and persistent user policy in scalar state. This prevents the driver from representing PPT0/PPT1 independently and leaves user limits vulnerable to PMFW reset.
The runtime model requires separate ownership for each class of data:
- PPTable-derived ranges define normal and OD capabilities.
- PMFW messages and tables define the effective runtime limit.
- Common user-profile state defines persistent policy by source and controller.
The four patches establish these boundaries:
- Index common ranges by AC/DC source and PPT0/PPT1 controller; pass the controller through get and set callbacks.
- Account for PMFW protocols that represent an effective limit as a message base plus an OD percentage.
- Save user values and validity masks by source and controller; restore them after suspend and live AC/DC transitions.
- Restore the saved PPT policy after GPU reset reinitializes PMFW and the platform power table.
The resulting policy preserves explicit user limits without caching mutable PMFW current values.
Yang Wang (4):
drm/amd/pm: refactor PPT limits by controller and power source drm/amd/pm: account for OD percentage in effective PPT limits drm/amd/pm: refactor user PPT policy save and restore drm/amd/pm: restore user PPT limits after GPU reset
drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 222 ++++++++++-------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 63 ++--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h | 15 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 11 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h | 11 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h | 11 +- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 52 ++-- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 78 +++--- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 122 +++++----- .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 23 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 118 ++++------ .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 93 ++++---- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 23 +- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 123 ++++++---- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 124 +++++----- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 123 ++++++---- .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c | 23 +- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 123 ++++++---- .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 23 +- .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 122 +++++----- drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 +- 22 files changed, 792 insertions(+), 716 deletions(-)
--
2.54.0
Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restore
In reply to Yang WangQuoted 63 lines · Yang Wang
The existing user policy representation has three ambiguities:
- A numeric value cannot distinguish explicit zero from an unset policy.
- One value per controller cannot preserve independent AC and DC requests.
- Suspend-only restore misses runtime resume, GPU reset, and table reload.Refactor policy storage and restore as follows:
- Store values and validity masks by power source and PPT controller.
- Save writes against the active source.
- Restore the active source after default SMU setup.
- Reapply the target policy after live AC/DC transitions.
- Use the target source default when no explicit request exists.The late-init path now covers system resume, runtime resume, GPU reset, and custom PPTable reload. Common code owns persistent policy; PMFW continues to own effective current limits.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 89 +++++++++++++------ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 +- 3 files changed, 68 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1@@ -508,7 +508,7 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)amdgpu_dpm_notify_ac_dc (adev);if (is_support_sw_smu (adev)) -smu_set_ac_dc (adev->powerplay.pp_handle); +smu_set_ac_dc (adev->powerplay.pp_handle, true);mutex_unlock (&adev->pm.mutex); }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +17
-0@@ -488,12 +488,52 @@ static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_return ; } +static void smu_restore_ppt_limits (struct smu_context *smu, +bool restore_defaults) +{ +enum smu_power_src_type power_source; +struct smu_ppt_limit_range *range; +uint32_t restore_mask; +uint32_t limit; +int i, ret; + + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; + restore_mask = smu->user_dpm_profile.ppt_limit_user_mask[power_source] & + smu->ppt_limits.supported_mask; +if (!restore_mask && !restore_defaults) +return ; + + smu->user_dpm_profile.flags |=SMU_DPM_USER_PROFILE_RESTORE ;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_ · line 517
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +10
-0+ +for (i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { +if (!(smu->ppt_limits.supported_mask &BIT (i))) +continue ; + +if (restore_mask &BIT (i)) { + limit = smu->user_dpm_profile.ppt_limits[power_source][i]; + }else if (restore_defaults) { + range = &smu->ppt_limits.range[power_source][i]; + limit = range->default_value;
This should be restore the current limit before a suspend/reset and not the default limit. The current limit could be set through out of band also, user profile values won't reflect that.
Thanks,
Lijo
Quoted 137 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +37
-25+ }else { +continue ; + } + + ret =smu_set_ppt_limit (smu, i, limit); +if (ret) +dev_err (smu->adev->dev, +"Failed to restore PPT%d limit: %d\n" , i, ret); + } + + smu->user_dpm_profile.flags &= ~SMU_DPM_USER_PROFILE_RESTORE ; +} +/** * smu_restore_dpm_user_profile - reinstate user dpm profile * * @smu: smu_context pointer * -* Restore saved user power limits, clock frequencies and fan settings. +* Restore saved user clock frequencies and fan settings. */ static void smu_restore_dpm_user_profile (struct smu_context *smu) {@@ -509,17 +549,6 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)/* Enable restore flag */ smu->user_dpm_profile.flags |=SMU_DPM_USER_PROFILE_RESTORE ; -/* set the user dpm power limits */ -for (int i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { -if (!smu->user_dpm_profile.ppt_limits[i]) -continue ; - ret =smu_set_ppt_limit (smu, i, - smu->user_dpm_profile.ppt_limits[i]); -if (ret) -dev_err (smu->adev->dev, -"Failed to set %d PPT limit value\n" , i); - } -/* set the user dpm clock configurations */ if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_MANUAL ) {enum smu_clk_type clk_type;@@ -932,7 +961,7 @@ static int smu_late_init(struct amdgpu_ip_block *ip_block)* is unnecessary. */ adev->pm.ac_power =power_supply_is_system_supplied () >0 ; -smu_set_ac_dc (smu); +smu_set_ac_dc (smu, false);if ((amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (13 ,0 ,1 )) || (amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (13 ,0 ,3 )))@@ -967,6 +996,8 @@ static int smu_late_init(struct amdgpu_ip_block *ip_block)return ret; } +if (adev->in_suspend) +smu_restore_ppt_limits (smu, false);smu_restore_dpm_user_profile (smu);return 0 ;@@ -2746,7 +2777,7 @@ static int smu_set_watermarks_for_clock_ranges(void *handle,return smu_set_watermarks_table (smu, clock_ranges); } -int smu_set_ac_dc (struct smu_context *smu) +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy) {int ret =0 ;@@ -2754,17 +2785,22 @@ int smu_set_ac_dc(struct smu_context *smu)return -EOPNOTSUPP ;/* controlled by firmware */ -if (smu->dc_controlled_by_gpio) -return 0 ; +if (!smu->dc_controlled_by_gpio) { + ret =smu_set_power_source (smu, + smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC : +SMU_POWER_SOURCE_DC ); +if (ret) { +dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , + smu->adev->pm.ac_power ?"AC" :"DC" ); +return ret; + } + } - ret =smu_set_power_source (smu, - smu->adev->pm.ac_power ?SMU_POWER_SOURCE_AC : -SMU_POWER_SOURCE_DC ); -if (ret) -dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , - smu->adev->pm.ac_power ?"AC" :"DC" ); +if (restore_ppt_policy) +smu_restore_ppt_limits (smu, true); -return ret; +return 0 ; }const struct amd_ip_funcs smu_ip_funcs = {@@ -3020,8 +3056,11 @@ static int smu_set_ppt_limit(void *handle, uint32_t limit_type, uint32_t limit) ret = smu->ppt_funcs->set_ppt_limit (smu, limit_type, limit);if (ret)return ret; -if (!(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) - smu->user_dpm_profile.ppt_limits[limit_type] = limit; +if (!(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) { + smu->user_dpm_profile.ppt_limits[power_source][limit_type] = limit; + smu->user_dpm_profile.ppt_limit_user_mask[power_source] |= +BIT (limit_type); + }return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +3
-2@@ -251,7 +251,8 @@ enum smu_memory_pool_size {struct smu_user_dpm_profile {uint32_t fan_mode; -uint32_t ppt_limits[SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limits[SMU_POWER_SOURCE_COUNT ][SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limit_user_mask[SMU_POWER_SOURCE_COUNT ];uint32_t fan_speed_pwm;uint32_t fan_speed_rpm;uint32_t flags;@@ -1953,7 +1954,7 @@ int smu_set_soft_freq_range(struct smu_context *smu, enum pp_clock_type clk_typeint smu_set_gfx_power_up_by_imu (struct smu_context *smu); -int smu_set_ac_dc (struct smu_context *smu); +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy);int smu_set_xgmi_plpd_mode (struct smu_context *smu,enum pp_xgmi_plpd_mode mode);
RE: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restore
AMD General
Quoted 84 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 31, 2026 12:57 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restoreQuoted 4 lines · Yang Wang
The existing user policy representation has three ambiguities:
- A numeric value cannot distinguish explicit zero from an unset policy.
- One value per controller cannot preserve independent AC and DCrequests.
Quoted 10 lines
- Suspend-only restore misses runtime resume, GPU reset, and table reload.
Refactor policy storage and restore as follows:
- Store values and validity masks by power source and PPT controller.
- Save writes against the active source.
- Restore the active source after default SMU setup.
- Reapply the target policy after live AC/DC transitions.
- Use the target source default when no explicit request exists.Quoted 8 lines
The late-init path now covers system resume, runtime resume, GPU reset, and custom PPTable reload. Common code owns persistent policy; PMFW continues to own effective current limits.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 89 +++++++++++++------
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_acpi_event_handler(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 +- 3 files changed, 68 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -508,7 +508,7 @@ void amdgpu_pm_acpi_event_handler(struct
amdgpu_device*adev)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void
Quoted 14 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1amdgpu_dpm_notify_ac_dc (adev);if (is_support_sw_smu (adev)) -smu_set_ac_dc (adev->powerplay.pp_handle); +smu_set_ac_dc (adev->powerplay.pp_handle, true);mutex_unlock (&adev->pm.mutex); }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -488,12 +488,52 @@ static voidsmu_set_user_clk_dependencies(struct
smu_context*smu, enumsmu_clk_Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +12
-0return ; } +static void smu_restore_ppt_limits (struct smu_context *smu, +bool restore_defaults) +{ +enum smu_power_src_type power_source; +struct smu_ppt_limit_range *range; +uint32_t restore_mask; +uint32_t limit; +int i, ret; + + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; + restore_mask = smu-user_dpm_profile.ppt_limit_user_mask[power_source] &
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+ smu->ppt_limits.supported_mask; +if (!restore_mask && !restore_defaults) +return ; + + smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;
Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_ · line 517
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-0+ +for (i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { +if (!(smu->ppt_limits.supported_mask &BIT (i))) +continue ; + +if (restore_mask &BIT (i)) { + limit = smu-user_dpm_profile.ppt_limits[power_source][i];
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ }else if (restore_defaults) { + range = &smu->ppt_limits.range[power_source][i]; + limit = range->default_value;This should be restore the current limit before a suspend/reset and not the default limit. The current limit could be set through out of band also, user profile values won't reflect that.
Please check the call sites.
The quoted default path is an opt-in fallback for AC/DC policy restore, and it is not used for suspend or GPU reset. Suspend and reset invoke smu_restore_ppt_limits(smu, false), which replays only limits recorded in user_dpm_profile.
The profile intentionally does not represent out-of-band state,
and the amdgpu driver has no ownership or synchronization contract for PMFW limits changed outside the driver. Supporting that use case requires separate policy and should be addressed in a separate change.
Best Regards,
Kevin
Quoted 158 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11
-0+ }else { +continue ; + } + + ret =smu_set_ppt_limit (smu, i, limit); +if (ret) +dev_err (smu->adev->dev, +"Failed to restore PPT%d limit: %d\n" , i, ret); + } + + smu->user_dpm_profile.flags &=~SMU_DPM_USER_PROFILE_RESTORE; }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1+/** * smu_restore_dpm_user_profile - reinstate user dpm profile * * @smu: smu_context pointer * -* Restore saved user power limits, clock frequencies and fan settings. +* Restore saved user clock frequencies and fan settings. */ static void smu_restore_dpm_user_profile (struct smu_context *smu) {@@ -509,17 +549,6 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct · line 550
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0/* Enable restore flag */ smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-4-/* set the user dpm power limits */ -for (int i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { -if (!smu->user_dpm_profile.ppt_limits[i]) -continue ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-7- ret =smu_set_ppt_limit (smu, i, - smu- user_dpm_profile.ppt_limits[i]); -if (ret) -dev_err (smu->adev->dev, -"Failed to set %d PPT limit value\n" , i); - } -/* set the user dpm clock configurations */ if (smu_dpm_ctx->dpm_level ==
AMD_DPM_FORCED_LEVEL_MANUAL) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_late_init(struct amdgpu_ip_block
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0enum smu_clk_type clk_type;@@ -932,7 +961,7 @@ static int smu_late_init(struct amdgpu_ip_block
*ip_block)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_late_init(struct amdgpu_ip_block *ip_block)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1* is unnecessary. */ adev->pm.ac_power =power_supply_is_system_supplied () >0 ; -smu_set_ac_dc (smu); +smu_set_ac_dc (smu, false); if ((amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 1))|| > (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 3)))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_late_init(struct amdgpu_ip_block
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -967,6 +996,8 @@ static int smu_late_init(struct amdgpu_ip_block
*ip_block)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0return ret; } +if (adev->in_suspend) +smu_restore_ppt_limits (smu, false);smu_restore_dpm_user_profile (smu);return 0 ;@@ -2746,7 +2777,7 @@ static intsmu_set_watermarks_for_clock_ranges(void *handle,
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1return smu_set_watermarks_table (smu, clock_ranges); } -int smu_set_ac_dc (struct smu_context *smu) +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy) {int ret =0 ;@@ -2754,17 +2785,22 @@ int smu_set_ac_dc(struct smu_context *smu)return -EOPNOTSUPP ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu) · line 2794
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-2/* controlled by firmware */ -if (smu->dc_controlled_by_gpio) -return 0 ; +if (!smu->dc_controlled_by_gpio) { + ret =smu_set_power_source (smu, + smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC : +SMU_POWER_SOURCE_DC ); +if (ret) { + dev_err(smu->adev->dev, "Failed to switch to %smode!\n",
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2+ smu->adev->pm.ac_power ? "AC" : "DC"); +return ret; + } + } - ret = smu_set_power_source(smu, - smu->adev->pm.ac_power ?
SMU_POWER_SOURCE_AC:Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-5- SMU_POWER_SOURCE_DC); -if (ret) -dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , - smu->adev->pm.ac_power ?"AC" :"DC" ); +if (restore_ppt_policy) +smu_restore_ppt_limits (smu, true); -return ret; +return 0 ; } const struct amd_ip_funcs smu_ip_funcs = { @@ -3020,8 +3056,11 @@Quoted 1 line
static int smu_set_ppt_limit(void *handle,
uint32_tlimit_type,uint32_tlimit)
Quoted 4 lines
ret = smu->ppt_funcs->set_ppt_limit(smu, limit_type, limit); if (ret) return ret;- if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1- smu->user_dpm_profile.ppt_limits[limit_type] = limit; + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 3 lines
+ smu-
user_dpm_profile.ppt_limits[power_source][limit_type] = limit;
+ smu->user_dpm_profile.ppt_limit_user_mask[power_source]|=
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+BIT (limit_type); + }return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h enum smu_memory_pool_size { · line 254
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -251,7 +251,8 @@ enum smu_memory_pool_size {struct smu_user_dpm_profile {uint32_t fan_mode; -uint32_t ppt_limits[SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limits[SMU_POWER_SOURCE_COUNT][SMU_LIMIT_TYPE_COUNT];
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2
-1+uint32_t ppt_limit_user_mask[SMU_POWER_SOURCE_COUNT ];uint32_t fan_speed_pwm;uint32_t fan_speed_rpm;uint32_t flags;@@ -1953,7 +1954,7 @@ int smu_set_soft_freq_range(struct smu_context *smu, enum pp_clock_type clk_typeint smu_set_gfx_power_up_by_imu (struct smu_context *smu); -int smu_set_ac_dc (struct smu_context *smu); +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy); int smu_set_xgmi_plpd_mode(struct smu_context *smu,enum pp_xgmi_plpd_mode mode);
Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restore
Quoted 102 lines · Yang(Kevin)
AMD General
Quoted 84 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 31, 2026 12:57 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restoreQuoted 4 lines · Yang Wang
The existing user policy representation has three ambiguities:
- A numeric value cannot distinguish explicit zero from an unset policy.
- One value per controller cannot preserve independent AC and DCrequests.
Quoted 10 lines
- Suspend-only restore misses runtime resume, GPU reset, and table reload.
Refactor policy storage and restore as follows:
- Store values and validity masks by power source and PPT controller.
- Save writes against the active source.
- Restore the active source after default SMU setup.
- Reapply the target policy after live AC/DC transitions.
- Use the target source default when no explicit request exists.Quoted 8 lines
The late-init path now covers system resume, runtime resume, GPU reset, and custom PPTable reload. Common code owns persistent policy; PMFW continues to own effective current limits.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 89 +++++++++++++------
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_acpi_event_handler(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 +- 3 files changed, 68 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -508,7 +508,7 @@ void amdgpu_pm_acpi_event_handler(struct
amdgpu_device*adev)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void
Quoted 14 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1amdgpu_dpm_notify_ac_dc (adev);if (is_support_sw_smu (adev)) -smu_set_ac_dc (adev->powerplay.pp_handle); +smu_set_ac_dc (adev->powerplay.pp_handle, true);mutex_unlock (&adev->pm.mutex); }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -488,12 +488,52 @@ static voidsmu_set_user_clk_dependencies(struct
smu_context*smu, enumsmu_clk_Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +12
-0return ; } +static void smu_restore_ppt_limits (struct smu_context *smu, +bool restore_defaults) +{ +enum smu_power_src_type power_source; +struct smu_ppt_limit_range *range; +uint32_t restore_mask; +uint32_t limit; +int i, ret; + + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; + restore_mask = smu-user_dpm_profile.ppt_limit_user_mask[power_source] &
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+ smu->ppt_limits.supported_mask; +if (!restore_mask && !restore_defaults) +return ; + + smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_ · line 517
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-0+ +for (i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { +if (!(smu->ppt_limits.supported_mask &BIT (i))) +continue ; + +if (restore_mask &BIT (i)) { + limit = smu-user_dpm_profile.ppt_limits[power_source][i];
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ }else if (restore_defaults) { + range = &smu->ppt_limits.range[power_source][i]; + limit = range->default_value;This should be restore the current limit before a suspend/reset and not the default limit. The current limit could be set through out of band also, user profile values won't reflect that.
Quoted 5 lines
Please check the call sites.
The quoted default path is an opt-in fallback for AC/DC policy restore, and it is not used for suspend or GPU reset. Suspend and reset invoke
smu_restore_ppt_limits(smu, false), which replays only limits recorded inuser_dpm_profile.
Yes, I'm specifically talking about late_init path. It gets called after a suspend or reset. It's about a case where user dpm limit is not present.
Quoted 4 lines
The profile intentionally does not represent out-of-band state,
and the amdgpu driver has no ownership or synchronization contract for PMFW limits changed outside the driver. Supporting that use case requires separate policy and should be addressed in a separate change.
This only requires restoring the current limit after a suspend or reset when called from smu late init if a user specified limit is not found. It doesn't need to revert to default limit.
Thanks,
Lijo
Quoted 161 lines
Best Regards,
KevinQuoted 158 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11
-0+ }else { +continue ; + } + + ret =smu_set_ppt_limit (smu, i, limit); +if (ret) +dev_err (smu->adev->dev, +"Failed to restore PPT%d limit: %d\n" , i, ret); + } + + smu->user_dpm_profile.flags &=~SMU_DPM_USER_PROFILE_RESTORE; }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1+/** * smu_restore_dpm_user_profile - reinstate user dpm profile * * @smu: smu_context pointer * -* Restore saved user power limits, clock frequencies and fan settings. +* Restore saved user clock frequencies and fan settings. */ static void smu_restore_dpm_user_profile (struct smu_context *smu) {@@ -509,17 +549,6 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct · line 550
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0/* Enable restore flag */ smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-4-/* set the user dpm power limits */ -for (int i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { -if (!smu->user_dpm_profile.ppt_limits[i]) -continue ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-7- ret =smu_set_ppt_limit (smu, i, - smu- user_dpm_profile.ppt_limits[i]); -if (ret) -dev_err (smu->adev->dev, -"Failed to set %d PPT limit value\n" , i); - } -/* set the user dpm clock configurations */ if (smu_dpm_ctx->dpm_level ==
AMD_DPM_FORCED_LEVEL_MANUAL) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_late_init(struct amdgpu_ip_block
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0enum smu_clk_type clk_type;@@ -932,7 +961,7 @@ static int smu_late_init(struct amdgpu_ip_block
*ip_block)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_late_init(struct amdgpu_ip_block *ip_block)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1* is unnecessary. */ adev->pm.ac_power =power_supply_is_system_supplied () >0 ; -smu_set_ac_dc (smu); +smu_set_ac_dc (smu, false); if ((amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 1))|| > (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 3)))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_late_init(struct amdgpu_ip_block
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -967,6 +996,8 @@ static int smu_late_init(struct amdgpu_ip_block
*ip_block)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0return ret; } +if (adev->in_suspend) +smu_restore_ppt_limits (smu, false);smu_restore_dpm_user_profile (smu);return 0 ;@@ -2746,7 +2777,7 @@ static intsmu_set_watermarks_for_clock_ranges(void *handle,
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1return smu_set_watermarks_table (smu, clock_ranges); } -int smu_set_ac_dc (struct smu_context *smu) +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy) {int ret =0 ;@@ -2754,17 +2785,22 @@ int smu_set_ac_dc(struct smu_context *smu)return -EOPNOTSUPP ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu) · line 2794
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-2/* controlled by firmware */ -if (smu->dc_controlled_by_gpio) -return 0 ; +if (!smu->dc_controlled_by_gpio) { + ret =smu_set_power_source (smu, + smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC : +SMU_POWER_SOURCE_DC ); +if (ret) { + dev_err(smu->adev->dev, "Failed to switch to %smode!\n",
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2+ smu->adev->pm.ac_power ? "AC" : "DC"); +return ret; + } + } - ret = smu_set_power_source(smu, - smu->adev->pm.ac_power ?
SMU_POWER_SOURCE_AC:Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-5- SMU_POWER_SOURCE_DC); -if (ret) -dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , - smu->adev->pm.ac_power ?"AC" :"DC" ); +if (restore_ppt_policy) +smu_restore_ppt_limits (smu, true); -return ret; +return 0 ; } const struct amd_ip_funcs smu_ip_funcs = { @@ -3020,8 +3056,11 @@Quoted 1 line
static int smu_set_ppt_limit(void *handle,
uint32_tlimit_type,uint32_tlimit)
Quoted 4 lines
ret = smu->ppt_funcs->set_ppt_limit(smu, limit_type, limit); if (ret) return ret;- if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1- smu->user_dpm_profile.ppt_limits[limit_type] = limit; + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 3 lines
+ smu-
user_dpm_profile.ppt_limits[power_source][limit_type] = limit;
+ smu->user_dpm_profile.ppt_limit_user_mask[power_source]|=
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+BIT (limit_type); + }return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h enum smu_memory_pool_size { · line 254
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -251,7 +251,8 @@ enum smu_memory_pool_size {struct smu_user_dpm_profile {uint32_t fan_mode; -uint32_t ppt_limits[SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limits[SMU_POWER_SOURCE_COUNT][SMU_LIMIT_TYPE_COUNT];
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2
-1+uint32_t ppt_limit_user_mask[SMU_POWER_SOURCE_COUNT ];uint32_t fan_speed_pwm;uint32_t fan_speed_rpm;uint32_t flags;@@ -1953,7 +1954,7 @@ int smu_set_soft_freq_range(struct smu_context *smu, enum pp_clock_type clk_typeint smu_set_gfx_power_up_by_imu (struct smu_context *smu); -int smu_set_ac_dc (struct smu_context *smu); +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy); int smu_set_xgmi_plpd_mode(struct smu_context *smu,enum pp_xgmi_plpd_mode mode);
RE: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restore
AMD General
Quoted 130 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 31, 2026 3:45 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restoreQuoted 21 lines · Yang(Kevin)
AMD General
Quoted 19 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 31, 2026 12:57 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restoreQuoted 4 lines · Yang Wang
The existing user policy representation has three ambiguities:
- A numeric value cannot distinguish explicit zero from an unset policy.
- One value per controller cannot preserve independent AC and DCrequests.
Quoted 1 line
- Suspend-only restore misses runtime resume, GPU reset, and table
reload.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Refactor policy storage and restore as follows:
- Store values and validity masks by power source and PPT controller.
- Save writes against the active source.
- Restore the active source after default SMU setup.
- Reapply the target policy after live AC/DC transitions.
- Use the target source default when no explicit request exists.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
The late-init path now covers system resume, runtime resume, GPU reset, and custom PPTable reload. Common code owns persistent policy; PMFW continues to own effective current limits.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 89+++++++++++++-
Quoted 17 lines
Quoted 17 lines
-----
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_acpi_event_handler(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 +- 3 files changed, 68 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -508,7 +508,7 @@ void amdgpu_pm_acpi_event_handler(struct
amdgpu_device*adev)Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1amdgpu_dpm_notify_ac_dc (adev);if (is_support_sw_smu (adev)) -smu_set_ac_dc (adev->powerplay.pp_handle); +smu_set_ac_dc (adev->powerplay.pp_handle, true);Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0mutex_unlock (&adev->pm.mutex); }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -488,12 +488,52 @@ static voidsmu_set_user_clk_dependencies(struct
smu_context*smu, enum
smu_clk_Quoted 37 lines
Quoted 21 lines
Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11
-0return ; } +static void smu_restore_ppt_limits (struct smu_context *smu, +bool restore_defaults) { +enum smu_power_src_type power_source; +struct smu_ppt_limit_range *range; +uint32_t restore_mask; +uint32_t limit; +int i, ret; + + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; + restore_mask = smu-user_dpm_profile.ppt_limit_user_mask[power_source] &
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+ smu->ppt_limits.supported_mask; +if (!restore_mask && !restore_defaults) +return ; + + smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_ · line 517
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-0+ +for (i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { +if (!(smu->ppt_limits.supported_mask &BIT (i))) +continue ; + +if (restore_mask &BIT (i)) { + limit = smu-user_dpm_profile.ppt_limits[power_source][i];
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ }else if (restore_defaults) { + range = &smu->ppt_limits.range[power_source][i]; + limit = range->default_value;This should be restore the current limit before a suspend/reset and not the default limit. The current limit could be set through out of band also, user profile values won't reflect that.
Quoted 3 lines
Please check the call sites.
The quoted default path is an opt-in fallback for AC/DC policy restore, and it
is not used for suspend or GPU reset.
Quoted 1 line
Suspend and reset invoke
smu_restore_ppt_limits(smu, false), which replaysonly limits recorded in
user_dpm_profile.Quoted 1 line
Yes, I'm specifically talking about
late_initpath. It gets called after a suspend or reset. It's about a case where user dpm limit is not present.Quoted 2 lines
The profile intentionally does not represent out-of-band state, and the amdgpu driver has no ownership or synchronization contract for PMFW
Quoted 8 lines
limits changed outside the driver.
Quoted 1 line
Supporting that use case requires separate policy and should be addressed
in a separate change.
Quoted 1 line
This only requires restoring the current limit after a suspend or reset when called from smu late init if a user specified limit is not found. It doesn't need to revert to default limit.
Yes, the restore function takes no action if no custom limits are set by the user. And the logic has been verified on the target system, including suspend, reset and default cases.
Best Regards,
Kevin
Quoted 171 lines
Thanks,
LijoQuoted 78 lines
Best Regards,
KevinQuoted 76 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11
-0+ }else { +continue ; + } + + ret =smu_set_ppt_limit (smu, i, limit); +if (ret) +dev_err (smu->adev->dev, +"Failed to restore PPT%d limit: %d\n" , i, ret); + } + + smu->user_dpm_profile.flags &=~SMU_DPM_USER_PROFILE_RESTORE; }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1+/** * smu_restore_dpm_user_profile - reinstate user dpm profile * * @smu: smu_context pointer * -* Restore saved user power limits, clock frequencies and fan settings. +* Restore saved user clock frequencies and fan settings. */ static void smu_restore_dpm_user_profile (struct smu_context *smu) {@@ -509,17 +549,6 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct · line 550
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0/* Enable restore flag */ smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-4-/* set the user dpm power limits */ -for (int i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { -if (!smu->user_dpm_profile.ppt_limits[i]) -continue ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-7- ret =smu_set_ppt_limit (smu, i, - smu- user_dpm_profile.ppt_limits[i]); -if (ret) -dev_err (smu->adev->dev, -"Failed to set %d PPT limit value\n" , i); - } -/* set the user dpm clock configurations */ if (smu_dpm_ctx->dpm_level ==
AMD_DPM_FORCED_LEVEL_MANUAL) {Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0enum smu_clk_type clk_type; @@ -932,7 +961,7 @@ staticint smu_late_init(struct
amdgpu_ip_block
*ip_block)Quoted 8 lines
* is unnecessary. */ adev->pm.ac_power = power_supply_is_system_supplied() > 0;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-smu_set_ac_dc (smu); +smu_set_ac_dc (smu, false); if ((amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0,1))
|| > (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0,Quoted 2 lines
3))) @@ -967,6 +996,8 @@ static int smu_late_init(struct
amdgpu_ip_block
*ip_block)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 9 lines
return ret; }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+if (adev->in_suspend) +smu_restore_ppt_limits (smu, false);smu_restore_dpm_user_profile (smu);return 0 ;@@ -2746,7 +2777,7 @@ static intsmu_set_watermarks_for_clock_ranges(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0return smu_set_watermarks_table (smu, clock_ranges); }Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-int smu_set_ac_dc (struct smu_context *smu) +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy) {int ret =0 ;@@ -2754,17 +2785,22 @@ int smu_set_ac_dc(struct smu_context*smu)
Quoted 65 lines
Quoted 65 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu)
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-2return -EOPNOTSUPP ;/* controlled by firmware */ -if (smu->dc_controlled_by_gpio) -return 0 ; +if (!smu->dc_controlled_by_gpio) { + ret =smu_set_power_source (smu, + smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC : +SMU_POWER_SOURCE_DC ); +if (ret) { + dev_err(smu->adev->dev, "Failed to switch to %smode!\n",
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2+ smu->adev->pm.ac_power ? "AC" : "DC"); +return ret; + } + } - ret = smu_set_power_source(smu, - smu->adev->pm.ac_power ?
SMU_POWER_SOURCE_AC:Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-5- SMU_POWER_SOURCE_DC); -if (ret) -dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , - smu->adev->pm.ac_power ?"AC" :"DC" ); +if (restore_ppt_policy) +smu_restore_ppt_limits (smu, true); -return ret; +return 0 ; } const struct amd_ip_funcs smu_ip_funcs = { @@ -3020,8 +3056,11 @@Quoted 2 lines
static int smu_set_ppt_limit(void *handle,
uint32_tlimit_type,uint32_tlimit)
Quoted 4 lines
ret = smu->ppt_funcs->set_ppt_limit(smu, limit_type, limit); if (ret) return ret;- if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1- smu->user_dpm_profile.ppt_limits[limit_type] = limit; + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 3 lines
+ smu-
user_dpm_profile.ppt_limits[power_source][limit_type] = limit;
+ smu->user_dpm_profile.ppt_limit_user_mask[power_source]|=
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+BIT (limit_type); + }return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h enum smu_memory_pool_size { · line 254
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -251,7 +251,8 @@ enum smu_memory_pool_size {struct smu_user_dpm_profile {uint32_t fan_mode; -uint32_t ppt_limits[SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limits[SMU_POWER_SOURCE_COUNT][SMU_LIMIT_TYPE_COUNT];
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h int smu_set_soft_freq_range(struct
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-0+uint32_t ppt_limit_user_mask[SMU_POWER_SOURCE_COUNT ];uint32_t fan_speed_pwm;uint32_t fan_speed_rpm;uint32_t flags;@@ -1953,7 +1954,7 @@ int smu_set_soft_freq_range(struct
smu_contextQuoted 11 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2
-1*smu, enum pp_clock_type clk_typeint smu_set_gfx_power_up_by_imu (struct smu_context *smu); -int smu_set_ac_dc (struct smu_context *smu); +int smu_set_ac_dc (struct smu_context *smu,bool +restore_ppt_policy);int smu_set_xgmi_plpd_mode (struct smu_context *smu,enum pp_xgmi_plpd_mode mode);
Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restore
Quoted 137 lines · Yang(Kevin)
AMD General
Quoted 135 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 31, 2026 3:45 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restoreQuoted 21 lines · Yang(Kevin)
AMD General
Quoted 19 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, July 31, 2026 12:57 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 3/4] drm/amd/pm: refactor user PPT policy save and restoreQuoted 4 lines · Yang Wang
The existing user policy representation has three ambiguities:
- A numeric value cannot distinguish explicit zero from an unset policy.
- One value per controller cannot preserve independent AC and DCrequests.
Quoted 1 line
- Suspend-only restore misses runtime resume, GPU reset, and table
reload.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Refactor policy storage and restore as follows:
- Store values and validity masks by power source and PPT controller.
- Save writes against the active source.
- Restore the active source after default SMU setup.
- Reapply the target policy after live AC/DC transitions.
- Use the target source default when no explicit request exists.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
The late-init path now covers system resume, runtime resume, GPU reset, and custom PPTable reload. Common code owns persistent policy; PMFW continues to own effective current limits.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 89+++++++++++++-
Quoted 17 lines
Quoted 17 lines
-----
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_acpi_event_handler(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 +- 3 files changed, 68 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -508,7 +508,7 @@ void amdgpu_pm_acpi_event_handler(struct
amdgpu_device*adev)Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1amdgpu_dpm_notify_ac_dc (adev);if (is_support_sw_smu (adev)) -smu_set_ac_dc (adev->powerplay.pp_handle); +smu_set_ac_dc (adev->powerplay.pp_handle, true);Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0mutex_unlock (&adev->pm.mutex); }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -488,12 +488,52 @@ static voidsmu_set_user_clk_dependencies(struct
smu_context*smu, enum
smu_clk_Quoted 37 lines
Quoted 21 lines
Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11
-0return ; } +static void smu_restore_ppt_limits (struct smu_context *smu, +bool restore_defaults) { +enum smu_power_src_type power_source; +struct smu_ppt_limit_range *range; +uint32_t restore_mask; +uint32_t limit; +int i, ret; + + power_source = smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC ; + restore_mask = smu-user_dpm_profile.ppt_limit_user_mask[power_source] &
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+ smu->ppt_limits.supported_mask; +if (!restore_mask && !restore_defaults) +return ; + + smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_ · line 517
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-0+ +for (i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { +if (!(smu->ppt_limits.supported_mask &BIT (i))) +continue ; + +if (restore_mask &BIT (i)) { + limit = smu-user_dpm_profile.ppt_limits[power_source][i];
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ }else if (restore_defaults) { + range = &smu->ppt_limits.range[power_source][i]; + limit = range->default_value;This should be restore the current limit before a suspend/reset and not the default limit. The current limit could be set through out of band also, user profile values won't reflect that.
Quoted 3 lines
Please check the call sites.
The quoted default path is an opt-in fallback for AC/DC policy restore, and it
is not used for suspend or GPU reset.
Quoted 1 line
Suspend and reset invoke
smu_restore_ppt_limits(smu, false), which replaysonly limits recorded in
user_dpm_profile.Quoted 1 line
Yes, I'm specifically talking about
late_initpath. It gets called after a suspend or reset. It's about a case where user dpm limit is not present.Quoted 2 lines
The profile intentionally does not represent out-of-band state, and the amdgpu driver has no ownership or synchronization contract for PMFW
limits changed outside the driver.
Quoted 1 line
Supporting that use case requires separate policy and should be addressed
in a separate change.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
This only requires restoring the current limit after a suspend or reset when called from smu late init if a user specified limit is not found. It doesn't need to revert to default limit.
Yes, the restore function takes no action if no custom limits are set by the user. And the logic has been verified on the target system, including suspend, reset and default cases.
That's right. Currently it doesn't do any action.
What I was asking is -
restore_default => if user explicitly wants to restore default valuesrestore_user => restore user specified limits
auto => if user specified limit is present, restore_user, else restore current limit of the power source mode.
During late init with suspend or reset, restore the limit.
if (suspend or reset)
restore_limit(auto)
refresh_current_limit()
Thanks,
Lijo
Quoted 174 lines
Best Regards,
KevinQuoted 171 lines
Thanks,
LijoQuoted 78 lines
Best Regards,
KevinQuoted 76 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_set_user_clk_dependencies(struct smu_context *smu, enum smu_clk_
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11
-0+ }else { +continue ; + } + + ret =smu_set_ppt_limit (smu, i, limit); +if (ret) +dev_err (smu->adev->dev, +"Failed to restore PPT%d limit: %d\n" , i, ret); + } + + smu->user_dpm_profile.flags &=~SMU_DPM_USER_PROFILE_RESTORE; }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1+/** * smu_restore_dpm_user_profile - reinstate user dpm profile * * @smu: smu_context pointer * -* Restore saved user power limits, clock frequencies and fan settings. +* Restore saved user clock frequencies and fan settings. */ static void smu_restore_dpm_user_profile (struct smu_context *smu) {@@ -509,17 +549,6 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct · line 550
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0/* Enable restore flag */ smu->user_dpm_profile.flags |=
SMU_DPM_USER_PROFILE_RESTORE;Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-4-/* set the user dpm power limits */ -for (int i =SMU_PPT_LIMIT_PPT0 ; i <SMU_LIMIT_TYPE_COUNT ; i++) { -if (!smu->user_dpm_profile.ppt_limits[i]) -continue ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-7- ret =smu_set_ppt_limit (smu, i, - smu- user_dpm_profile.ppt_limits[i]); -if (ret) -dev_err (smu->adev->dev, -"Failed to set %d PPT limit value\n" , i); - } -/* set the user dpm clock configurations */ if (smu_dpm_ctx->dpm_level ==
AMD_DPM_FORCED_LEVEL_MANUAL) {Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0enum smu_clk_type clk_type; @@ -932,7 +961,7 @@ staticint smu_late_init(struct
amdgpu_ip_block
*ip_block)Quoted 8 lines
* is unnecessary. */ adev->pm.ac_power = power_supply_is_system_supplied() > 0;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-smu_set_ac_dc (smu); +smu_set_ac_dc (smu, false); if ((amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0,1))
|| > (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0,Quoted 2 lines
3))) @@ -967,6 +996,8 @@ static int smu_late_init(struct
amdgpu_ip_block
*ip_block)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 9 lines
return ret; }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+if (adev->in_suspend) +smu_restore_ppt_limits (smu, false);smu_restore_dpm_user_profile (smu);return 0 ;@@ -2746,7 +2777,7 @@ static intsmu_set_watermarks_for_clock_ranges(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0return smu_set_watermarks_table (smu, clock_ranges); }Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-int smu_set_ac_dc (struct smu_context *smu) +int smu_set_ac_dc (struct smu_context *smu,bool restore_ppt_policy) {int ret =0 ;@@ -2754,17 +2785,22 @@ int smu_set_ac_dc(struct smu_context*smu)
Quoted 65 lines
Quoted 65 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu)
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-2return -EOPNOTSUPP ;/* controlled by firmware */ -if (smu->dc_controlled_by_gpio) -return 0 ; +if (!smu->dc_controlled_by_gpio) { + ret =smu_set_power_source (smu, + smu->adev->pm.ac_power ? +SMU_POWER_SOURCE_AC : +SMU_POWER_SOURCE_DC ); +if (ret) { + dev_err(smu->adev->dev, "Failed to switch to %smode!\n",
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_set_ac_dc(struct smu_context *smu)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2+ smu->adev->pm.ac_power ? "AC" : "DC"); +return ret; + } + } - ret = smu_set_power_source(smu, - smu->adev->pm.ac_power ?
SMU_POWER_SOURCE_AC:Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-5- SMU_POWER_SOURCE_DC); -if (ret) -dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , - smu->adev->pm.ac_power ?"AC" :"DC" ); +if (restore_ppt_policy) +smu_restore_ppt_limits (smu, true); -return ret; +return 0 ; } const struct amd_ip_funcs smu_ip_funcs = { @@ -3020,8 +3056,11 @@Quoted 2 lines
static int smu_set_ppt_limit(void *handle,
uint32_tlimit_type,uint32_tlimit)
Quoted 4 lines
ret = smu->ppt_funcs->set_ppt_limit(smu, limit_type, limit); if (ret) return ret;- if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1- smu->user_dpm_profile.ppt_limits[limit_type] = limit; + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 3 lines
+ smu-
user_dpm_profile.ppt_limits[power_source][limit_type] = limit;
+ smu->user_dpm_profile.ppt_limit_user_mask[power_source]|=
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+BIT (limit_type); + }return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h enum smu_memory_pool_size { · line 254
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -251,7 +251,8 @@ enum smu_memory_pool_size {struct smu_user_dpm_profile {uint32_t fan_mode; -uint32_t ppt_limits[SMU_LIMIT_TYPE_COUNT ]; +uint32_t ppt_limits[SMU_POWER_SOURCE_COUNT][SMU_LIMIT_TYPE_COUNT];
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h int smu_set_soft_freq_range(struct
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-0+uint32_t ppt_limit_user_mask[SMU_POWER_SOURCE_COUNT ];uint32_t fan_speed_pwm;uint32_t fan_speed_rpm;uint32_t flags;@@ -1953,7 +1954,7 @@ int smu_set_soft_freq_range(struct
smu_contextQuoted 11 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2
-1*smu, enum pp_clock_type clk_typeint smu_set_gfx_power_up_by_imu (struct smu_context *smu); -int smu_set_ac_dc (struct smu_context *smu); +int smu_set_ac_dc (struct smu_context *smu,bool +restore_ppt_policy);int smu_set_xgmi_plpd_mode (struct smu_context *smu,enum pp_xgmi_plpd_mode mode);