]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd: Save and restore all limit types
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 9 Oct 2025 20:59:06 +0000 (15:59 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 13 Oct 2025 18:14:35 +0000 (14:14 -0400)
Vangogh has separate limits for default PPT and fast PPT. Add
infrastructure to save both of these limits and restore both of them.

Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h

index a55f94b91bc92eb52ee762254151021d497e7168..ea27c087ecf189c558637b26054bd628a0fe2fdf 100644 (file)
@@ -508,11 +508,14 @@ 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 limit */
-       if (smu->user_dpm_profile.power_limit) {
-               ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit);
+       /* 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])
+                       continue;
+               ret = smu_set_power_limit(smu, i,
+                                         smu->user_dpm_profile.power_limits[i]);
                if (ret)
-                       dev_err(smu->adev->dev, "Failed to set power limit value\n");
+                       dev_err(smu->adev->dev, "Failed to set %d power limit value\n", i);
        }
 
        /* set the user dpm clock configurations */
@@ -2979,11 +2982,13 @@ static int smu_set_power_limit(void *handle, uint32_t limit_type, uint32_t 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))
-                       smu->user_dpm_profile.power_limit = 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;
        }
 
-       return ret;
+       return 0;
 }
 
 static int smu_print_smuclk_levels(struct smu_context *smu, enum smu_clk_type clk_type, char *buf)
index 582c186d8b6230ef85289fbf76e7d9270b686c9b..32387e8c138b95abd5c4b861e3c92d1827d868fd 100644 (file)
@@ -212,6 +212,7 @@ enum smu_power_src_type {
 enum smu_ppt_limit_type {
        SMU_DEFAULT_PPT_LIMIT = 0,
        SMU_FAST_PPT_LIMIT,
+       SMU_LIMIT_TYPE_COUNT,
 };
 
 enum smu_ppt_limit_level {
@@ -231,7 +232,7 @@ enum smu_memory_pool_size {
 
 struct smu_user_dpm_profile {
        uint32_t fan_mode;
-       uint32_t power_limit;
+       uint32_t power_limits[SMU_LIMIT_TYPE_COUNT];
        uint32_t fan_speed_pwm;
        uint32_t fan_speed_rpm;
        uint32_t flags;