Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Evan Quan and committed by
Alex Deucher
e73fc71e 272b9814

+28 -6
+14 -3
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
··· 1441 1441 static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu, 1442 1442 uint32_t *speed) 1443 1443 { 1444 + int ret; 1445 + 1444 1446 if (!speed) 1445 1447 return -EINVAL; 1446 1448 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; 1450 1461 } 1451 1462 1452 1463 static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,
+14 -3
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
··· 1363 1363 static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu, 1364 1364 uint32_t *speed) 1365 1365 { 1366 + int ret; 1367 + 1366 1368 if (!speed) 1367 1369 return -EINVAL; 1368 1370 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; 1372 1383 } 1373 1384 1374 1385 static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,