[AMD Official Use Only - AMD Internal Distribution Only] >-----Original Message----- >From: amd-gfx <[email protected]> On Behalf Of Mario >Limonciello >Sent: Thursday, October 9, 2025 12:42 AM >To: Limonciello, Mario <[email protected]>; amd- >[email protected] >Cc: Robert Beckett <[email protected]> >Subject: [PATCH v4 3/6] drm/amd: Remove second call to set_power_limit() > >The min/max limits only make sense for default PPT. Restructure >smu_set_power_limit() to only use them in that case. > >Signed-off-by: Mario Limonciello <[email protected]> >--- > drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 20 +++++++++----------- > 1 file changed, 9 insertions(+), 11 deletions(-) > >diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c >b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c >index 1c5f37cd5b75..f946effc1776 100644 >--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c >+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c >@@ -2966,20 +2966,18 @@ static int smu_set_power_limit(void *handle, >uint32_t limit_type, uint32_t limit > if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) > return -EOPNOTSUPP; > >- if (limit_type != SMU_DEFAULT_PPT_LIMIT) >- if (smu->ppt_funcs->set_power_limit) >- return smu->ppt_funcs->set_power_limit(smu, >limit_type, limit); >+ if (limit_type == SMU_DEFAULT_PPT_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; >+ } > >- 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; >+ if (!limit) >+ limit = smu->current_power_limit; [lijo]
It seems this logic is expected to work only on SOCs with min_power_limit = 0.
I don't know the history of this. Shall we move this up and make this notation
generic - a 0-limit passed will try to reapply the current limit for any SOC?
Thanks,
Lijo
> }
>
>- if (!limit)
>- limit = smu->current_power_limit;
>-
> if (smu->ppt_funcs->set_power_limit) {
> ret = smu->ppt_funcs->set_power_limit(smu, limit_type, limit);
> if (!ret && !(smu->user_dpm_profile.flags &
>SMU_DPM_USER_PROFILE_RESTORE))
>--
>2.51.0
<<attachment: winmail.dat>>
