AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] drm/amd/pm: Update pmfw headers for smuv_13_0_12
@ 2025-11-06 11:44 Asad Kamal
  2025-11-06 11:44 ` [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12 Asad Kamal
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Asad Kamal @ 2025-11-06 11:44 UTC (permalink / raw)
  To: amd-gfx
  Cc: lijo.lazar, hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
	asad.kamal, KevinYang.Wang

Update pmfw headers for smmu_v13_0_12 to include ppt1 messages and
static parameters

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
 drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_pmfw.h | 5 +++++
 .../gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_ppsmc.h    | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_pmfw.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_pmfw.h
index bf6aa9620911..bb7d48e3b60e 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_pmfw.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_pmfw.h
@@ -367,6 +367,11 @@ typedef struct {
 
   //Node Power Limit
   uint32_t MaxNodePowerLimit;
+
+  // PPT1 Configuration
+  uint32_t PPT1Max;
+  uint32_t PPT1Min;
+  uint32_t PPT1Default;
 } StaticMetricsTable_t;
 #pragma pack(pop)
 
diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_ppsmc.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_ppsmc.h
index 4b066c42e0ec..bd811efa3232 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_ppsmc.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_12_ppsmc.h
@@ -121,7 +121,9 @@
 #define PPSMC_MSG_GetSystemMetricsTable             0x5C
 #define PPSMC_MSG_GetSystemMetricsVersion           0x5D
 #define PPSMC_MSG_ResetVCN                          0x5E
-#define PPSMC_Message_Count                         0x5F
+#define PPSMC_MSG_SetFastPptLimit                   0x5F
+#define PPSMC_MSG_GetFastPptLimit                   0x60
+#define PPSMC_Message_Count                         0x61
 
 //PPSMC Reset Types for driver msg argument
 #define PPSMC_RESET_TYPE_DRIVER_MODE_1_RESET        0x1
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12
  2025-11-06 11:44 [PATCH v2 1/4] drm/amd/pm: Update pmfw headers for smuv_13_0_12 Asad Kamal
@ 2025-11-06 11:44 ` Asad Kamal
  2025-11-06 13:25   ` Lazar, Lijo
  2025-11-06 11:44 ` [PATCH v2 3/4] drm/amd/pm: Expose ppt1 limit for gc_v9_5_0 Asad Kamal
  2025-11-06 11:44 ` [PATCH v2 4/4] drm/amd/pm: Enable ppt1 caps for smu_v13_0_12 Asad Kamal
  2 siblings, 1 reply; 6+ messages in thread
From: Asad Kamal @ 2025-11-06 11:44 UTC (permalink / raw)
  To: amd-gfx
  Cc: lijo.lazar, hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
	asad.kamal, KevinYang.Wang

Add support to configure and retrieve ppt1 limit for smu_v13_0_12

v2: Add update_caps function and update ppt1 cap based on max ppt1
value, optimize the return values (Lijo)

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h  |  4 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c |  8 ++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 79 ++++++++++++++++++-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h  |  4 +
 4 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
index 2256c77da636..5fb71d4398f4 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
@@ -279,7 +279,9 @@
 	__SMU_DUMMY_MAP(ResetSDMA), \
 	__SMU_DUMMY_MAP(ResetVCN), \
 	__SMU_DUMMY_MAP(GetStaticMetricsTable), \
-	__SMU_DUMMY_MAP(GetSystemMetricsTable),
+	__SMU_DUMMY_MAP(GetSystemMetricsTable), \
+	__SMU_DUMMY_MAP(SetFastPptLimit), \
+	__SMU_DUMMY_MAP(GetFastPptLimit),
 
 #undef __SMU_DUMMY_MAP
 #define __SMU_DUMMY_MAP(type)	SMU_MSG_##type
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
index a0c844bf852c..e2851b26593a 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
@@ -139,6 +139,8 @@ const struct cmn2asic_msg_mapping smu_v13_0_12_message_map[SMU_MSG_MAX_COUNT] =
 	MSG_MAP(ResetVCN,                            PPSMC_MSG_ResetVCN,                        0),
 	MSG_MAP(GetStaticMetricsTable,               PPSMC_MSG_GetStaticMetricsTable,           1),
 	MSG_MAP(GetSystemMetricsTable,               PPSMC_MSG_GetSystemMetricsTable,           1),
+	MSG_MAP(SetFastPptLimit,		     PPSMC_MSG_SetFastPptLimit,			1),
+	MSG_MAP(GetFastPptLimit,		     PPSMC_MSG_GetFastPptLimit,			1),
 };
 
 int smu_v13_0_12_tables_init(struct smu_context *smu)
@@ -345,6 +347,12 @@ int smu_v13_0_12_setup_driver_pptable(struct smu_context *smu)
 		if (smu_v13_0_6_cap_supported(smu, SMU_CAP(NPM_METRICS)))
 			pptable->MaxNodePowerLimit =
 				SMUQ10_ROUND(static_metrics->MaxNodePowerLimit);
+		if (smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)) &&
+		    static_metrics->PPT1Max) {
+			pptable->PPT1Max = static_metrics->PPT1Max;
+			pptable->PPT1Min = static_metrics->PPT1Min;
+			pptable->PPT1Default = static_metrics->PPT1Default;
+		}
 		smu_v13_0_12_init_xgmi_data(smu, static_metrics);
 		pptable->Init = true;
 	}
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 197fd91e1fb4..282bd00a909c 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -851,6 +851,17 @@ int smu_v13_0_6_get_static_metrics_table(struct smu_context *smu)
 	return 0;
 }
 
+static void smu_v13_0_6_update_caps(struct smu_context *smu)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	struct PPTable_t *pptable =
+		(struct PPTable_t *)smu_table->driver_pptable;
+
+	if (smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)) &&
+	    !pptable->PPT1Max)
+		smu_v13_0_6_cap_clear(smu, SMU_CAP(FAST_PPT));
+}
+
 static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
 {
 	struct smu_table_context *smu_table = &smu->smu_table;
@@ -867,8 +878,12 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
 	uint8_t max_width;
 
 	if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 12) &&
-	    smu_v13_0_6_cap_supported(smu, SMU_CAP(STATIC_METRICS)))
-		return smu_v13_0_12_setup_driver_pptable(smu);
+	    smu_v13_0_6_cap_supported(smu, SMU_CAP(STATIC_METRICS))) {
+		ret = smu_v13_0_12_setup_driver_pptable(smu);
+		if (ret)
+			return ret;
+		goto out;
+	}
 
 	/* Store one-time values in driver PPTable */
 	if (!pptable->Init) {
@@ -948,7 +963,8 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
 			smu_v13_0_6_fill_static_metrics_table(smu, static_metrics);
 		}
 	}
-
+out:
+	smu_v13_0_6_update_caps(smu);
 	return 0;
 }
 
@@ -1882,9 +1898,65 @@ static int smu_v13_0_6_set_power_limit(struct smu_context *smu,
 				       enum smu_ppt_limit_type limit_type,
 				       uint32_t limit)
 {
+	struct smu_table_context *smu_table = &smu->smu_table;
+	struct PPTable_t *pptable =
+		(struct PPTable_t *)smu_table->driver_pptable;
+	int ret;
+
+	if (limit_type == SMU_FAST_PPT_LIMIT) {
+		if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)))
+			return -EOPNOTSUPP;
+		if (limit > pptable->PPT1Max || limit < pptable->PPT1Min) {
+			dev_err(smu->adev->dev,
+				"New power limit (%d) should be between min %d max %d\n",
+				limit, pptable->PPT1Min, pptable->PPT1Max);
+			return -EINVAL;
+		}
+		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetFastPptLimit,
+						      limit, NULL);
+		if (ret)
+			dev_err(smu->adev->dev, "Set fast PPT limit failed!\n");
+		return ret;
+	}
+
 	return smu_v13_0_set_power_limit(smu, limit_type, limit);
 }
 
+static int smu_v13_0_6_get_ppt_limit(struct smu_context *smu,
+				     uint32_t *ppt_limit,
+				     enum smu_ppt_limit_type type,
+				     enum smu_ppt_limit_level level)
+{
+	struct smu_table_context *smu_table = &smu->smu_table;
+	struct PPTable_t *pptable =
+		(struct PPTable_t *)smu_table->driver_pptable;
+	int ret = 0;
+
+	if (type == SMU_FAST_PPT_LIMIT) {
+		if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)))
+			return -EOPNOTSUPP;
+		switch (level) {
+		case SMU_PPT_LIMIT_MAX:
+			*ppt_limit = pptable->PPT1Max;
+			break;
+		case SMU_PPT_LIMIT_CURRENT:
+			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPptLimit, ppt_limit);
+			if (ret)
+				dev_err(smu->adev->dev, "Get fast PPT limit failed!\n");
+			break;
+		case SMU_PPT_LIMIT_DEFAULT:
+			*ppt_limit = pptable->PPT1Default;
+			break;
+		case SMU_PPT_LIMIT_MIN:
+			*ppt_limit = pptable->PPT1Min;
+			break;
+		default:
+			break;
+		}
+	}
+	return ret;
+}
+
 static int smu_v13_0_6_irq_process(struct amdgpu_device *adev,
 				   struct amdgpu_irq_src *source,
 				   struct amdgpu_iv_entry *entry)
@@ -3934,6 +4006,7 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {
 	.get_enabled_mask = smu_v13_0_6_get_enabled_mask,
 	.feature_is_enabled = smu_cmn_feature_is_enabled,
 	.set_power_limit = smu_v13_0_6_set_power_limit,
+	.get_ppt_limit = smu_v13_0_6_get_ppt_limit,
 	.set_xgmi_pstate = smu_v13_0_set_xgmi_pstate,
 	.register_irq_handler = smu_v13_0_6_register_irq_handler,
 	.enable_thermal_alert = smu_v13_0_enable_thermal_alert,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
index 7ef5f3e66c27..4a47025b49e0 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
@@ -50,6 +50,9 @@ struct PPTable_t {
 	uint32_t MinLclkDpmRange;
 	uint64_t PublicSerialNumber_AID;
 	uint32_t MaxNodePowerLimit;
+	uint32_t PPT1Max;
+	uint32_t PPT1Min;
+	uint32_t PPT1Default;
 	bool Init;
 };
 
@@ -72,6 +75,7 @@ enum smu_v13_0_6_caps {
 	SMU_CAP(PLDM_VERSION),
 	SMU_CAP(TEMP_METRICS),
 	SMU_CAP(NPM_METRICS),
+	SMU_CAP(FAST_PPT),
 	SMU_CAP(ALL),
 };
 
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] drm/amd/pm: Expose ppt1 limit for gc_v9_5_0
  2025-11-06 11:44 [PATCH v2 1/4] drm/amd/pm: Update pmfw headers for smuv_13_0_12 Asad Kamal
  2025-11-06 11:44 ` [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12 Asad Kamal
@ 2025-11-06 11:44 ` Asad Kamal
  2025-11-06 13:28   ` Lazar, Lijo
  2025-11-06 11:44 ` [PATCH v2 4/4] drm/amd/pm: Enable ppt1 caps for smu_v13_0_12 Asad Kamal
  2 siblings, 1 reply; 6+ messages in thread
From: Asad Kamal @ 2025-11-06 11:44 UTC (permalink / raw)
  To: amd-gfx
  Cc: lijo.lazar, hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
	asad.kamal, KevinYang.Wang

Expose power2_cap hwmon node for retrieving and configuring ppt1
limit on supported boards for gc_v9_5_0

v2: Remove version check

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c        | 12 +++++++++---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 69aa8e22f103..49cc5aaa749c 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -3373,7 +3373,9 @@ static ssize_t amdgpu_hwmon_show_power_label(struct device *dev,
 				  to_sensor_dev_attr(attr)->index == PP_PWR_TYPE_FAST ?
 				  "fastPPT" : "slowPPT");
 	else
-		return sysfs_emit(buf, "PPT\n");
+		return sysfs_emit(buf, "%s\n",
+				  to_sensor_dev_attr(attr)->index == PP_PWR_TYPE_FAST ?
+				  "PPT1" : "PPT");
 }
 
 static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
@@ -3737,7 +3739,8 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
 		return 0;
 
 	/* not all products support both average and instantaneous */
-	if (attr == &sensor_dev_attr_power1_average.dev_attr.attr &&
+	if ((attr == &sensor_dev_attr_power1_average.dev_attr.attr ||
+	     attr == &sensor_dev_attr_power2_average.dev_attr.attr) &&
 	    amdgpu_pm_get_sensor_generic(adev, AMDGPU_PP_SENSOR_GPU_AVG_POWER,
 					 (void *)&tmp) == -EOPNOTSUPP)
 		return 0;
@@ -3832,7 +3835,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
 	     attr == &sensor_dev_attr_power2_cap_min.dev_attr.attr ||
 	     attr == &sensor_dev_attr_power2_cap.dev_attr.attr ||
 	     attr == &sensor_dev_attr_power2_cap_default.dev_attr.attr ||
-	     attr == &sensor_dev_attr_power2_label.dev_attr.attr))
+	     attr == &sensor_dev_attr_power2_label.dev_attr.attr) &&
+	     (amdgpu_dpm_get_power_limit(adev, &tmp,
+					 PP_PWR_LIMIT_MAX,
+					 PP_PWR_TYPE_FAST) == -EOPNOTSUPP))
 		return 0;
 
 	return effective_mode;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 4317da6f7c38..73a063748c86 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -2921,6 +2921,8 @@ int smu_get_power_limit(void *handle,
 	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:
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] drm/amd/pm: Enable ppt1 caps for smu_v13_0_12
  2025-11-06 11:44 [PATCH v2 1/4] drm/amd/pm: Update pmfw headers for smuv_13_0_12 Asad Kamal
  2025-11-06 11:44 ` [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12 Asad Kamal
  2025-11-06 11:44 ` [PATCH v2 3/4] drm/amd/pm: Expose ppt1 limit for gc_v9_5_0 Asad Kamal
@ 2025-11-06 11:44 ` Asad Kamal
  2 siblings, 0 replies; 6+ messages in thread
From: Asad Kamal @ 2025-11-06 11:44 UTC (permalink / raw)
  To: amd-gfx
  Cc: lijo.lazar, hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
	asad.kamal, KevinYang.Wang

Enable ppt1 caps to fetch and configure ppt1 for smu_v13_0_12

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 282bd00a909c..81d8fc51a5de 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -356,6 +356,9 @@ static void smu_v13_0_12_init_caps(struct smu_context *smu)
 	if (fw_ver > 0x04560900)
 		smu_v13_0_6_cap_set(smu, SMU_CAP(VCN_RESET));
 
+	if (fw_ver >= 0x04560D00)
+		smu_v13_0_6_cap_set(smu, SMU_CAP(FAST_PPT));
+
 	if (fw_ver >= 0x04560700) {
 		if (fw_ver >= 0x04560900) {
 			smu_v13_0_6_cap_set(smu, SMU_CAP(TEMP_METRICS));
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12
  2025-11-06 11:44 ` [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12 Asad Kamal
@ 2025-11-06 13:25   ` Lazar, Lijo
  0 siblings, 0 replies; 6+ messages in thread
From: Lazar, Lijo @ 2025-11-06 13:25 UTC (permalink / raw)
  To: Asad Kamal, amd-gfx
  Cc: hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
	KevinYang.Wang



On 11/6/2025 5:14 PM, Asad Kamal wrote:
> Add support to configure and retrieve ppt1 limit for smu_v13_0_12
> 
> v2: Add update_caps function and update ppt1 cap based on max ppt1
> value, optimize the return values (Lijo)
> 
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
>   drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h  |  4 +-
>   .../drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c |  8 ++
>   .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 79 ++++++++++++++++++-
>   .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h  |  4 +
>   4 files changed, 91 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
> index 2256c77da636..5fb71d4398f4 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
> @@ -279,7 +279,9 @@
>   	__SMU_DUMMY_MAP(ResetSDMA), \
>   	__SMU_DUMMY_MAP(ResetVCN), \
>   	__SMU_DUMMY_MAP(GetStaticMetricsTable), \
> -	__SMU_DUMMY_MAP(GetSystemMetricsTable),
> +	__SMU_DUMMY_MAP(GetSystemMetricsTable), \
> +	__SMU_DUMMY_MAP(SetFastPptLimit), \
> +	__SMU_DUMMY_MAP(GetFastPptLimit),
>   
>   #undef __SMU_DUMMY_MAP
>   #define __SMU_DUMMY_MAP(type)	SMU_MSG_##type
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
> index a0c844bf852c..e2851b26593a 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
> @@ -139,6 +139,8 @@ const struct cmn2asic_msg_mapping smu_v13_0_12_message_map[SMU_MSG_MAX_COUNT] =
>   	MSG_MAP(ResetVCN,                            PPSMC_MSG_ResetVCN,                        0),
>   	MSG_MAP(GetStaticMetricsTable,               PPSMC_MSG_GetStaticMetricsTable,           1),
>   	MSG_MAP(GetSystemMetricsTable,               PPSMC_MSG_GetSystemMetricsTable,           1),
> +	MSG_MAP(SetFastPptLimit,		     PPSMC_MSG_SetFastPptLimit,			1),
> +	MSG_MAP(GetFastPptLimit,		     PPSMC_MSG_GetFastPptLimit,			1),
>   };
>   
>   int smu_v13_0_12_tables_init(struct smu_context *smu)
> @@ -345,6 +347,12 @@ int smu_v13_0_12_setup_driver_pptable(struct smu_context *smu)
>   		if (smu_v13_0_6_cap_supported(smu, SMU_CAP(NPM_METRICS)))
>   			pptable->MaxNodePowerLimit =
>   				SMUQ10_ROUND(static_metrics->MaxNodePowerLimit);
> +		if (smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)) &&
> +		    static_metrics->PPT1Max) {
> +			pptable->PPT1Max = static_metrics->PPT1Max;
> +			pptable->PPT1Min = static_metrics->PPT1Min;
> +			pptable->PPT1Default = static_metrics->PPT1Default;
> +		}
>   		smu_v13_0_12_init_xgmi_data(smu, static_metrics);
>   		pptable->Init = true;
>   	}
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> index 197fd91e1fb4..282bd00a909c 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> @@ -851,6 +851,17 @@ int smu_v13_0_6_get_static_metrics_table(struct smu_context *smu)
>   	return 0;
>   }
>   
> +static void smu_v13_0_6_update_caps(struct smu_context *smu)
> +{
> +	struct smu_table_context *smu_table = &smu->smu_table;
> +	struct PPTable_t *pptable =
> +		(struct PPTable_t *)smu_table->driver_pptable;
> +
> +	if (smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)) &&
> +	    !pptable->PPT1Max)
> +		smu_v13_0_6_cap_clear(smu, SMU_CAP(FAST_PPT));
> +}
> +
>   static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
>   {
>   	struct smu_table_context *smu_table = &smu->smu_table;
> @@ -867,8 +878,12 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
>   	uint8_t max_width;
>   
>   	if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 12) &&
> -	    smu_v13_0_6_cap_supported(smu, SMU_CAP(STATIC_METRICS)))
> -		return smu_v13_0_12_setup_driver_pptable(smu);
> +	    smu_v13_0_6_cap_supported(smu, SMU_CAP(STATIC_METRICS))) {
> +		ret = smu_v13_0_12_setup_driver_pptable(smu);
> +		if (ret)
> +			return ret;
> +		goto out;
> +	}
>   
>   	/* Store one-time values in driver PPTable */
>   	if (!pptable->Init) {
> @@ -948,7 +963,8 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
>   			smu_v13_0_6_fill_static_metrics_table(smu, static_metrics);
>   		}
>   	}
> -
> +out:
> +	smu_v13_0_6_update_caps(smu);
>   	return 0;
>   }
>   
> @@ -1882,9 +1898,65 @@ static int smu_v13_0_6_set_power_limit(struct smu_context *smu,
>   				       enum smu_ppt_limit_type limit_type,
>   				       uint32_t limit)
>   {
> +	struct smu_table_context *smu_table = &smu->smu_table;
> +	struct PPTable_t *pptable =
> +		(struct PPTable_t *)smu_table->driver_pptable;
> +	int ret;
> +
> +	if (limit_type == SMU_FAST_PPT_LIMIT) {
> +		if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)))
> +			return -EOPNOTSUPP;
> +		if (limit > pptable->PPT1Max || limit < pptable->PPT1Min) {
> +			dev_err(smu->adev->dev,
> +				"New power limit (%d) should be between min %d max %d\n",
> +				limit, pptable->PPT1Min, pptable->PPT1Max);
> +			return -EINVAL;
> +		}
> +		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetFastPptLimit,
> +						      limit, NULL);
> +		if (ret)
> +			dev_err(smu->adev->dev, "Set fast PPT limit failed!\n");
> +		return ret;
> +	}
> +
>   	return smu_v13_0_set_power_limit(smu, limit_type, limit);
>   }
>   
> +static int smu_v13_0_6_get_ppt_limit(struct smu_context *smu,
> +				     uint32_t *ppt_limit,
> +				     enum smu_ppt_limit_type type,
> +				     enum smu_ppt_limit_level level)
> +{
> +	struct smu_table_context *smu_table = &smu->smu_table;
> +	struct PPTable_t *pptable =
> +		(struct PPTable_t *)smu_table->driver_pptable;
> +	int ret = 0;
> +
> +	if (type == SMU_FAST_PPT_LIMIT) {
> +		if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(FAST_PPT)))
> +			return -EOPNOTSUPP;
> +		switch (level) {
> +		case SMU_PPT_LIMIT_MAX:
> +			*ppt_limit = pptable->PPT1Max;
> +			break;
> +		case SMU_PPT_LIMIT_CURRENT:
> +			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPptLimit, ppt_limit);
> +			if (ret)
> +				dev_err(smu->adev->dev, "Get fast PPT limit failed!\n");
> +			break;
> +		case SMU_PPT_LIMIT_DEFAULT:
> +			*ppt_limit = pptable->PPT1Default;
> +			break;
> +		case SMU_PPT_LIMIT_MIN:
> +			*ppt_limit = pptable->PPT1Min;
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +	return ret;

Since there is an out param, returning success for other limit 
types/unrecognized limit levels is not preferred. Better to return as 
not supported.

Thanks,
Lijo

> +}
> +
>   static int smu_v13_0_6_irq_process(struct amdgpu_device *adev,
>   				   struct amdgpu_irq_src *source,
>   				   struct amdgpu_iv_entry *entry)
> @@ -3934,6 +4006,7 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {
>   	.get_enabled_mask = smu_v13_0_6_get_enabled_mask,
>   	.feature_is_enabled = smu_cmn_feature_is_enabled,
>   	.set_power_limit = smu_v13_0_6_set_power_limit,
> +	.get_ppt_limit = smu_v13_0_6_get_ppt_limit,
>   	.set_xgmi_pstate = smu_v13_0_set_xgmi_pstate,
>   	.register_irq_handler = smu_v13_0_6_register_irq_handler,
>   	.enable_thermal_alert = smu_v13_0_enable_thermal_alert,
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
> index 7ef5f3e66c27..4a47025b49e0 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
> @@ -50,6 +50,9 @@ struct PPTable_t {
>   	uint32_t MinLclkDpmRange;
>   	uint64_t PublicSerialNumber_AID;
>   	uint32_t MaxNodePowerLimit;
> +	uint32_t PPT1Max;
> +	uint32_t PPT1Min;
> +	uint32_t PPT1Default;
>   	bool Init;
>   };
>   
> @@ -72,6 +75,7 @@ enum smu_v13_0_6_caps {
>   	SMU_CAP(PLDM_VERSION),
>   	SMU_CAP(TEMP_METRICS),
>   	SMU_CAP(NPM_METRICS),
> +	SMU_CAP(FAST_PPT),
>   	SMU_CAP(ALL),
>   };
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/4] drm/amd/pm: Expose ppt1 limit for gc_v9_5_0
  2025-11-06 11:44 ` [PATCH v2 3/4] drm/amd/pm: Expose ppt1 limit for gc_v9_5_0 Asad Kamal
@ 2025-11-06 13:28   ` Lazar, Lijo
  0 siblings, 0 replies; 6+ messages in thread
From: Lazar, Lijo @ 2025-11-06 13:28 UTC (permalink / raw)
  To: Asad Kamal, amd-gfx
  Cc: hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
	KevinYang.Wang



On 11/6/2025 5:14 PM, Asad Kamal wrote:
> Expose power2_cap hwmon node for retrieving and configuring ppt1
> limit on supported boards for gc_v9_5_0
> 
> v2: Remove version check
> 
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
>   drivers/gpu/drm/amd/pm/amdgpu_pm.c        | 12 +++++++++---
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  2 ++
>   2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index 69aa8e22f103..49cc5aaa749c 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -3373,7 +3373,9 @@ static ssize_t amdgpu_hwmon_show_power_label(struct device *dev,
>   				  to_sensor_dev_attr(attr)->index == PP_PWR_TYPE_FAST ?
>   				  "fastPPT" : "slowPPT");
>   	else
> -		return sysfs_emit(buf, "PPT\n");
> +		return sysfs_emit(buf, "%s\n",
> +				  to_sensor_dev_attr(attr)->index == PP_PWR_TYPE_FAST ?
> +				  "PPT1" : "PPT");
>   }
>   
>   static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
> @@ -3737,7 +3739,8 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
>   		return 0;
>   
>   	/* not all products support both average and instantaneous */
> -	if (attr == &sensor_dev_attr_power1_average.dev_attr.attr &&
> +	if ((attr == &sensor_dev_attr_power1_average.dev_attr.attr ||
> +	     attr == &sensor_dev_attr_power2_average.dev_attr.attr) &&

Better group this with other power2 attributes.

Thanks,
Lijo

>   	    amdgpu_pm_get_sensor_generic(adev, AMDGPU_PP_SENSOR_GPU_AVG_POWER,
>   					 (void *)&tmp) == -EOPNOTSUPP)
>   		return 0;
> @@ -3832,7 +3835,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
>   	     attr == &sensor_dev_attr_power2_cap_min.dev_attr.attr ||
>   	     attr == &sensor_dev_attr_power2_cap.dev_attr.attr ||
>   	     attr == &sensor_dev_attr_power2_cap_default.dev_attr.attr ||
> -	     attr == &sensor_dev_attr_power2_label.dev_attr.attr))
> +	     attr == &sensor_dev_attr_power2_label.dev_attr.attr) &&
> +	     (amdgpu_dpm_get_power_limit(adev, &tmp,
> +					 PP_PWR_LIMIT_MAX,
> +					 PP_PWR_TYPE_FAST) == -EOPNOTSUPP))
>   		return 0;
>   
>   	return effective_mode;
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index 4317da6f7c38..73a063748c86 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -2921,6 +2921,8 @@ int smu_get_power_limit(void *handle,
>   	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:


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-06 13:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 11:44 [PATCH v2 1/4] drm/amd/pm: Update pmfw headers for smuv_13_0_12 Asad Kamal
2025-11-06 11:44 ` [PATCH v2 2/4] drm/amd/pm: Add ppt1 support for smu_v13_0_12 Asad Kamal
2025-11-06 13:25   ` Lazar, Lijo
2025-11-06 11:44 ` [PATCH v2 3/4] drm/amd/pm: Expose ppt1 limit for gc_v9_5_0 Asad Kamal
2025-11-06 13:28   ` Lazar, Lijo
2025-11-06 11:44 ` [PATCH v2 4/4] drm/amd/pm: Enable ppt1 caps for smu_v13_0_12 Asad Kamal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox