All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/pm: enable power limit retrieving and setting for SMU 13.0.0
@ 2022-05-03 20:08 Alex Deucher
  2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable ac/dc switching " Alex Deucher
                   ` (23 more replies)
  0 siblings, 24 replies; 26+ messages in thread
From: Alex Deucher @ 2022-05-03 20:08 UTC (permalink / raw)
  To: amd-gfx; +Cc: Lijo Lazar, Alex Deucher, Evan Quan, Hawking Zhang

From: Evan Quan <evan.quan@amd.com>

Fulfill the interfaces for retrieving and setting power limit on
SMU 13.0.0.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
index e4bc8d85b151..f4184ea90e86 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
@@ -114,6 +114,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] =
 	MSG_MAP(AllowGfxOff,			PPSMC_MSG_AllowGfxOff,                 0),
 	MSG_MAP(DisallowGfxOff,			PPSMC_MSG_DisallowGfxOff,              0),
 	MSG_MAP(SetMGpuFanBoostLimitRpm,	PPSMC_MSG_SetMGpuFanBoostLimitRpm,     0),
+	MSG_MAP(GetPptLimit,			PPSMC_MSG_GetPptLimit,                 0),
 };
 
 static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = {
@@ -138,6 +139,7 @@ static struct cmn2asic_mapping smu_v13_0_0_feature_mask_map[SMU_FEATURE_COUNT] =
 	[SMU_FEATURE_DPM_VCLK_BIT] = {1, FEATURE_MM_DPM_BIT},
 	[SMU_FEATURE_DPM_DCLK_BIT] = {1, FEATURE_MM_DPM_BIT},
 	[SMU_FEATURE_FAN_CONTROL_BIT] = {1, FEATURE_FAN_CONTROL_BIT},
+	[SMU_FEATURE_PPT_BIT] = {1, FEATURE_THROTTLERS_BIT},
 };
 
 static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = {
@@ -1305,6 +1307,44 @@ static int smu_v13_0_0_enable_mgpu_fan_boost(struct smu_context *smu)
 					       NULL);
 }
 
+static int smu_v13_0_0_get_power_limit(struct smu_context *smu,
+				       uint32_t *current_power_limit,
+				       uint32_t *default_power_limit,
+				       uint32_t *max_power_limit)
+{
+	struct smu_table_context *table_context = &smu->smu_table;
+	struct smu_13_0_0_powerplay_table *powerplay_table =
+		(struct smu_13_0_0_powerplay_table *)table_context->power_play_table;
+	PPTable_t *pptable = table_context->driver_pptable;
+	SkuTable_t *skutable = &pptable->SkuTable;
+	uint32_t power_limit, od_percent;
+
+	if (smu_v13_0_get_current_power_limit(smu, &power_limit))
+		power_limit = smu->adev->pm.ac_power ?
+			      skutable->SocketPowerLimitAc[PPT_THROTTLER_PPT0] :
+			      skutable->SocketPowerLimitDc[PPT_THROTTLER_PPT0];
+
+	if (current_power_limit)
+		*current_power_limit = power_limit;
+	if (default_power_limit)
+		*default_power_limit = power_limit;
+
+	if (max_power_limit) {
+		if (smu->od_enabled) {
+			od_percent = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_13_0_0_ODSETTING_POWERPERCENTAGE]);
+
+			dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_percent, power_limit);
+
+			power_limit *= (100 + od_percent);
+			power_limit /= 100;
+		}
+		*max_power_limit = power_limit;
+	}
+
+	return 0;
+}
+
+
 static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
 	.get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask,
 	.set_default_dpm_table = smu_v13_0_0_set_default_dpm_table,
@@ -1351,6 +1391,8 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = {
 	.get_fan_control_mode = smu_v13_0_get_fan_control_mode,
 	.set_fan_control_mode = smu_v13_0_set_fan_control_mode,
 	.enable_mgpu_fan_boost = smu_v13_0_0_enable_mgpu_fan_boost,
+	.get_power_limit = smu_v13_0_0_get_power_limit,
+	.set_power_limit = smu_v13_0_set_power_limit,
 };
 
 void smu_v13_0_0_set_ppt_funcs(struct smu_context *smu)
-- 
2.35.1


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

end of thread, other threads:[~2022-05-04  6:25 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03 20:08 [PATCH] drm/amd/pm: enable power limit retrieving and setting for SMU 13.0.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable ac/dc switching " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable power profile setting " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable RunDcBtc support " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable ppfeature mask setting " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable PMLOG support " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable df cstate feature " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu: enable more GFX clockgating features for GC 11.0.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: support more DPM features for SMU 13.0.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable deep sleep features control " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable gfx ulv feature " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amd/pm: enable more dpm features to pair with PMFW 78.31.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu: enable MGCG and LS for ATHUB 3.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu: enable MGCG and LS for MMHUB 3.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu: enable clock gating for IH 6.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu: enable clock gating for HDP 6.0 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/gmc11: avoid cpu accessing registers to flush VM Alex Deucher
2022-05-04  6:25   ` Christian König
2022-05-03 20:08 ` [PATCH] drm/amdgpu: add soc21 support for GC 11.0.2 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/discovery: " Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu: add support for ATHUB 3.0.2 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/discovery: add ih6 support for IH 6.0.2 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/discovery: add smu13 support for MP1 13.0.7 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/discovery: add nbio 4.3 support for NBIO 4.3.1 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/discovery: add hdp6 support for HDP 6.0.1 Alex Deucher
2022-05-03 20:08 ` [PATCH] drm/amdgpu/discovery: add SMUIO_13_0_8 func support Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.