drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
Subsystems (3)
PATCH 1/1 drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver need to convert that into correct PMW(255) based.
--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15 ++++++++++++--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +12 -3
@@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)static int smu_v13_0_0_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ; +if (!speed)return -EINVAL ; -return smu_v13_0_0_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_0_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +12 -3
@@ -1365,12 +1365,21 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)static int smu_v13_0_7_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ; +if (!speed)return -EINVAL ; -return smu_v13_0_7_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_7_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
Signature · 1 line
2.34.1
Am 16.12.22 um 11:35 schrieb Evan Quan:
Quoted 15 lines
For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver need to convert that into correct PMW(255) based.
Signed-off-by Evan Quan <[email protected]>Change-Id I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15 ++++++++++++--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c static void smu_v13_0_0_get_unique_id(struct smu_context *smu) · line 1448
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1
-0@@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)static int smu_v13_0_0_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ;
Please don't initialize local variables when there isn't a need for this.
We often get complains about this from automated scripts.
Regards,
Christian.
Quoted 49 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +11
-3+if (!speed)return -EINVAL ; -return smu_v13_0_0_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_0_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +12
-3@@ -1365,12 +1365,21 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)static int smu_v13_0_7_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ; +if (!speed)return -EINVAL ; -return smu_v13_0_7_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_7_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
Alex Deucher
Acked-byWith Christian's comment addressed, the patch is:
Quoted 79 lines · Christian König
Am 16.12.22 um 11:35 schrieb Evan Quan:
Quoted 15 lines
For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver need to convert that into correct PMW(255) based.
Signed-off-by Evan Quan <[email protected]>Change-Id I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15 ++++++++++++--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c static void smu_v13_0_0_get_unique_id(struct smu_context *smu) · line 1448
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1
-0@@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)static int smu_v13_0_0_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ;Please don't initialize local variables when there isn't a need for this.
We often get complains about this from automated scripts.
Regards,
Christian.Quoted 49 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +11
-3+if (!speed)return -EINVAL ; -return smu_v13_0_0_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_0_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +12
-3@@ -1365,12 +1365,21 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)static int smu_v13_0_7_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ; +if (!speed)return -EINVAL ; -return smu_v13_0_7_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_7_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
[AMD Official Use Only - General]
Thanks Christian,
Yes, it is not such needed.
I checked this with checkpatch.pl script and no complains popped out about this. That is weird... Anyway, I will fix this up.
BR
Evan
Quoted 93 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, December 16, 2022 7:50 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asicsAm 16.12.22 um 11:35 schrieb Evan Quan:
Quoted 7 lines
For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver need to convert that into correct PMW(255) based.
Signed-off-by Evan Quan <[email protected]>Change-Id I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15++++++++++++---
Quoted 1 line
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15++++++++++++---
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c static void smu_v13_0_0_get_unique_id(struct
Quoted 8 lines
2 files changed, 24 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +0
-0@@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c static void smu_v13_0_0_get_unique_id(struct smu_context *smu) · line 1448
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1
-0static int smu_v13_0_0_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ;Please don't initialize local variables when there isn't a need for this.
We often get complains about this from automated scripts.
Regards,
Christian.Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1
-0+if (!speed)return -EINVAL ;drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c static void smu_v13_0_0_get_unique_id(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +7
-3-return smu_v13_0_0_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_0_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +3
-0+ *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0
-0@@ -1365,12 +1365,21 @@ static int
smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +2
-0static int smu_v13_0_7_get_fan_speed_pwm (struct smu_context *smu,uint32_t *speed) { +int ret =0 ; +if (!speed)return -EINVAL ;drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +7
-3-return smu_v13_0_7_get_smu_metrics_data (smu, -METRICS_CURR_FANPWM , - speed); + ret =smu_v13_0_7_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) +return ret; + +/* Convert the PMFW output which is in percent to pwm(255) based */
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +3
-0+ *speed =MIN (*speed *255 /100 ,255 ); + +return 0 ; } static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,