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 90df6db62f)
Cc: stable@vger.kernel.org # 6.12.x
This commit is contained in:
Alex Deucher
2025-03-11 10:34:36 -04:00
parent 19b53f9685
commit 5ca0040ecf

View File

@@ -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,