Skip to content

Commit 54b6a04

Browse files
Evan Quangregkh
authored andcommitted
drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
commit e73fc71 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@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org # 6.0, 6.1 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0b865bc commit 54b6a04

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,12 +1417,23 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)
14171417
static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu,
14181418
uint32_t *speed)
14191419
{
1420+
int ret;
1421+
14201422
if (!speed)
14211423
return -EINVAL;
14221424

1423-
return smu_v13_0_0_get_smu_metrics_data(smu,
1424-
METRICS_CURR_FANPWM,
1425-
speed);
1425+
ret = smu_v13_0_0_get_smu_metrics_data(smu,
1426+
METRICS_CURR_FANPWM,
1427+
speed);
1428+
if (ret) {
1429+
dev_err(smu->adev->dev, "Failed to get fan speed(PWM)!");
1430+
return ret;
1431+
}
1432+
1433+
/* Convert the PMFW output which is in percent to pwm(255) based */
1434+
*speed = MIN(*speed * 255 / 100, 255);
1435+
1436+
return 0;
14261437
}
14271438

14281439
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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,12 +1361,23 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
13611361
static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu,
13621362
uint32_t *speed)
13631363
{
1364+
int ret;
1365+
13641366
if (!speed)
13651367
return -EINVAL;
13661368

1367-
return smu_v13_0_7_get_smu_metrics_data(smu,
1368-
METRICS_CURR_FANPWM,
1369-
speed);
1369+
ret = smu_v13_0_7_get_smu_metrics_data(smu,
1370+
METRICS_CURR_FANPWM,
1371+
speed);
1372+
if (ret) {
1373+
dev_err(smu->adev->dev, "Failed to get fan speed(PWM)!");
1374+
return ret;
1375+
}
1376+
1377+
/* Convert the PMFW output which is in percent to pwm(255) based */
1378+
*speed = MIN(*speed * 255 / 100, 255);
1379+
1380+
return 0;
13701381
}
13711382

13721383
static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,

0 commit comments

Comments
 (0)