mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-18 00:24:58 +08:00
drm/amd/pm: record the RPM and PWM based fan speed settings
As the relationship "PWM = RPM / smu->fan_max_rpm" between fan speed PWM and RPM is not true for SMU11 ASICs. So, both the RPM and PWM settings need to be saved. Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
f3289d0497
commit
96401f7c21
@ -3179,6 +3179,9 @@ static ssize_t amdgpu_hwmon_show_mclk_label(struct device *dev,
|
||||
*
|
||||
* - fan[1-\*]_enable: Enable or disable the sensors.1: Enable 0: Disable
|
||||
*
|
||||
* NOTE: DO NOT set the fan speed via "pwm1" and "fan[1-\*]_target" interfaces at the same time.
|
||||
* That will get the former one overridden.
|
||||
*
|
||||
* hwmon interfaces for GPU clocks:
|
||||
*
|
||||
* - freq1_input: the gfx/compute clock in hertz
|
||||
|
@ -34,6 +34,8 @@
|
||||
#define SMU_FW_NAME_LEN 0x24
|
||||
|
||||
#define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)
|
||||
#define SMU_CUSTOM_FAN_SPEED_RPM (1 << 1)
|
||||
#define SMU_CUSTOM_FAN_SPEED_PWM (1 << 2)
|
||||
|
||||
// Power Throttlers
|
||||
#define SMU_THROTTLER_PPT0_BIT 0
|
||||
@ -230,6 +232,7 @@ struct smu_user_dpm_profile {
|
||||
uint32_t fan_mode;
|
||||
uint32_t power_limit;
|
||||
uint32_t fan_speed_percent;
|
||||
uint32_t fan_speed_rpm;
|
||||
uint32_t flags;
|
||||
uint32_t user_od;
|
||||
|
||||
|
@ -408,6 +408,7 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)
|
||||
ret = smu_set_fan_control_mode(smu, smu->user_dpm_profile.fan_mode);
|
||||
if (ret) {
|
||||
smu->user_dpm_profile.fan_speed_percent = 0;
|
||||
smu->user_dpm_profile.fan_speed_rpm = 0;
|
||||
smu->user_dpm_profile.fan_mode = AMD_FAN_CTRL_AUTO;
|
||||
dev_err(smu->adev->dev, "Failed to set manual fan control mode\n");
|
||||
}
|
||||
@ -415,7 +416,13 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)
|
||||
if (smu->user_dpm_profile.fan_speed_percent) {
|
||||
ret = smu_set_fan_speed_percent(smu, smu->user_dpm_profile.fan_speed_percent);
|
||||
if (ret)
|
||||
dev_err(smu->adev->dev, "Failed to set manual fan speed\n");
|
||||
dev_err(smu->adev->dev, "Failed to set manual fan speed in percent\n");
|
||||
}
|
||||
|
||||
if (smu->user_dpm_profile.fan_speed_rpm) {
|
||||
ret = smu_set_fan_speed_rpm(smu, smu->user_dpm_profile.fan_speed_rpm);
|
||||
if (ret)
|
||||
dev_err(smu->adev->dev, "Failed to set manual fan speed in rpm\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2182,7 +2189,6 @@ static int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled)
|
||||
static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
|
||||
{
|
||||
struct smu_context *smu = handle;
|
||||
u32 percent;
|
||||
int ret = 0;
|
||||
|
||||
if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
|
||||
@ -2193,8 +2199,12 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
|
||||
if (smu->ppt_funcs->set_fan_speed_rpm) {
|
||||
ret = smu->ppt_funcs->set_fan_speed_rpm(smu, speed);
|
||||
if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) {
|
||||
percent = speed * 100 / smu->fan_max_rpm;
|
||||
smu->user_dpm_profile.fan_speed_percent = percent;
|
||||
smu->user_dpm_profile.flags |= SMU_CUSTOM_FAN_SPEED_RPM;
|
||||
smu->user_dpm_profile.fan_speed_rpm = speed;
|
||||
|
||||
/* Override custom PWM setting as they cannot co-exist */
|
||||
smu->user_dpm_profile.flags &= ~SMU_CUSTOM_FAN_SPEED_PWM;
|
||||
smu->user_dpm_profile.fan_speed_percent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2555,8 +2565,11 @@ static int smu_set_fan_control_mode(struct smu_context *smu, int value)
|
||||
|
||||
/* reset user dpm fan speed */
|
||||
if (!ret && value != AMD_FAN_CTRL_MANUAL &&
|
||||
!(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE))
|
||||
!(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) {
|
||||
smu->user_dpm_profile.fan_speed_percent = 0;
|
||||
smu->user_dpm_profile.fan_speed_rpm = 0;
|
||||
smu->user_dpm_profile.flags &= ~(SMU_CUSTOM_FAN_SPEED_RPM | SMU_CUSTOM_FAN_SPEED_PWM);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2607,8 +2620,14 @@ static int smu_set_fan_speed_percent(void *handle, u32 speed)
|
||||
if (speed > 100)
|
||||
speed = 100;
|
||||
ret = smu->ppt_funcs->set_fan_speed_percent(smu, speed);
|
||||
if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE))
|
||||
if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) {
|
||||
smu->user_dpm_profile.flags |= SMU_CUSTOM_FAN_SPEED_PWM;
|
||||
smu->user_dpm_profile.fan_speed_percent = speed;
|
||||
|
||||
/* Override custom RPM setting as they cannot co-exist */
|
||||
smu->user_dpm_profile.flags &= ~SMU_CUSTOM_FAN_SPEED_RPM;
|
||||
smu->user_dpm_profile.fan_speed_rpm = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&smu->mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user