Skip to contentSkip to conversation

drm/amd/powerplay: Add the interface for geting dpm current power state

PATCH In review Liang, Prike 3 participants 3 messages Sep 9, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/powerplay: Add the interface for geting dpm current power state

implement the sysfs power_dpm_state

---
 drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 34 ++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +34 -0
index a5cf846..2c22ba4 100644
@@ -246,6 +246,38 @@ static int renoir_print_clk_levels(struct smu_context *smu,
 	return size;
 }
 
+static enum amd_pm_state_type renoir_get_current_power_state(struct smu_context *smu)
+{
+	enum amd_pm_state_type pm_type;
+	struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
+
+	if (!smu_dpm_ctx->dpm_context ||
+	    !smu_dpm_ctx->dpm_current_power_state)
+		return -EINVAL;
+
+	mutex_lock(&(smu->mutex));
+	switch (smu_dpm_ctx->dpm_current_power_state->classification.ui_label) {
+	case SMU_STATE_UI_LABEL_BATTERY:
+		pm_type = POWER_STATE_TYPE_BATTERY;
+		break;
+	case SMU_STATE_UI_LABEL_BALLANCED:
+		pm_type = POWER_STATE_TYPE_BALANCED;
+		break;
+	case SMU_STATE_UI_LABEL_PERFORMANCE:
+		pm_type = POWER_STATE_TYPE_PERFORMANCE;
+		break;
+	default:
+		if (smu_dpm_ctx->dpm_current_power_state->classification.flags & SMU_STATE_CLASSIFICATION_FLAG_BOOT)
+			pm_type = POWER_STATE_TYPE_INTERNAL_BOOT;
+		else
+			pm_type = POWER_STATE_TYPE_DEFAULT;
+		break;
+	}
+	mutex_unlock(&(smu->mutex));
+
+	return pm_type;
+}
+
 static const struct pptable_funcs renoir_ppt_funcs = {
 	.get_smu_msg_index = renoir_get_smu_msg_index,
 	.get_smu_table_index = renoir_get_smu_table_index,
@@ -253,6 +285,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
 	.set_power_state = NULL,
 	.get_dpm_uclk_limited = renoir_get_dpm_uclk_limited,
 	.print_clk_levels = renoir_print_clk_levels,
+	.get_current_power_state = renoir_get_current_power_state,
+
 };
 
 void renoir_set_ppt_funcs(struct smu_context *smu)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1568006521-7471-1-git-send-email-Prike.Liang-5C7GfCeVMHo@public.gmane.org

Reviewed-by Evan Quan
#2 lore raw
Quoted 75 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: 2019年9月9日 13:22
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH] drm/amd/powerplay: Add the interface for geting dpm current power state

implement the sysfs power_dpm_state

---
 drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 34
++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +32 -0
index a5cf846..2c22ba4 100644
@@ -246,6 +246,38 @@ static int renoir_print_clk_levels(struct smu_context
 *smu,
 	return size;
 }
 
+static enum amd_pm_state_type renoir_get_current_power_state(struct
+smu_context *smu) {
+	enum amd_pm_state_type pm_type;
+	struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
+
+	if (!smu_dpm_ctx->dpm_context ||
+	    !smu_dpm_ctx->dpm_current_power_state)
+		return -EINVAL;
+
+	mutex_lock(&(smu->mutex));
+	switch (smu_dpm_ctx->dpm_current_power_state-
 >classification.ui_label) {
+	case SMU_STATE_UI_LABEL_BATTERY:
+		pm_type = POWER_STATE_TYPE_BATTERY;
+		break;
+	case SMU_STATE_UI_LABEL_BALLANCED:
+		pm_type = POWER_STATE_TYPE_BALANCED;
+		break;
+	case SMU_STATE_UI_LABEL_PERFORMANCE:
+		pm_type = POWER_STATE_TYPE_PERFORMANCE;
+		break;
+	default:
+		if (smu_dpm_ctx->dpm_current_power_state-
 >classification.flags & SMU_STATE_CLASSIFICATION_FLAG_BOOT)
+			pm_type = POWER_STATE_TYPE_INTERNAL_BOOT;
+		else
+			pm_type = POWER_STATE_TYPE_DEFAULT;
+		break;
+	}
+	mutex_unlock(&(smu->mutex));
+
+	return pm_type;
+}
+

static const struct pptable_funcs renoir_ppt_funcs = {

drivers/gpu/drm/amd/powerplay/renoir_ppt.c +3 -1
 	.get_smu_msg_index = renoir_get_smu_msg_index,
 	.get_smu_table_index = renoir_get_smu_table_index, @@ -253,6
+285,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
 	.set_power_state = NULL,
 	.get_dpm_uclk_limited = renoir_get_dpm_uclk_limited,
 	.print_clk_levels = renoir_print_clk_levels,
+	.get_current_power_state = renoir_get_current_power_state,
+
 };
 
 void renoir_set_ppt_funcs(struct smu_context *smu)
--
Quoted 1 line

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3344C78FF82CFB5166571091E4B70-rweVpJHSKToDMgCC8P//[email protected]

Reviewed-by Evan Quan Reviewed-by
#4 lore raw

comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Quan, Evan <[email protected]>
Sent: Monday, September 9, 2019 4:31 PM
To: Liang, Prike <[email protected]>; [email protected] <[email protected]>
Cc: Huang, Ray <[email protected]>; Feng, Kenneth <[email protected]>; Liu, Aaron <[email protected]>
Subject: RE: [PATCH] drm/amd/powerplay: Add the interface for geting dpm current power state

Quoted 69 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: 2019年9月9日 13:22
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH] drm/amd/powerplay: Add the interface for geting dpm
current power state

implement the sysfs power_dpm_state

---
 drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 34
++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +32 -0
index a5cf846..2c22ba4 100644
@@ -246,6 +246,38 @@ static int renoir_print_clk_levels(struct smu_context
 *smu,
       return size;
 }
 
+static enum amd_pm_state_type renoir_get_current_power_state(struct
+smu_context *smu) {
+     enum amd_pm_state_type pm_type;
+     struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
+
+     if (!smu_dpm_ctx->dpm_context ||
+         !smu_dpm_ctx->dpm_current_power_state)
+             return -EINVAL;
+
+     mutex_lock(&(smu->mutex));
+     switch (smu_dpm_ctx->dpm_current_power_state-
 >classification.ui_label) {
+     case SMU_STATE_UI_LABEL_BATTERY:
+             pm_type = POWER_STATE_TYPE_BATTERY;
+             break;
+     case SMU_STATE_UI_LABEL_BALLANCED:
+             pm_type = POWER_STATE_TYPE_BALANCED;
+             break;
+     case SMU_STATE_UI_LABEL_PERFORMANCE:
+             pm_type = POWER_STATE_TYPE_PERFORMANCE;
+             break;
+     default:
+             if (smu_dpm_ctx->dpm_current_power_state-
 >classification.flags & SMU_STATE_CLASSIFICATION_FLAG_BOOT)
+                     pm_type = POWER_STATE_TYPE_INTERNAL_BOOT;
+             else
+                     pm_type = POWER_STATE_TYPE_DEFAULT;
+             break;
+     }
+     mutex_unlock(&(smu->mutex));
+
+     return pm_type;
+}
+

static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index, @@ -253,6
+285,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.set_power_state = NULL,
.get_dpm_uclk_limited = renoir_get_dpm_uclk_limited, .print_clk_levels = renoir_print_clk_levels,

drivers/gpu/drm/amd/powerplay/renoir_ppt.c static const struct pptable_funcs renoir_ppt_funcs = { · line 289

Quoted 2 lines
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +2 -0
+     .get_current_power_state = renoir_get_current_power_state,
+

[kevin]:
please remove this blank line.
after fixed:

Quoted 5 lines

};

void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx