This is a note to let you know that I've just added the patch titled drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-amd-pm-correct-the-fan-speed-retrieving-in-pwm-for-some-smu13-asics.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From e73fc71e8f015d61f3adca7659cb209fd5117aa5 Mon Sep 17 00:00:00 2001 From: Evan Quan <evan.quan@xxxxxxx> Date: Fri, 16 Dec 2022 17:04:24 +0800 Subject: drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics From: Evan Quan <evan.quan@xxxxxxx> commit e73fc71e8f015d61f3adca7659cb209fd5117aa5 upstream. 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 <evan.quan@xxxxxxx> Acked-by: Alex Deucher <alexander.deucher@xxxxxxx> Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> Cc: stable@xxxxxxxxxxxxxxx # 6.0, 6.1 Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 17 ++++++++++++++--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c @@ -1417,12 +1417,23 @@ out: static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu, uint32_t *speed) { + int ret; + 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) { + 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, 255); + + return 0; } static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu, --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c @@ -1361,12 +1361,23 @@ static int smu_v13_0_7_populate_umd_stat static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu, uint32_t *speed) { + int ret; + 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) { + 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, 255); + + return 0; } static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu, Patches currently in stable-queue which might be from evan.quan@xxxxxxx are queue-6.1/drm-amd-pm-add-missing-smu13.0.7-mm_dpm-feature-mapping.patch queue-6.1/drm-amd-pm-add-missing-smu13.0.0-mm_dpm-feature-mapping.patch queue-6.1/drm-amd-pm-correct-the-fan-speed-retrieving-in-pwm-for-some-smu13-asics.patch queue-6.1/drm-amd-pm-update-smu13.0.0-reported-maximum-shader-clock.patch queue-6.1/drm-amd-pm-correct-smu13.0.0-pstate-profiling-clock-settings.patch queue-6.1/drm-amd-pm-bump-smu13.0.0-driver_if-header-to-version-0x34.patch