Skip to content

Commit 5ca0040

Browse files
committed
drm/amdgpu/pm: wire up hwmon fan speed for smu 14.0.2
Add callbacks for fan speed fetching. Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4034 Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 90df6db) Cc: stable@vger.kernel.org # 6.12.x
1 parent 19b53f9 commit 5ca0040

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,39 @@ static void smu_v14_0_2_get_unique_id(struct smu_context *smu)
16271627
adev->unique_id = ((uint64_t)upper32 << 32) | lower32;
16281628
}
16291629

1630+
static int smu_v14_0_2_get_fan_speed_pwm(struct smu_context *smu,
1631+
uint32_t *speed)
1632+
{
1633+
int ret;
1634+
1635+
if (!speed)
1636+
return -EINVAL;
1637+
1638+
ret = smu_v14_0_2_get_smu_metrics_data(smu,
1639+
METRICS_CURR_FANPWM,
1640+
speed);
1641+
if (ret) {
1642+
dev_err(smu->adev->dev, "Failed to get fan speed(PWM)!");
1643+
return ret;
1644+
}
1645+
1646+
/* Convert the PMFW output which is in percent to pwm(255) based */
1647+
*speed = min(*speed * 255 / 100, (uint32_t)255);
1648+
1649+
return 0;
1650+
}
1651+
1652+
static int smu_v14_0_2_get_fan_speed_rpm(struct smu_context *smu,
1653+
uint32_t *speed)
1654+
{
1655+
if (!speed)
1656+
return -EINVAL;
1657+
1658+
return smu_v14_0_2_get_smu_metrics_data(smu,
1659+
METRICS_CURR_FANSPEED,
1660+
speed);
1661+
}
1662+
16301663
static int smu_v14_0_2_get_power_limit(struct smu_context *smu,
16311664
uint32_t *current_power_limit,
16321665
uint32_t *default_power_limit,
@@ -2804,6 +2837,8 @@ static const struct pptable_funcs smu_v14_0_2_ppt_funcs = {
28042837
.set_performance_level = smu_v14_0_set_performance_level,
28052838
.gfx_off_control = smu_v14_0_gfx_off_control,
28062839
.get_unique_id = smu_v14_0_2_get_unique_id,
2840+
.get_fan_speed_pwm = smu_v14_0_2_get_fan_speed_pwm,
2841+
.get_fan_speed_rpm = smu_v14_0_2_get_fan_speed_rpm,
28072842
.get_power_limit = smu_v14_0_2_get_power_limit,
28082843
.set_power_limit = smu_v14_0_2_set_power_limit,
28092844
.get_power_profile_mode = smu_v14_0_2_get_power_profile_mode,

0 commit comments

Comments
 (0)