Skip to content

Commit e73fc71

Browse files
Evan Quanalexdeucher
authored andcommitted
drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
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 <[email protected]> Acked-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] # 6.0, 6.1
1 parent 272b981 commit e73fc71

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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
@@ -1441,12 +1441,23 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)
14411441
static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu,
14421442
uint32_t *speed)
14431443
{
1444+
int ret;
1445+
14441446
if (!speed)
14451447
return -EINVAL;
14461448

1447-
return smu_v13_0_0_get_smu_metrics_data(smu,
1448-
METRICS_CURR_FANPWM,
1449-
speed);
1449+
ret = smu_v13_0_0_get_smu_metrics_data(smu,
1450+
METRICS_CURR_FANPWM,
1451+
speed);
1452+
if (ret) {
1453+
dev_err(smu->adev->dev, "Failed to get fan speed(PWM)!");
1454+
return ret;
1455+
}
1456+
1457+
/* Convert the PMFW output which is in percent to pwm(255) based */
1458+
*speed = MIN(*speed * 255 / 100, 255);
1459+
1460+
return 0;
14501461
}
14511462

14521463
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
@@ -1363,12 +1363,23 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
13631363
static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu,
13641364
uint32_t *speed)
13651365
{
1366+
int ret;
1367+
13661368
if (!speed)
13671369
return -EINVAL;
13681370

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

13741385
static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,

0 commit comments

Comments
 (0)