Skip to contentSkip to conversation

drm/amd/pm: add the fine grain tuning function for vangogh

PATCH In review Xiaojian Du 2 participants 3 messages Nov 15, 2020 – Nov 16, 2020

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

PATCH 1/2 drm/amd/pm: add the fine grain tuning function for vangogh

This patch is to add the fine grain tuning function for vangogh. This function uses the pp_od_clk_voltage sysfs file to configure the min and max value of gfx clock frequency or restore the default value.

Command guide:
echo "s level value" > pp_od_clk_voltage
"s" - set the sclk frequency
"level" - 0 or 1, "0" represents the min value, "1" represents the max value
"value" - the target value of sclk frequency, it should be limited in the
safe range.
echo "r" > pp_od_clk_voltage
"r" - reset the sclk frequency, restore the default value
echo "c" > pp_od_clk_voltage
"c" - commit the min and max value of sclk frequency to the system. only after the commit command, the target values will take effect.
Example:
1)check the default sclk frequency

	$ cat pp_od_clk_voltage
	OD_SCLK:
	0:        200Mhz
	1:       1400Mhz
	OD_RANGE:
	SCLK:     200MHz       1400MHz
2)use "s" -- set command to configure the min or max sclk frequency
	$ echo "s 0 600" > pp_od_clk_voltage
	$ echo "s 1 1000" > pp_od_clk_voltage
	$ echo "c" > pp_od_clk_voltage
        $ cat pp_od_clk_voltage
	OD_SCLK:
	0:        600Mhz
	1:       1000Mhz
	OD_RANGE:
	SCLK:     200MHz       1400MHz
3)use "r" -- reset command to restore the min and max sclk frequency
	$ echo "r" > pp_od_clk_voltage
	& echo "c" > pp_od_clk_voltage
        $ cat pp_od_clk_voltage
	OD_SCLK:
	0:        200Mhz
	1:       1400Mhz
	OD_RANGE:
	SCLK:     200MHz       1400MHz
---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |   6 +
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    |   2 +
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 135 ++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |   1 +
 4 files changed, 144 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +6 -0
index ae8ff7b07932..7550757cc059 100644
@@ -459,6 +459,11 @@ struct smu_context
 
 	unsigned fan_max_rpm;
 	unsigned manual_fan_speed_rpm;
+
+	uint32_t gfx_default_hard_min_freq;
+	uint32_t gfx_default_soft_max_freq;
+	uint32_t gfx_actual_hard_min_freq;
+	uint32_t gfx_actual_soft_max_freq;
 };
 
 struct i2c_adapter;
@@ -577,6 +582,7 @@ struct pptable_funcs {
 	void (*interrupt_work)(struct smu_context *smu);
 	int (*gpo_control)(struct smu_context *smu, bool enablement);
 	int (*gfx_state_change_set)(struct smu_context *smu, uint32_t state);
+	int (*set_fine_grain_gfx_freq_parameters)(struct smu_context *smu);
 };
 
 typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +2 -0
index b880c72c322c..b23311096467 100644
@@ -438,11 +438,13 @@ int smu_v11_0_fini_smc_tables(struct smu_context *smu)
 	kfree(smu_table->overdrive_table);
 	kfree(smu_table->max_sustainable_clocks);
 	kfree(smu_table->driver_pptable);
+	kfree(smu_table->clocks_table);
 	smu_table->gpu_metrics_table = NULL;
 	smu_table->boot_overdrive_table = NULL;
 	smu_table->overdrive_table = NULL;
 	smu_table->max_sustainable_clocks = NULL;
 	smu_table->driver_pptable = NULL;
+	smu_table->clocks_table = NULL;
 	kfree(smu_table->hardcode_pptable);
 	smu_table->hardcode_pptable = NULL;
 
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +135 -0

161 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
index f7be2d1a0ff2..68d9464ababc 100644
@@ -90,6 +90,7 @@
 #define smu_get_fan_parameters(smu)					smu_ppt_funcs(get_fan_parameters, 0, smu)
 #define smu_post_init(smu)						smu_ppt_funcs(post_init, 0, smu)
 #define smu_gpo_control(smu, enablement)				smu_ppt_funcs(gpo_control, 0, smu, enablement)
+#define smu_set_fine_grain_gfx_freq_parameters(smu)					smu_ppt_funcs(set_fine_grain_gfx_freq_parameters, 0, smu)
 
 #endif
 #endif
Signature · 6 lines
2.17.1

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

PATCH 2/2 drm/amd/pm: enable the fine grain tuning function for vangogh

This patch is to enale the fine grain tuning function for vangogh.

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4 -0
index 7b698c5ddad0..1904df5a3e20 100644
@@ -405,6 +405,8 @@ static int smu_set_funcs(struct amdgpu_device *adev)
 		break;
 	case CHIP_VANGOGH:
 		vangogh_set_ppt_funcs(smu);
+		/* enable the OD by default to allow the fine grain tuning function */
+		smu->od_enabled = true;
 		break;
 	default:
 		return -EINVAL;
@@ -474,6 +476,8 @@ static int smu_late_init(void *handle)
 	struct smu_context *smu = &adev->smu;
 	int ret = 0;
 
+	smu_set_fine_grain_gfx_freq_parameters(smu);
+
 	if (adev->asic_type == CHIP_VANGOGH)
 		return 0;
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw
In reply to Xiaojian Du

[AMD Official Use Only - Internal Distribution Only]

To be consistent with other ASICs, "echo r" is enough to restore to the default values. No need to followed by a "echo c".
With that fixed, the series is reviewed-by: Evan Quan <[email protected]>

-----Original Message-----
From: Du, Xiaojian <[email protected]>
Sent: Sunday, November 15, 2020 10:45 PM
To: [email protected]
Cc: Huang, Ray <[email protected]>; Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Kevin(Yang) <[email protected]>; Huang, Shimmer <[email protected]>; Liang, Prike <[email protected]>; Zhu, Changfeng <[email protected]>; Du, Xiaojian <[email protected]>
Subject: [PATCH 1/2] drm/amd/pm: add the fine grain tuning function for vangogh

This patch is to add the fine grain tuning function for vangogh. This function uses the pp_od_clk_voltage sysfs file to configure the min and max value of gfx clock frequency or restore the default value.

Command guide:
echo "s level value" > pp_od_clk_voltage
"s" - set the sclk frequency
"level" - 0 or 1, "0" represents the min value, "1" represents the max value
"value" - the target value of sclk frequency, it should be limited in the
safe range.
echo "r" > pp_od_clk_voltage
"r" - reset the sclk frequency, restore the default value
echo "c" > pp_od_clk_voltage
"c" - commit the min and max value of sclk frequency to the system. only after the commit command, the target values will take effect.
Example:
1)check the default sclk frequency

$ cat pp_od_clk_voltage
OD_SCLK:
0:        200Mhz
1:       1400Mhz
OD_RANGE:
SCLK:     200MHz       1400MHz
2)use "s" -- set command to configure the min or max sclk frequency
$ echo "s 0 600" > pp_od_clk_voltage
$ echo "s 1 1000" > pp_od_clk_voltage
$ echo "c" > pp_od_clk_voltage
        $ cat pp_od_clk_voltage
OD_SCLK:
0:        600Mhz
1:       1000Mhz
OD_RANGE:
SCLK:     200MHz       1400MHz
3)use "r" -- reset command to restore the min and max sclk frequency
$ echo "r" > pp_od_clk_voltage
& echo "c" > pp_od_clk_voltage
        $ cat pp_od_clk_voltage
OD_SCLK:
0:        200Mhz
1:       1400Mhz
OD_RANGE:
SCLK:     200MHz       1400MHz
---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |   6 +
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    |   2 +
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 135 ++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |   1 +
 4 files changed, 144 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +6 -0
index ae8ff7b07932..7550757cc059 100644
@@ -459,6 +459,11 @@ struct smu_context
 
 unsigned fan_max_rpm;
 unsigned manual_fan_speed_rpm;
+
+uint32_t gfx_default_hard_min_freq;
+uint32_t gfx_default_soft_max_freq;
+uint32_t gfx_actual_hard_min_freq;
+uint32_t gfx_actual_soft_max_freq;
 };
 
 struct i2c_adapter;
@@ -577,6 +582,7 @@ struct pptable_funcs {
 void (*interrupt_work)(struct smu_context *smu);
 int (*gpo_control)(struct smu_context *smu, bool enablement);
 int (*gfx_state_change_set)(struct smu_context *smu, uint32_t state);
+int (*set_fine_grain_gfx_freq_parameters)(struct smu_context *smu);
 };
 
 typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +2 -0
index b880c72c322c..b23311096467 100644
@@ -438,11 +438,13 @@ int smu_v11_0_fini_smc_tables(struct smu_context *smu)
 kfree(smu_table->overdrive_table);
 kfree(smu_table->max_sustainable_clocks);
 kfree(smu_table->driver_pptable);
+kfree(smu_table->clocks_table);
 smu_table->gpu_metrics_table = NULL;
 smu_table->boot_overdrive_table = NULL;
 smu_table->overdrive_table = NULL;
 smu_table->max_sustainable_clocks = NULL;
 smu_table->driver_pptable = NULL;
+smu_table->clocks_table = NULL;
 kfree(smu_table->hardcode_pptable);
 smu_table->hardcode_pptable = NULL;
 
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +135 -0

161 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
index f7be2d1a0ff2..68d9464ababc 100644
@@ -90,6 +90,7 @@
 #define smu_get_fan_parameters(smu)smu_ppt_funcs(get_fan_parameters, 0, smu)
 #define smu_post_init(smu)smu_ppt_funcs(post_init, 0, smu)
 #define smu_gpo_control(smu, enablement)smu_ppt_funcs(gpo_control, 0, smu, enablement)
+#define smu_set_fine_grain_gfx_freq_parameters(smu)smu_ppt_funcs(set_fine_grain_gfx_freq_parameters, 0, smu)
 
 #endif
 #endif

--
2.17.1

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