Skip to contentSkip to conversation

drm/amdgpu: added a sysfs interface for thermal throttling

PATCH In review kunliu13 3 participants 3 messages Feb 14, 2023

Subsystems (3)
lore
Share & tools
lore

kunliu13

author
#0 lore raw

PATCH 2/2 drm/amdgpu: added a sysfs interface for thermal throttling

implement apu_thermal_cap r/w callback for vangogh

Jira ID: SWDEV-354511

---
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +23 -0
index cb10c7e31..d211b1dfe 100644
@@ -1590,6 +1590,27 @@ static int vangogh_read_sensor(struct smu_context *smu,
 	return ret;
 }
 
+static int vangogh_get_apu_thermal_limit(struct smu_context *smu, uint32_t *limit)
+{
+	int ret = -EINVAL;
+
+	ret = smu_cmn_send_smc_msg_with_param(smu,
+					      SMU_MSG_GetThermalLimit,
+					      0, limit);
+	return ret;
+}
+
+int vangogh_set_apu_thermal_limit(struct smu_context *smu, uint32_t limit)
+{
+	int ret = -EINVAL;
+
+	ret = smu_cmn_send_smc_msg_with_param(smu,
+					      SMU_MSG_SetReducedThermalLimit,
+					      limit, NULL);
+	return ret;
+}
+
+
 static int vangogh_set_watermarks_table(struct smu_context *smu,
 				       struct pp_smu_wm_range_sets *clock_ranges)
 {
@@ -2425,6 +2446,8 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
 	.dpm_set_jpeg_enable = vangogh_dpm_set_jpeg_enable,
 	.is_dpm_running = vangogh_is_dpm_running,
 	.read_sensor = vangogh_read_sensor,
+	.get_apu_thermal_limit = vangogh_get_apu_thermal_limit,
+	.set_apu_thermal_limit = vangogh_set_apu_thermal_limit,
 	.get_enabled_mask = smu_cmn_get_enabled_mask,
 	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
 	.set_watermarks_table = vangogh_set_watermarks_table,
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Am 14.02.23 um 09:02 schrieb kunliu13:

Quoted 13 lines

implement apu_thermal_cap r/w callback for vangogh

Jira ID: SWDEV-354511

---
  .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 23 +++++++++++++++++++
  1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0 -0
index cb10c7e31..d211b1dfe 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_read_sensor(struct smu_context *smu, · line 1595

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3 -0
@@ -1590,6 +1590,27 @@ static int vangogh_read_sensor(struct smu_context *smu,
  	return ret;
  }
 
+static int vangogh_get_apu_thermal_limit(struct smu_context *smu, uint32_t *limit)
+{
+	int ret = -EINVAL;

Generally please don't initialize return values if it isn't necessary!

This is constantly reported by automated checkers as bad coding style since it prevent the compiler from properly warn if an uninitialized variable is used.

Regards,
Christian.

Quoted 30 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +20 -0
+
+	ret = smu_cmn_send_smc_msg_with_param(smu,
+					      SMU_MSG_GetThermalLimit,
+					      0, limit);
+	return ret;
+}
+
+int vangogh_set_apu_thermal_limit(struct smu_context *smu, uint32_t limit)
+{
+	int ret = -EINVAL;
+
+	ret = smu_cmn_send_smc_msg_with_param(smu,
+					      SMU_MSG_SetReducedThermalLimit,
+					      limit, NULL);
+	return ret;
+}
+
+
  static int vangogh_set_watermarks_table(struct smu_context *smu,
  				       struct pp_smu_wm_range_sets *clock_ranges)
  {
@@ -2425,6 +2446,8 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
  	.dpm_set_jpeg_enable = vangogh_dpm_set_jpeg_enable,
  	.is_dpm_running = vangogh_is_dpm_running,
  	.read_sensor = vangogh_read_sensor,
+	.get_apu_thermal_limit = vangogh_get_apu_thermal_limit,
+	.set_apu_thermal_limit = vangogh_set_apu_thermal_limit,
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
  	.set_watermarks_table = vangogh_set_watermarks_table,
#2 lore raw
In reply to kunliu13

[AMD Official Use Only - General]

Quoted 12 lines

-----Original Message-----
From: kunliu13 <[email protected]>
Sent: Tuesday, February 14, 2023 4:03 PM
To: Limonciello, Mario <[email protected]>; Liang, Richard qi <[email protected]>; Yuan, Perry <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Du, Xiaojian <[email protected]>; Quan, Evan <[email protected]>; Liu, Kun <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: added a sysfs interface for thermal throttling

Quoted 3 lines

implement apu_thermal_cap r/w callback for vangogh

Jira ID: SWDEV-354511

[Quan, Evan] Please drop this internal link.

Quoted 15 lines
---
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 23
+++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0 -0
index cb10c7e31..d211b1dfe 100644
@@ -1590,6 +1590,27 @@ static int vangogh_read_sensor(struct
 smu_context *smu,
 	return ret;
 }

drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_read_sensor(struct · line 1602

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +8 -0
 
+static int vangogh_get_apu_thermal_limit(struct smu_context *smu,
 uint32_t *limit)
+{
+	int ret = -EINVAL;
+
+	ret = smu_cmn_send_smc_msg_with_param(smu,
+					      SMU_MSG_GetThermalLimit,
+					      0, limit);
+	return ret;

[Quan, Evan] "ret" here and below in vangogh_set_apu_thermal_limit seem unnecessary. Other that those, the patch is reviewed-by: Evan Quan <[email protected]>

Evan

Quoted 31 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +8 -0
+}
+
+int vangogh_set_apu_thermal_limit(struct smu_context *smu, uint32_t
 limit)
+{
+	int ret = -EINVAL;
+
+	ret = smu_cmn_send_smc_msg_with_param(smu,
+

SMU_MSG_SetReducedThermalLimit,

drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5 -0
+					      limit, NULL);
+	return ret;
+}
+
+
 static int vangogh_set_watermarks_table(struct smu_context *smu,
 				       struct pp_smu_wm_range_sets

*clock_ranges)
{

drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +2 -0
@@ -2425,6 +2446,8 @@ static const struct pptable_funcs
 vangogh_ppt_funcs = {
 	.dpm_set_jpeg_enable = vangogh_dpm_set_jpeg_enable,
 	.is_dpm_running = vangogh_is_dpm_running,
 	.read_sensor = vangogh_read_sensor,
+	.get_apu_thermal_limit = vangogh_get_apu_thermal_limit,
+	.set_apu_thermal_limit = vangogh_set_apu_thermal_limit,
 	.get_enabled_mask = smu_cmn_get_enabled_mask,
 	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,

.set_watermarks_table = vangogh_set_watermarks_table,
--
2.25.1