Skip to contentSkip to conversation

drm/amd/pm: enhance the real response for smu message (v2)

PATCH In review Huang Rui 2 participants 4 messages Jan 11, 2021

Subsystems (3)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH v2 2/7 drm/amd/pm: enhance the real response for smu message (v2)

The user prefers to know the real response value from C2PMSG 90 register which is written by firmware not -EIO.

v2: return C2PMSG 90 value

---
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -5
index f8260769061c..59cf650efbd9 100644
@@ -92,7 +92,7 @@ static int smu_cmn_wait_for_response(struct smu_context *smu)
 	for (i = 0; i < timeout; i++) {
 		cur_value = RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90);
 		if ((cur_value & MP1_C2PMSG_90__CONTENT_MASK) != 0)
-			return cur_value == 0x1 ? 0 : -EIO;
+			return cur_value;
 
 		udelay(1);
 	}
@@ -101,7 +101,7 @@ static int smu_cmn_wait_for_response(struct smu_context *smu)
 	if (i == timeout)
 		return -ETIME;
 
-	return RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90) == 0x1 ? 0 : -EIO;
+	return RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90);
 }
 
 int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
@@ -123,7 +123,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 
 	mutex_lock(&smu->message_lock);
 	ret = smu_cmn_wait_for_response(smu);
-	if (ret) {
+	if (ret != 0x1) {
 		dev_err(adev->dev, "Msg issuing pre-check failed and "
 		       "SMU may be not in the right state!\n");
 		goto out;
@@ -136,9 +136,9 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 	smu_cmn_send_msg_without_waiting(smu, (uint16_t)index);
 
 	ret = smu_cmn_wait_for_response(smu);
-	if (ret) {
+	if (ret != 0x1) {
 		dev_err(adev->dev, "failed send message: %10s (%d) \tparam: 0x%08x response %#x\n",
-		       smu_get_message_name(smu, msg), index, param, ret);
+			smu_get_message_name(smu, msg), index, param, ret);
 		goto out;
 	}
 
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#1 lore raw

PATCH v2 7/7 drm/amd/pm: implement processor fine grain feature for vangogh (v2)

This patch is to implement the processor fine grain feature for vangogh. It's similar with gfx clock, the only difference is below:

echo "p core_id level value" > pp_od_clk_voltage

1. "p" - set the cclk (processor) frequency
2. "core_id" - 0/1/2/3, represents which cpu core you want to select
2. "level" - 0 or 1, "0" represents the min value, "1" represents the max value
3. "value" - the target value of cclk frequency, it should be limited in the safe range

v2: fix some missing changes as Evan's suggestion.

---
 .../gpu/drm/amd/include/kgd_pp_interface.h    |  1 +
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 ++
 drivers/gpu/drm/amd/pm/inc/smu_types.h        |  1 +
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 80 ++++++++++++++++++-
 5 files changed, 90 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
index 57b24c4c205b..a41875ac5dfb 100644
@@ -156,6 +156,7 @@ enum {
 enum PP_OD_DPM_TABLE_COMMAND {
 	PP_OD_EDIT_SCLK_VDDC_TABLE,
 	PP_OD_EDIT_MCLK_VDDC_TABLE,
+	PP_OD_EDIT_CCLK_VDDC_TABLE,
 	PP_OD_EDIT_VDDC_CURVE,
 	PP_OD_RESTORE_DEFAULT_TABLE,
 	PP_OD_COMMIT_DPM_TABLE,
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -0
index a5be03aa384b..75cefcb25a44 100644
@@ -800,6 +800,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
 
 	if (*buf == 's')
 		type = PP_OD_EDIT_SCLK_VDDC_TABLE;
+	else if (*buf == 'p')
+		type = PP_OD_EDIT_CCLK_VDDC_TABLE;
 	else if (*buf == 'm')
 		type = PP_OD_EDIT_MCLK_VDDC_TABLE;
 	else if(*buf == 'r')
@@ -916,6 +918,7 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
 		size += smu_print_clk_levels(&adev->smu, SMU_OD_VDDC_CURVE, buf+size);
 		size += smu_print_clk_levels(&adev->smu, SMU_OD_VDDGFX_OFFSET, buf+size);
 		size += smu_print_clk_levels(&adev->smu, SMU_OD_RANGE, buf+size);
+		size += smu_print_clk_levels(&adev->smu, SMU_OD_CCLK, buf+size);
 	} else if (adev->powerplay.pp_funcs->print_clock_levels) {
 		size = amdgpu_dpm_print_clock_levels(adev, OD_SCLK, buf);
 		size += amdgpu_dpm_print_clock_levels(adev, OD_MCLK, buf+size);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +6 -0
index 97d788451624..25ee9f51813b 100644
@@ -465,6 +465,12 @@ struct smu_context
 	uint32_t gfx_default_soft_max_freq;
 	uint32_t gfx_actual_hard_min_freq;
 	uint32_t gfx_actual_soft_max_freq;
+
+	uint32_t cpu_default_soft_min_freq;
+	uint32_t cpu_default_soft_max_freq;
+	uint32_t cpu_actual_soft_min_freq;
+	uint32_t cpu_actual_soft_max_freq;
+	uint32_t cpu_core_id_select;
 };
 
 struct i2c_adapter;
drivers/gpu/drm/amd/pm/inc/smu_types.h +1 -0
index 8e428c728e0e..b76270e8767c 100644
@@ -237,6 +237,7 @@ enum smu_clk_type {
 	SMU_SCLK,
 	SMU_MCLK,
 	SMU_PCIE,
+	SMU_OD_CCLK,
 	SMU_OD_SCLK,
 	SMU_OD_MCLK,
 	SMU_OD_VDDC_CURVE,
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +79 -1

127 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v2 7/7
#2 lore raw

RE: [PATCH v2 7/7] drm/amd/pm: implement processor fine grain feature for vangogh (v2)

[AMD Official Use Only - Internal Distribution Only]

-----Original Message-----
From: Huang, Ray <[email protected]>
Sent: Monday, January 11, 2021 12:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liu, Aaron <[email protected]>; Du, Xiaojian <[email protected]>; Hou, Xiaomeng (Matthew) <[email protected]>; Quan, Evan <[email protected]>; Huang, Ray <[email protected]>
Subject: [PATCH v2 7/7] drm/amd/pm: implement processor fine grain feature for vangogh (v2)

This patch is to implement the processor fine grain feature for vangogh. It's similar with gfx clock, the only difference is below:

echo "p core_id level value" > pp_od_clk_voltage

1. "p" - set the cclk (processor) frequency 2. "core_id" - 0/1/2/3, represents which cpu core you want to select 2. "level" - 0 or 1, "0" represents the min value, "1" represents the max value
3. "value" - the target value of cclk frequency, it should be limited in
the safe range

v2: fix some missing changes as Evan's suggestion.

---
 .../gpu/drm/amd/include/kgd_pp_interface.h    |  1 +
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  3 +
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 ++
 drivers/gpu/drm/amd/pm/inc/smu_types.h        |  1 +
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 80 ++++++++++++++++++-
 5 files changed, 90 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
index 57b24c4c205b..a41875ac5dfb 100644
@@ -156,6 +156,7 @@ enum {
 enum PP_OD_DPM_TABLE_COMMAND {
 PP_OD_EDIT_SCLK_VDDC_TABLE,
 PP_OD_EDIT_MCLK_VDDC_TABLE,
+PP_OD_EDIT_CCLK_VDDC_TABLE,
 PP_OD_EDIT_VDDC_CURVE,
 PP_OD_RESTORE_DEFAULT_TABLE,
 PP_OD_COMMIT_DPM_TABLE,
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -0
index a5be03aa384b..75cefcb25a44 100644
@@ -800,6 +800,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
 
 if (*buf == 's')
 type = PP_OD_EDIT_SCLK_VDDC_TABLE;
+else if (*buf == 'p')
+type = PP_OD_EDIT_CCLK_VDDC_TABLE;
 else if (*buf == 'm')
 type = PP_OD_EDIT_MCLK_VDDC_TABLE;
 else if(*buf == 'r')
@@ -916,6 +918,7 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
 size += smu_print_clk_levels(&adev->smu, SMU_OD_VDDC_CURVE, buf+size);
 size += smu_print_clk_levels(&adev->smu, SMU_OD_VDDGFX_OFFSET, buf+size);
 size += smu_print_clk_levels(&adev->smu, SMU_OD_RANGE, buf+size);
+size += smu_print_clk_levels(&adev->smu, SMU_OD_CCLK, buf+size);
 } else if (adev->powerplay.pp_funcs->print_clock_levels) {
 size = amdgpu_dpm_print_clock_levels(adev, OD_SCLK, buf);
 size += amdgpu_dpm_print_clock_levels(adev, OD_MCLK, buf+size); diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h

index 97d788451624..25ee9f51813b 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +6 -0
@@ -465,6 +465,12 @@ struct smu_context
 uint32_t gfx_default_soft_max_freq;
 uint32_t gfx_actual_hard_min_freq;
 uint32_t gfx_actual_soft_max_freq;
+
+uint32_t cpu_default_soft_min_freq;
+uint32_t cpu_default_soft_max_freq;
+uint32_t cpu_actual_soft_min_freq;
+uint32_t cpu_actual_soft_max_freq;
+uint32_t cpu_core_id_select;
 };
 
 struct i2c_adapter;
drivers/gpu/drm/amd/pm/inc/smu_types.h +1 -0
index 8e428c728e0e..b76270e8767c 100644
@@ -237,6 +237,7 @@ enum smu_clk_type {
 SMU_SCLK,
 SMU_MCLK,
 SMU_PCIE,
+SMU_OD_CCLK,
 SMU_OD_SCLK,
 SMU_OD_MCLK,
 SMU_OD_VDDC_CURVE,
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +40 -1

63 lines not on this page · raw message

} else {
smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq; smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
+smu->cpu_actual_soft_min_freq = smu->cpu_default_soft_min_freq; +smu->cpu_actual_soft_max_freq = smu->cpu_default_soft_max_freq;

ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk,
smu->gfx_actual_hard_min_freq, NULL); @@ -1300,6 +1341,20 @@ static int vangogh_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TAB dev_err(smu->adev->dev, "Restore the default soft max sclk failed!");
return ret;
}
+
+ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMinCclk,
+ smu->cpu_actual_soft_min_freq, NULL);
+if (ret) {
+dev_err(smu->adev->dev, "Set hard min cclk failed!");
+return ret;
+}
+
+ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxCclk,
+ smu->cpu_actual_soft_max_freq, NULL);
+if (ret) {
+dev_err(smu->adev->dev, "Set soft max cclk failed!");
+return ret;
+}
}
break;
case PP_OD_COMMIT_DPM_TABLE:
@@ -1326,6 +1381,24 @@ static int vangogh_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TAB
dev_err(smu->adev->dev, "Set soft max sclk failed!");
return ret;
}
+
+ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMinCclk,
+ ((smu->cpu_core_id_select << 20)
+ | smu->cpu_actual_soft_min_freq),
+ NULL);
+if (ret) {
+dev_err(smu->adev->dev, "Set hard min cclk failed!");
+return ret;
+}
+
+ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxCclk,
+ ((smu->cpu_core_id_select << 20)
+ | smu->cpu_actual_soft_max_freq),
+ NULL);
+if (ret) {
+dev_err(smu->adev->dev, "Set soft max cclk failed!");
+return ret;
+}
}
break;
default:
@@ -1351,6 +1424,11 @@ static int vangogh_set_fine_grain_gfx_freq_parameters(struct smu_context *smu)
smu->gfx_actual_hard_min_freq = 0;
smu->gfx_actual_soft_max_freq = 0;

+smu->cpu_default_soft_min_freq = 1400;
+smu->cpu_default_soft_max_freq = 3500;
+smu->cpu_actual_soft_min_freq = 0;
+smu->cpu_actual_soft_max_freq = 0;
+
return 0;
}

--
2.25.1

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

Reviewed-by on v2 2/7
#3 lore raw
In reply to Huang Rui

[AMD Official Use Only - Internal Distribution Only]

-----Original Message-----
From: Huang, Ray <[email protected]>
Sent: Monday, January 11, 2021 12:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liu, Aaron <[email protected]>; Du, Xiaojian <[email protected]>; Hou, Xiaomeng (Matthew) <[email protected]>; Quan, Evan <[email protected]>; Huang, Ray <[email protected]>
Subject: [PATCH v2 2/7] drm/amd/pm: enhance the real response for smu message (v2)

The user prefers to know the real response value from C2PMSG 90 register which is written by firmware not -EIO.

v2: return C2PMSG 90 value

---
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -5
index f8260769061c..59cf650efbd9 100644
@@ -92,7 +92,7 @@ static int smu_cmn_wait_for_response(struct smu_context *smu)
 for (i = 0; i < timeout; i++) {
 cur_value = RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90);
 if ((cur_value & MP1_C2PMSG_90__CONTENT_MASK) != 0)
-return cur_value == 0x1 ? 0 : -EIO;
+return cur_value;
 
 udelay(1);
 }
@@ -101,7 +101,7 @@ static int smu_cmn_wait_for_response(struct smu_context *smu)
 if (i == timeout)
 return -ETIME;
 
-return RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90) == 0x1 ? 0 : -EIO;
+return RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90);
 }
 
 int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
@@ -123,7 +123,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 
 mutex_lock(&smu->message_lock);
 ret = smu_cmn_wait_for_response(smu);
-if (ret) {
+if (ret != 0x1) {
 dev_err(adev->dev, "Msg issuing pre-check failed and "
        "SMU may be not in the right state!\n");
 goto out;
@@ -136,9 +136,9 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 smu_cmn_send_msg_without_waiting(smu, (uint16_t)index);
 
 ret = smu_cmn_wait_for_response(smu);
-if (ret) {
+if (ret != 0x1) {
 dev_err(adev->dev, "failed send message: %10s (%d) \tparam: 0x%08x response %#x\n",
-       smu_get_message_name(smu, msg), index, param, ret);
+smu_get_message_name(smu, msg), index, param, ret);
 goto out;
 }
 

--
2.25.1

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