drm/amdgpu/pm: wire up hwmon fan speed for smu 14.0.2
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/pm: wire up hwmon fan speed for smu 14.0.2
Add callbacks for fan speed fetching.
Signed-off-by Alex Deucher <[email protected]>
--- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +35 -0
@@ -1627,6 +1627,39 @@ static void smu_v14_0_2_get_unique_id(struct smu_context *smu) adev->unique_id = ((uint64_t )upper32 <<32 ) | lower32; } +static int smu_v14_0_2_get_fan_speed_pwm (struct smu_context *smu, +uint32_t *speed) +{ +int ret; + +if (!speed) +return -EINVAL ; + + ret =smu_v14_0_2_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) { +dev_err (smu->adev->dev,"Failed to get fan speed(PWM)!" ); +return ret; + } + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =min (*speed *255 /100 , (uint32_t )255 ); + +return 0 ; +} + +static int smu_v14_0_2_get_fan_speed_rpm (struct smu_context *smu, +uint32_t *speed) +{ +if (!speed) +return -EINVAL ; + +return smu_v14_0_2_get_smu_metrics_data (smu, +METRICS_CURR_FANSPEED , + speed); +} + static int smu_v14_0_2_get_power_limit(struct smu_context *smu, uint32_t *current_power_limit, uint32_t *default_power_limit,
@@ -2804,6 +2837,8 @@ static const struct pptable_funcs smu_v14_0_2_ppt_funcs = { .set_performance_level = smu_v14_0_set_performance_level, .gfx_off_control = smu_v14_0_gfx_off_control, .get_unique_id = smu_v14_0_2_get_unique_id, + .get_fan_speed_pwm = smu_v14_0_2_get_fan_speed_pwm, + .get_fan_speed_rpm = smu_v14_0_2_get_fan_speed_rpm, .get_power_limit = smu_v14_0_2_get_power_limit, .set_power_limit = smu_v14_0_2_set_power_limit, .get_power_profile_mode = smu_v14_0_2_get_power_profile_mode,
Signature · 1 line
2.48.1
[AMD Official Use Only - AMD Internal Distribution Only]
Reviewed-by Kenneth Feng [email protected]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, March 11, 2025 10:39 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu/pm: wire up hwmon fan speed for smu 14.0.2
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Add callbacks for fan speed fetching.
Signed-off-by Alex Deucher <[email protected]>
--- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +30 -0
@@ -1627,6 +1627,39 @@ static void smu_v14_0_2_get_unique_id(struct smu_context *smu) adev->unique_id = ((uint64_t )upper32 <<32 ) | lower32; } +static int smu_v14_0_2_get_fan_speed_pwm (struct smu_context *smu, +uint32_t *speed) { +int ret; + +if (!speed) +return -EINVAL ; + + ret =smu_v14_0_2_get_smu_metrics_data (smu, +METRICS_CURR_FANPWM , + speed); +if (ret) { +dev_err (smu->adev->dev,"Failed to get fan speed(PWM)!" ); +return ret; + } + +/* Convert the PMFW output which is in percent to pwm(255) based */ + *speed =min (*speed *255 /100 , (uint32_t )255 ); + +return 0 ; +} + +static int smu_v14_0_2_get_fan_speed_rpm (struct smu_context *smu, +uint32_t *speed) { +if (!speed) +return -EINVAL ; + +return smu_v14_0_2_get_smu_metrics_data (smu, +METRICS_CURR_FANSPEED , + speed); } +static int smu_v14_0_2_get_power_limit (struct smu_context *smu,uint32_t *current_power_limit, uint32_t *default_power_limit, @@ -2804,6 +2837,8 @@ static const struct pptable_funcs smu_v14_0_2_ppt_funcs = { .set_performance_level = smu_v14_0_set_performance_level,
.gfx_off_control = smu_v14_0_gfx_off_control,
.get_unique_id = smu_v14_0_2_get_unique_id,
+ .get_fan_speed_pwm = smu_v14_0_2_get_fan_speed_pwm,
+ .get_fan_speed_rpm = smu_v14_0_2_get_fan_speed_rpm,
.get_power_limit = smu_v14_0_2_get_power_limit,
.set_power_limit = smu_v14_0_2_set_power_limit,
.get_power_profile_mode = smu_v14_0_2_get_power_profile_mode,--
2.48.1