Skip to contentSkip to conversation

Adjustment to power limit setting

PATCH Superseded Mario Limonciello 4 participants 13 messages Oct 6, 2025 – Oct 8, 2025

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Adjustment to power limit setting

Lijo pointed out to me that
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume") commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume")

both should be unnecessary because smu_restore_dpm_user_profile() already restores them. However in looking at the code there is a case that isn't properly restored - the FAST PPT limits supported by Van Gogh. The nuance isn't immediately obvious because the limit variable is overloaded with limit type.

This series attempts to address that issue by passing limit type around and saving/restoring both types.

Cc Lijo Lazar <[email protected]>

Mario Limonciello (5):
drm/amd: Remove some unncessary header includes
drm/amd: Stop overloading power limit with limit type drm/amd: Save and restore all limit types
drm/amd: Drop calls to restore power limit and clock from smu_resume() drm/amd: Adjust whitespace for vangogh_ppt

 .../gpu/drm/amd/include/kgd_pp_interface.h    |  2 +-
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 +-
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  2 +-
 .../gpu/drm/amd/pm/powerplay/amd_powerplay.c  |  5 +--
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 40 ++++++++-----------
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 +-
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 13 +++---
 8 files changed, 29 insertions(+), 42 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/5 drm/amd: Remove some unncessary header includes

Unnecessary headers can slow down the build, drop em.

No intended functional changes.

---
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -3
index 554492dfa3c0..fb595a70bbd1 100644
@@ -20,7 +20,6 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
-#include "pp_debug.h"
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/gfp.h>
@@ -28,12 +27,10 @@
 #include <linux/firmware.h>
 #include <linux/reboot.h>
 #include "amd_shared.h"
-#include "amd_powerplay.h"
 #include "power_state.h"
 #include "amdgpu.h"
 #include "hwmgr.h"
 #include "amdgpu_dpm_internal.h"
-#include "amdgpu_display.h"
 
 static const struct amd_pm_funcs pp_dpm_funcs;
 
Signature · 1 line
2.51.0
#2 lore raw

PATCH v2 2/5 drm/amd: Stop overloading power limit with limit type

In reply to Mario Limonciello

When passed around internally the upper 8 bits of power limit include the limit type. This is non-obvious without digging into the nuances of each function. Instead pass the limit type as an argument to all applicable layers.

---
v2:
* split into two patches

---
 drivers/gpu/drm/amd/include/kgd_pp_interface.h   | 2 +-
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c              | 3 ++-
 drivers/gpu/drm/amd/pm/amdgpu_pm.c               | 3 +--
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h          | 2 +-
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 2 +-
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c        | 6 ++----
 drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 1 -
 7 files changed, 8 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -1
index 2b0cdb2a2775..87814c2b526e 100644
@@ -454,7 +454,7 @@ struct amd_pm_funcs {
 				bool gate,
 				int inst);
 	int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
-	int (*set_power_limit)(void *handle, uint32_t n);
+	int (*set_power_limit)(void *handle, uint32_t limit_type, uint32_t n);
 	int (*get_power_limit)(void *handle, uint32_t *limit,
 			enum pp_power_limit_level pp_limit_level,
 			enum pp_power_type power_type);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -1
index 518d07afc7df..5d08dc3b7110 100644
@@ -1616,6 +1616,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
 }
 
 int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
+			       uint32_t limit_type,
 			       uint32_t limit)
 {
 	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
@@ -1626,7 +1627,7 @@ int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
 
 	mutex_lock(&adev->pm.mutex);
 	ret = pp_funcs->set_power_limit(adev->powerplay.pp_handle,
-					limit);
+					limit_type, limit);
 	mutex_unlock(&adev->pm.mutex);
 
 	return ret;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -2
index b5fbb0fd1dc0..6bdf185c6b60 100644
@@ -3390,13 +3390,12 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
 		return err;
 
 	value = value / 1000000; /* convert to Watt */
-	value |= limit_type << 24;
 
 	err = amdgpu_pm_get_access(adev);
 	if (err < 0)
 		return err;
 
-	err = amdgpu_dpm_set_power_limit(adev, value);
+	err = amdgpu_dpm_set_power_limit(adev, limit_type, value);
 
 	amdgpu_pm_put_access(adev);
 
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -1
index 65c1d98af26c..3bce74f8bb0a 100644
@@ -553,7 +553,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
 			       enum pp_power_limit_level pp_limit_level,
 			       enum pp_power_type power_type);
 int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
-			       uint32_t limit);
+			       uint32_t limit_type, uint32_t limit);
 int amdgpu_dpm_is_cclk_dpm_supported(struct amdgpu_device *adev);
 int amdgpu_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
 						       struct seq_file *m);
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1 -1
index fb595a70bbd1..76a5353d7f4a 100644
@@ -952,7 +952,7 @@ static int pp_dpm_switch_power_profile(void *handle,
 	return 0;
 }
 
-static int pp_set_power_limit(void *handle, uint32_t limit)
+static int pp_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit)
 {
 	struct pp_hwmgr *hwmgr = handle;
 	uint32_t max_power_limit;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -4
index fb8086859857..c4459dc553f0 100644
@@ -68,7 +68,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);
+static int smu_set_power_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);
@@ -2958,16 +2958,14 @@ int smu_get_power_limit(void *handle,
 	return ret;
 }
 
-static int smu_set_power_limit(void *handle, uint32_t limit)
+static int smu_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit)
 {
 	struct smu_context *smu = handle;
-	uint32_t limit_type = limit >> 24;
 	int ret = 0;
 
 	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
-	limit &= (1<<24)-1;
 	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);
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0 -1
index 2c9869feba61..81077a3969e9 100644
@@ -2399,7 +2399,6 @@ static int vangogh_set_power_limit(struct smu_context *smu,
 		smu->current_power_limit = ppt_limit;
 		break;
 	case SMU_FAST_PPT_LIMIT:
-		ppt_limit &= ~(SMU_FAST_PPT_LIMIT << 24);
 		if (ppt_limit > power_context->max_fast_ppt_limit) {
 			dev_err(smu->adev->dev,
 				"New power limit (%d) is over the max allowed %d\n",
Signature · 1 line
2.51.0
#3 lore raw

Re: [PATCH v2 2/5] drm/amd: Stop overloading power limit with limit type

Quoted 5 lines · Mario Limonciello

When passed around internally the upper 8 bits of power limit include the limit type. This is non-obvious without digging into the nuances of each function. Instead pass the limit type as an argument to all applicable layers.

Just realized that I missed moving a hunk from patch 3/5 to this one with the split.

❯ git diff

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -1
index c4459dc553f0..1c5f37cd5b75 100644
@@ -510,7 +510,7 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)
 
        /* set the user dpm power limit */
        if (smu->user_dpm_profile.power_limit) {
-               ret = smu_set_power_limit(smu, smu->user_dpm_profile.power_limit);
+               ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit);
                if (ret)
                        dev_err(smu->adev->dev, "Failed to set power 
limit value\n");
        }
@@ -2258,7 +2258,7 @@ static int smu_resume(struct amdgpu_ip_block *ip_block)
        adev->pm.dpm_enabled = true;

        if (smu->current_power_limit) {
-               ret = smu_set_power_limit(smu, smu->current_power_limit);
+               ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit);
                if (ret && ret != -EOPNOTSUPP)
                        return ret;
        }
Quoted 135 lines

---
v2:
* split into two patches

---
  drivers/gpu/drm/amd/include/kgd_pp_interface.h   | 2 +-
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c              | 3 ++-
  drivers/gpu/drm/amd/pm/amdgpu_pm.c               | 3 +--
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h          | 2 +-
  drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 2 +-
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c        | 6 ++----
  drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 1 -
  7 files changed, 8 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -1
index 2b0cdb2a2775..87814c2b526e 100644
@@ -454,7 +454,7 @@ struct amd_pm_funcs {
  				bool gate,
  				int inst);
  	int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
-	int (*set_power_limit)(void *handle, uint32_t n);
+	int (*set_power_limit)(void *handle, uint32_t limit_type, uint32_t n);
  	int (*get_power_limit)(void *handle, uint32_t *limit,
  			enum pp_power_limit_level pp_limit_level,
  			enum pp_power_type power_type);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -1
index 518d07afc7df..5d08dc3b7110 100644
@@ -1616,6 +1616,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
  }
 
  int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
+			       uint32_t limit_type,
  			       uint32_t limit)
  {
  	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
@@ -1626,7 +1627,7 @@ int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
 
  	mutex_lock(&adev->pm.mutex);
  	ret = pp_funcs->set_power_limit(adev->powerplay.pp_handle,
-					limit);
+					limit_type, limit);
  	mutex_unlock(&adev->pm.mutex);
 
  	return ret;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -2
index b5fbb0fd1dc0..6bdf185c6b60 100644
@@ -3390,13 +3390,12 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
  		return err;
 
  	value = value / 1000000; /* convert to Watt */
-	value |= limit_type << 24;
 
  	err = amdgpu_pm_get_access(adev);
  	if (err < 0)
  		return err;
 
-	err = amdgpu_dpm_set_power_limit(adev, value);
+	err = amdgpu_dpm_set_power_limit(adev, limit_type, value);
 
  	amdgpu_pm_put_access(adev);
 
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -1
index 65c1d98af26c..3bce74f8bb0a 100644
@@ -553,7 +553,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
  			       enum pp_power_limit_level pp_limit_level,
  			       enum pp_power_type power_type);
  int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
-			       uint32_t limit);
+			       uint32_t limit_type, uint32_t limit);
  int amdgpu_dpm_is_cclk_dpm_supported(struct amdgpu_device *adev);
  int amdgpu_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
  						       struct seq_file *m);
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1 -1
index fb595a70bbd1..76a5353d7f4a 100644
@@ -952,7 +952,7 @@ static int pp_dpm_switch_power_profile(void *handle,
  	return 0;
  }
 
-static int pp_set_power_limit(void *handle, uint32_t limit)
+static int pp_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit)
  {
  	struct pp_hwmgr *hwmgr = handle;
  	uint32_t max_power_limit;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -4
index fb8086859857..c4459dc553f0 100644
@@ -68,7 +68,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);
+static int smu_set_power_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);
@@ -2958,16 +2958,14 @@ int smu_get_power_limit(void *handle,
  	return ret;
  }
 
-static int smu_set_power_limit(void *handle, uint32_t limit)
+static int smu_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit)
  {
  	struct smu_context *smu = handle;
-	uint32_t limit_type = limit >> 24;
  	int ret = 0;
 
  	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
  		return -EOPNOTSUPP;
 
-	limit &= (1<<24)-1;
  	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);
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0 -1
index 2c9869feba61..81077a3969e9 100644
@@ -2399,7 +2399,6 @@ static int vangogh_set_power_limit(struct smu_context *smu,
  		smu->current_power_limit = ppt_limit;
  		break;
  	case SMU_FAST_PPT_LIMIT:
-		ppt_limit &= ~(SMU_FAST_PPT_LIMIT << 24);
  		if (ppt_limit > power_context->max_fast_ppt_limit) {
  			dev_err(smu->adev->dev,
  				"New power limit (%d) is over the max allowed %d\n",
#4 lore raw

RE: [PATCH v2 2/5] drm/amd: Stop overloading power limit with limit type

[Public]

The change here in smu_restore_dpm_user_profile will need a revision of patch 3 also 😊

Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Mario Limonciello
Sent: Monday, October 6, 2025 10:11 PM
To: open list:RADEON and AMDGPU DRM DRIVERS <[email protected]>
Subject: Re: [PATCH v2 2/5] drm/amd: Stop overloading power limit with limit type

Quoted 5 lines · Mario Limonciello

When passed around internally the upper 8 bits of power limit include the limit type. This is non-obvious without digging into the nuances of each function. Instead pass the limit type as an argument to all applicable layers.

Just realized that I missed moving a hunk from patch 3/5 to this one with the split.

❯ git diff

(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index c4459dc553f0..1c5f37cd5b75 100644

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
@@ -510,7 +510,7 @@ static void smu_restore_dpm_user_profile(struct

smu_context *smu)

         /* set the user dpm power limit */
         if (smu->user_dpm_profile.power_limit) {
-               ret = smu_set_power_limit(smu,
smu->user_dpm_profile.power_limit);
+               ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT,
smu->current_power_limit);
                 if (ret)
                         dev_err(smu->adev->dev, "Failed to set power limit value\n");
         }
@@ -2258,7 +2258,7 @@ static int smu_resume(struct amdgpu_ip_block
*ip_block)
         adev->pm.dpm_enabled = true;

         if (smu->current_power_limit) {
-               ret = smu_set_power_limit(smu, smu->current_power_limit);
+               ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT,
smu->current_power_limit);
                 if (ret && ret != -EOPNOTSUPP)
                         return ret;
         }
Quoted 147 lines

---
v2:
* split into two patches

---
  drivers/gpu/drm/amd/include/kgd_pp_interface.h   | 2 +-
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c              | 3 ++-
  drivers/gpu/drm/amd/pm/amdgpu_pm.c               | 3 +--
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h          | 2 +-
  drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 2 +-
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c        | 6 ++----
  drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 1 -
  7 files changed, 8 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -1
index 2b0cdb2a2775..87814c2b526e 100644
@@ -454,7 +454,7 @@ struct amd_pm_funcs {
                              bool gate,
                              int inst);
      int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
-     int (*set_power_limit)(void *handle, uint32_t n);
+     int (*set_power_limit)(void *handle, uint32_t limit_type, uint32_t
+n);
      int (*get_power_limit)(void *handle, uint32_t *limit,
                      enum pp_power_limit_level pp_limit_level,
                      enum pp_power_type power_type);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
index 518d07afc7df..5d08dc3b7110 100644
@@ -1616,6 +1616,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
  }
 
  int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
+                            uint32_t limit_type,
                             uint32_t limit)
  {
      const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; @@
-1626,7 +1627,7 @@ int amdgpu_dpm_set_power_limit(struct amdgpu_device

*adev,

      mutex_lock(&adev->pm.mutex);
      ret = pp_funcs->set_power_limit(adev->powerplay.pp_handle,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
-                                     limit);
+                                     limit_type, limit);
      mutex_unlock(&adev->pm.mutex);
 
      return ret;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -2
index b5fbb0fd1dc0..6bdf185c6b60 100644
@@ -3390,13 +3390,12 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
              return err;
 
      value = value / 1000000; /* convert to Watt */
-     value |= limit_type << 24;
 
      err = amdgpu_pm_get_access(adev);
      if (err < 0)
              return err;
 
-     err = amdgpu_dpm_set_power_limit(adev, value);
+     err = amdgpu_dpm_set_power_limit(adev, limit_type, value);
 
      amdgpu_pm_put_access(adev);
 
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -1
index 65c1d98af26c..3bce74f8bb0a 100644
@@ -553,7 +553,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
                             enum pp_power_limit_level pp_limit_level,
                             enum pp_power_type power_type);
  int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
-                            uint32_t limit);
+                            uint32_t limit_type, uint32_t limit);
  int amdgpu_dpm_is_cclk_dpm_supported(struct amdgpu_device *adev);
  int amdgpu_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
                                                     struct seq_file *m);
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2 -1
index fb595a70bbd1..76a5353d7f4a 100644
@@ -952,7 +952,7 @@ static int pp_dpm_switch_power_profile(void *handle,
      return 0;
  }
 
-static int pp_set_power_limit(void *handle, uint32_t limit)
+static int pp_set_power_limit(void *handle, uint32_t limit_type,
+uint32_t limit)
  {
      struct pp_hwmgr *hwmgr = handle;
      uint32_t max_power_limit;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
index fb8086859857..c4459dc553f0 100644
@@ -68,7 +68,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);
+static int smu_set_power_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); @@ -2958,16 +2958,14 @@ int smu_get_power_limit(void *handle,

      return ret;

}

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -3
-static int smu_set_power_limit(void *handle, uint32_t limit)
+static int smu_set_power_limit(void *handle, uint32_t limit_type,
+uint32_t limit)
  {
      struct smu_context *smu = handle;
-     uint32_t limit_type = limit >> 24;
      int ret = 0;
 
      if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
              return -EOPNOTSUPP;
 
-     limit &= (1<<24)-1;
      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);
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0 -1
index 2c9869feba61..81077a3969e9 100644
@@ -2399,7 +2399,6 @@ static int vangogh_set_power_limit(struct smu_context *smu,
              smu->current_power_limit = ppt_limit;
              break;
      case SMU_FAST_PPT_LIMIT:
-             ppt_limit &= ~(SMU_FAST_PPT_LIMIT << 24);
              if (ppt_limit > power_context->max_fast_ppt_limit) {
                      dev_err(smu->adev->dev,
                              "New power limit (%d) is over the max allowed %d\n",
#5 lore raw

PATCH v2 3/5 drm/amd: Save and restore all limit types

In reply to Mario Limonciello

Vangogh has separate limits for default PPT and fast PPT. Add infrastructure to save both of these limits and restore both of them.

---
v2:
* split from previous patch

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 23 ++++++++++++-------
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++-
 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +15 -8
index c4459dc553f0..e87e729b230b 100644
@@ -508,11 +508,16 @@ 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->user_dpm_profile.power_limit);
+	/* set the user dpm power limits */
+	for (int limit_type = SMU_DEFAULT_PPT_LIMIT; limit_type < SMU_LIMIT_TYPE_COUNT; limit_type++) {
+		if (!smu->user_dpm_profile.power_limits[limit_type])
+			continue;
+		ret = smu_set_power_limit(smu, limit_type,
+					  smu->user_dpm_profile.power_limits[limit_type]);
 		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",
+				limit_type);
+
 	}
 
 	/* set the user dpm clock configurations */
@@ -2258,7 +2263,7 @@ static int smu_resume(struct amdgpu_ip_block *ip_block)
 	adev->pm.dpm_enabled = true;
 
 	if (smu->current_power_limit) {
-		ret = smu_set_power_limit(smu, smu->current_power_limit);
+		ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit);
 		if (ret && ret != -EOPNOTSUPP)
 			return ret;
 	}
@@ -2982,11 +2987,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)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2 -1
index 582c186d8b62..32387e8c138b 100644
@@ -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;
Signature · 1 line
2.51.0
#6 lore raw

PATCH v2 4/5 drm/amd: Drop calls to restore power limit and clock from smu_resume()

In reply to Mario Limonciello

User requested power limits and clock settings are already restored as part of smu_restore_dpm_user_profile(). It's unnecessary to call the same restore as part of smu_resume().

Revert the following commits to drop that extra restore:
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume")
commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume") commit f9b80514a722 ("drm/amd: Only restore cached manual clock settings in restore if OD enabled")

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -13
index e87e729b230b..5ec42de1d91d 100644
@@ -2230,7 +2230,6 @@ static int smu_resume(struct amdgpu_ip_block *ip_block)
 	int ret;
 	struct amdgpu_device *adev = ip_block->adev;
 	struct smu_context *smu = adev->powerplay.pp_handle;
-	struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
 
 	if (amdgpu_sriov_multi_vf_mode(adev))
 		return 0;
@@ -2262,18 +2261,6 @@ static int smu_resume(struct amdgpu_ip_block *ip_block)
 
 	adev->pm.dpm_enabled = true;
 
-	if (smu->current_power_limit) {
-		ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit);
-		if (ret && ret != -EOPNOTSUPP)
-			return ret;
-	}
-
-	if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL && smu->od_enabled) {
-		ret = smu_od_edit_dpm_table(smu, PP_OD_COMMIT_DPM_TABLE, NULL, 0);
-		if (ret)
-			return ret;
-	}
-
 	dev_info(adev->dev, "SMU is resumed successfully!\n");
 
 	return 0;
Signature · 1 line
2.51.0
#7 lore raw

PATCH v2 5/5 drm/amd: Adjust whitespace for vangogh_ppt

In reply to Mario Limonciello

A few changes have more whitespace than needed. Clean them up.

---
 drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5 -7
index 81077a3969e9..1dcbf250f486 100644
@@ -2308,8 +2308,7 @@ static int vangogh_get_power_limit(struct smu_context *smu,
 				   uint32_t *max_power_limit,
 				   uint32_t *min_power_limit)
 {
-	struct smu_11_5_power_context *power_context =
-								smu->smu_power.power_context;
+	struct smu_11_5_power_context *power_context = smu->smu_power.power_context;
 	uint32_t ppt_limit;
 	int ret = 0;
 
@@ -2345,12 +2344,11 @@ static int vangogh_get_power_limit(struct smu_context *smu,
 }
 
 static int vangogh_get_ppt_limit(struct smu_context *smu,
-								uint32_t *ppt_limit,
-								enum smu_ppt_limit_type type,
-								enum smu_ppt_limit_level level)
+				 uint32_t *ppt_limit,
+				 enum smu_ppt_limit_type type,
+				 enum smu_ppt_limit_level level)
 {
-	struct smu_11_5_power_context *power_context =
-							smu->smu_power.power_context;
+	struct smu_11_5_power_context *power_context = smu->smu_power.power_context;
 
 	if (!power_context)
 		return -EOPNOTSUPP;
Signature · 1 line
2.51.0
Tested-by on the v2 series
#8 lore raw
In reply to Mario Limonciello

From: Robert Beckett <[email protected]>

Quoted 17 lines

Lijo pointed out to me that
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume") commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume") both should be unnecessary because smu_restore_dpm_user_profile() already restores them. However in looking at the code there is a case that isn't properly restored - the FAST PPT limits supported by Van Gogh. The nuance isn't immediately obvious because the limit variable is overloaded with limit type.
This series attempts to address that issue by passing limit type around and saving/restoring both types.
Cc: Lijo Lazar <[email protected]>
Mario Limonciello (5):
drm/amd: Remove some unncessary header includes
drm/amd: Stop overloading power limit with limit type
drm/amd: Save and restore all limit types
drm/amd: Drop calls to restore power limit and clock from smu_resume() drm/amd: Adjust whitespace for vangogh_ppt

Quoted 11 lines
 .../gpu/drm/amd/include/kgd_pp_interface.h    |  2 +-
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 +-
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  2 +-
 .../gpu/drm/amd/pm/powerplay/amd_powerplay.c  |  5 +--
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 40 ++++++++-----------
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 +-
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 13 +++---
 8 files changed, 29 insertions(+), 42 deletions(-)
Signature · 1 line
2.51.0

entire series

#9 lore raw

--- quoted message ---

Quoted 29 lines

From: Robert Beckett <[email protected]>

Quoted 17 lines

Lijo pointed out to me that
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume") commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume") both should be unnecessary because smu_restore_dpm_user_profile() already restores them. However in looking at the code there is a case that isn't properly restored - the FAST PPT limits supported by Van Gogh. The nuance isn't immediately obvious because the limit variable is overloaded with limit type.
This series attempts to address that issue by passing limit type around and saving/restoring both types.
Cc: Lijo Lazar <[email protected]>
Mario Limonciello (5):
drm/amd: Remove some unncessary header includes
drm/amd: Stop overloading power limit with limit type
drm/amd: Save and restore all limit types
drm/amd: Drop calls to restore power limit and clock from smu_resume() drm/amd: Adjust whitespace for vangogh_ppt

Quoted 11 lines
 .../gpu/drm/amd/include/kgd_pp_interface.h    |  2 +-
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 +-
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  2 +-
 .../gpu/drm/amd/pm/powerplay/amd_powerplay.c  |  5 +--
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 40 ++++++++-----------
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 +-
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 13 +++---
 8 files changed, 29 insertions(+), 42 deletions(-)
Signature · 1 line
2.51.0
Quoted 2 lines

entire series

apologies, I need to retract this Tested-by.
I inadvertently tested v1. v2 looks like it still has the restore issue. I'll debug and get back to you.

#10 lore raw
Quoted 30 lines · Bob Beckett

--- quoted message ---

Quoted 29 lines

From: Robert Beckett <[email protected]>

Quoted 28 lines

Lijo pointed out to me that
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume") commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume") both should be unnecessary because smu_restore_dpm_user_profile() already restores them. However in looking at the code there is a case that isn't properly restored - the FAST PPT limits supported by Van Gogh. The nuance isn't immediately obvious because the limit variable is overloaded with limit type.
This series attempts to address that issue by passing limit type around and saving/restoring both types.
Cc: Lijo Lazar <[email protected]>
Mario Limonciello (5):
drm/amd: Remove some unncessary header includes
drm/amd: Stop overloading power limit with limit type
drm/amd: Save and restore all limit types
drm/amd: Drop calls to restore power limit and clock from smu_resume() drm/amd: Adjust whitespace for vangogh_ppt

  .../gpu/drm/amd/include/kgd_pp_interface.h    |  2 +-
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 +-
  drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +-
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  2 +-
  .../gpu/drm/amd/pm/powerplay/amd_powerplay.c  |  5 +--
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 40 ++++++++-----------
  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 +-
  .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 13 +++---
  8 files changed, 29 insertions(+), 42 deletions(-)
Signature · 1 line
2.51.0
Quoted 6 lines
Quoted 2 lines

entire series

apologies, I need to retract this Tested-by.
I inadvertently tested v1. v2 looks like it still has the restore issue. I'll debug and get back to you.

Oh thanks for getting back. Let me hold up our merge on the patches then too.

Tested-by
#11 lore raw

---- On Tue, 07 Oct 2025 20:40:43 +0100 Mario Limonciello <[email protected]> wrote ---

Quoted 34 lines · Bob Beckett
Quoted 33 lines

--- quoted message ---

Quoted 31 lines

From: Robert Beckett <[email protected]>

Quoted 17 lines

Lijo pointed out to me that
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume") commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume") both should be unnecessary because smu_restore_dpm_user_profile() already restores them. However in looking at the code there is a case that isn't properly restored - the FAST PPT limits supported by Van Gogh. The nuance isn't immediately obvious because the limit variable is overloaded with limit type.
This series attempts to address that issue by passing limit type around and saving/restoring both types.
Cc: Lijo Lazar <[email protected]>
Mario Limonciello (5):
drm/amd: Remove some unncessary header includes
drm/amd: Stop overloading power limit with limit type
drm/amd: Save and restore all limit types
drm/amd: Drop calls to restore power limit and clock from smu_resume() drm/amd: Adjust whitespace for vangogh_ppt

Quoted 11 lines
  .../gpu/drm/amd/include/kgd_pp_interface.h    |  2 +-
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 +-
  drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +-
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  2 +-
  .../gpu/drm/amd/pm/powerplay/amd_powerplay.c  |  5 +--
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 40 ++++++++-----------
  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 +-
  .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 13 +++---
  8 files changed, 29 insertions(+), 42 deletions(-)
Signature · 1 line
2.51.0

entire series

Quoted 7 lines
Quoted 3 lines

apologies, I need to retract this Tested-by.
I inadvertently tested v1. v2 looks like it still has the restore issue. I'll debug and get back to you.

Oh thanks for getting back. Let me hold up our merge on the patches then too.

The issue with v2 turned out to be quite simple in the end. You dropped

drm/amd: Drop superfluous call to set_power_limit()

from v1.
picking that on top of v2 series makes it work again, so assuming v3 adds this back, have another:

entire series

#12 lore raw
Quoted 47 lines · Robert Beckett

---- On Tue, 07 Oct 2025 20:40:43 +0100 Mario Limonciello <[email protected]> wrote ---

Quoted 34 lines · Bob Beckett
Quoted 33 lines

--- quoted message ---

Quoted 31 lines

From: Robert Beckett <[email protected]>

Quoted 26 lines

Lijo pointed out to me that
commit ed4efe426a49 ("drm/amd: Restore cached power limit during resume") commit 796ff8a7e01b ("drm/amd: Restore cached manual clock settings during resume") both should be unnecessary because smu_restore_dpm_user_profile() already restores them. However in looking at the code there is a case that isn't properly restored - the FAST PPT limits supported by Van Gogh. The nuance isn't immediately obvious because the limit variable is overloaded with limit type.
This series attempts to address that issue by passing limit type around and saving/restoring both types.
Cc: Lijo Lazar <[email protected]>
Mario Limonciello (5):
drm/amd: Remove some unncessary header includes
drm/amd: Stop overloading power limit with limit type
drm/amd: Save and restore all limit types
drm/amd: Drop calls to restore power limit and clock from smu_resume() drm/amd: Adjust whitespace for vangogh_ppt

  .../gpu/drm/amd/include/kgd_pp_interface.h    |  2 +-
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 +-
  drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +-
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  2 +-
  .../gpu/drm/amd/pm/powerplay/amd_powerplay.c  |  5 +--
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 40 ++++++++-----------
  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 +-
  .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 13 +++---
  8 files changed, 29 insertions(+), 42 deletions(-)
Quoted 2 lines

--
2.51.0

entire series

Quoted 7 lines
Quoted 3 lines

apologies, I need to retract this Tested-by.
I inadvertently tested v1. v2 looks like it still has the restore issue. I'll debug and get back to you.

Oh thanks for getting back. Let me hold up our merge on the patches then too.

The issue with v2 turned out to be quite simple in the end. You dropped

Quoted 8 lines

drm/amd: Drop superfluous call to set_power_limit()

from v1.
picking that on top of v2 series makes it work again, so assuming v3 adds this back, have another:

entire series

Lijo had commented that limits are different for default and fast PPT, so we shouldn't be dropping that. There is already a check in vangogh_set_power_limit() which is used for checking fast limits.

So to me it appears the issue here is with the handling of fast PPT. With that patch (Drop superfluous call to set_power_limit) in place do you see "New power limit (%d) is out of range" in the logs?

If not; maybe can you annotate with the v2 applied but not that "Drop superfluous call to set_power_limit" patch what each call to smu_set_power_limit() has for arguments and what max_power_limit, min_power_limit are.

I wonder if you're ending up with a call with a fast limit of 0. If so; throw a dump_stack() in that condition so we can understand why. I see max_fast_ppt_limit is hard coded to 30 in vangogh_ppt.