drm/amd/pm: correct the checks for fan attributes support
Subsystems (3)
PATCH 1/1 drm/amd/pm: correct the checks for fan attributes support
Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating in 3D graphics tests.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++---------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +23 -0
@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,return ret; } + +int amdgpu_dpm_is_fan_operation_supported (struct amdgpu_device *adev, +enum fan_operation_id id) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}
drivers/gpu/drm/amd/pm/amdgpu_pm.c +10 -10
@@ -3263,15 +3263,15 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,return 0 ;/* mask fan attributes if we have no bindings for this asic to expose */ -if (((amdgpu_dpm_get_fan_speed_pwm (adev, &speed) == -EINVAL ) && +if ((!amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_PWM_RETRIEVING ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't query fan */ - ((amdgpu_dpm_get_fan_control_mode (adev, &speed) == -EOPNOTSUPP ) && + (!amdgpu_dpm_is_fan_operation_supported (adev,FAN_CONTROL_MODE_RETRIEVING ) && attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't query state */ effective_mode &= ~S_IRUGO ; -if (((amdgpu_dpm_set_fan_speed_pwm (adev, speed) == -EINVAL ) && +if ((!amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_PWM_SETTING ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't manage fan */ - ((amdgpu_dpm_set_fan_control_mode (adev, speed) == -EOPNOTSUPP ) && + (!amdgpu_dpm_is_fan_operation_supported (adev,FAN_CONTROL_MODE_SETTING ) && attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't manage state */ effective_mode &= ~S_IWUSR ;
@@ -3291,16 +3291,16 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,return 0 ;/* hide max/min values if we can't both query and manage the fan */ -if (((amdgpu_dpm_set_fan_speed_pwm (adev, speed) == -EINVAL ) && - (amdgpu_dpm_get_fan_speed_pwm (adev, &speed) == -EINVAL ) && - (amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL ) && - (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL )) && +if ((!amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_PWM_SETTING ) && + !amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_PWM_RETRIEVING ) && + !amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_RPM_SETTING ) && + !amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_RPM_RETRIEVING )) && (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; -if ((amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL ) && - (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL ) && +if ((!amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_RPM_SETTING ) && + !amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_RPM_RETRIEVING )) && (attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +12 -0
@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{ +FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , +FAN_SPEED_RPM_SETTING =5 , +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size);
@@ -510,4 +520,6 @@ enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev, unsigned int *num_states);int amdgpu_dpm_get_dpm_clock_table (struct amdgpu_device *adev,struct dpm_clocks *clock_table); +int amdgpu_dpm_is_fan_operation_supported (struct amdgpu_device *adev, +enum fan_operation_id id);#endif
Signature · 1 line
2.29.0
Quoted 49 lines · Evan Quan
Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating in 3D graphics tests.
Signed-off-by Evan Quan <[email protected]>Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++---------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +23
-0@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,return ret; } + +int amdgpu_dpm_is_fan_operation_supported (struct amdgpu_device *adev, +enum fan_operation_id id) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj, · line 3266
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-1@@ -3263,15 +3263,15 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,return 0 ;/* mask fan attributes if we have no bindings for this asic to expose */ - if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL) && + if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_RETRIEVING) &&
As per the current logic, it's really checking the hardware registers. For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.
Quoted 16 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-3attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */ - ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) && + (!amdgpu_dpm_is_fan_operation_supported(adev, FAN_CONTROL_MODE_RETRIEVING) && attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */ effective_mode &= ~S_IRUGO ; -if (((amdgpu_dpm_set_fan_speed_pwm (adev, speed) == -EINVAL ) && +if ((!amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_PWM_SETTING ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't manage fan */ - ((amdgpu_dpm_set_fan_control_mode (adev, speed) == -EOPNOTSUPP ) && + (!amdgpu_dpm_is_fan_operation_supported (adev,FAN_CONTROL_MODE_SETTING ) && attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't manage state */ effective_mode &= ~S_IWUSR ;@@ -3291,16 +3291,16 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,return 0 ;
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj, · line 3297
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4
-4/* hide max/min values if we can't both query and manage the fan */ - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL) && - (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL) && - (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL) && - (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)) && + if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_SETTING) && + !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_RETRIEVING) && + !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_SETTING) && + !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_RETRIEVING)) &&
If this is the case, I think we should set pm.no_fan since nothing is possible.
Thanks,
Lijo
Quoted 40 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2
-2(attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; -if ((amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL ) && - (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL ) && +if ((!amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_RPM_SETTING ) && + !amdgpu_dpm_is_fan_operation_supported (adev,FAN_SPEED_RPM_RETRIEVING )) && (attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +12
-0@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{ +FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , +FAN_SPEED_RPM_SETTING =5 , +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size);@@ -510,4 +520,6 @@ enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev, unsigned int *num_states);int amdgpu_dpm_get_dpm_clock_table (struct amdgpu_device *adev,struct dpm_clocks *clock_table); +int amdgpu_dpm_is_fan_operation_supported (struct amdgpu_device *adev, +enum fan_operation_id id);#endif
[AMD Official Use Only]
Quoted 69 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 3 lines · Evan Quan
Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating
in
Quoted 6 lines
3D graphics tests.
Signed-off-by Evan Quan <[email protected]>Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23+++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++---------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.cdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct
Quoted 4 lines
index
68d2e80a673b..e732418a9558100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0return ret; } + +int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device*adev,
Review
Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21
-0+ enum fan_operation_id id) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_pm.cdrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 4 lines
index
d3eab245e0fe..57721750c51a100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3263,15 +3263,15 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0return 0 ;
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3265
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0/* mask fan attributes if we have no bindings for this asic to expose */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&As per the current logic, it's really checking the hardware registers.
[Quan, Evan] I probably should mention the "current" version you see now is actually a regression introduced by the commit below:801771de0331 drm/amd/pm: do not expose power implementation details to amdgpu_pm.c
The very early version(which works good) is something like below:
- if (!is_support_sw_smu(adev)) {
- /* mask fan attributes if we have no bindings for this asic to expose */
- if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm &&
- attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
- (!adev->powerplay.pp_funcs->get_fan_control_mode &&
- attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */
- effective_mode &= ~S_IRUGO;
So, the changes here are really just back to old working version. It aims to provide a quick fix for the failures reported by CQE.
Quoted 46 lines
For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3267
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't queryfan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_RETRIEVING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3269
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tquery state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1effective_mode &= ~S_IRUGO ; - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3272
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3273
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tmanage fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3275
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tmanage state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0effective_mode &= ~S_IWUSR ;@@ -3291,16 +3291,16 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1return 0 ;/* hide max/min values if we can't both query and manage the fan */ - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_pwm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&If this is the case, I think we should set pm.no_fan since nothing is possible.
[Quan, Evan] Yep, I agree a more optimized version should be something like that. Let's take this a quick solution and do further optimizations later.
BR
Evan
Quoted 52 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1(attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; - if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&Review
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0(attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hQuoted 9 lines
index
ba857ca75392..9e18151a3c46100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , + FAN_SPEED_RPM_SETTING = 5, +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void *data, uint32_t *size);@@ -510,4 +520,6 @@ enum pp_smu_statusamdgpu_dpm_get_uclk_dpm_states(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0unsigned int *num_states);int amdgpu_dpm_get_dpm_clock_table (struct amdgpu_device *adev,struct dpm_clocks *clock_table); +int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+ enum fan_operation_id id);#endif
Quoted 93 lines · Evan
[AMD Official Use Only]
Quoted 69 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 3 lines · Evan Quan
Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating
in
Quoted 6 lines
3D graphics tests.
Signed-off-by Evan Quan <[email protected]>Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23+++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++---------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.cdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct
Quoted 4 lines
index
68d2e80a673b..e732418a9558100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0return ret; } + +int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device*adev,
Review
Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21
-0+ enum fan_operation_id id) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_pm.cdrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 4 lines
index
d3eab245e0fe..57721750c51a100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3263,15 +3263,15 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0return 0 ;Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3265
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0/* mask fan attributes if we have no bindings for this asic to expose */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&As per the current logic, it's really checking the hardware registers.
[Quan, Evan] I probably should mention the "current" version you see now is actually a regression introduced by the commit below:
801771de0331drm/amd/pm: do not expose power implementation details toamdgpu_pm.cThe very early version(which works good) is something like below:
(quoted diff) +0
-7- if (!is_support_sw_smu(adev)) { - /* mask fan attributes if we have no bindings for this asic to expose */ - if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm && - attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */ - (!adev->powerplay.pp_funcs->get_fan_control_mode && - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */ - effective_mode &= ~S_IRUGO;
Quoted 1 line
So, the changes here are really just back to old working version. It aims to provide a quick fix for the failures reported by CQE.
I see. Could you model on it based on below one? This is preferrable rather than introducing new API.
drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices.
Thanks,
Lijo
Quoted 110 lines
Quoted 46 lines
For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3267
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't queryfan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_RETRIEVING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3269
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tquery state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1effective_mode &= ~S_IRUGO ; - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3272
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3273
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tmanage fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3275
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tmanage state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0effective_mode &= ~S_IWUSR ;@@ -3291,16 +3291,16 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1return 0 ;/* hide max/min values if we can't both query and manage the fan */ - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_pwm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&If this is the case, I think we should set pm.no_fan since nothing is possible.
[Quan, Evan] Yep, I agree a more optimized version should be something like that. Let's take this a quick solution and do further optimizations later.
BR
EvanQuoted 52 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1(attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; - if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&Review
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0(attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hQuoted 9 lines
index
ba857ca75392..9e18151a3c46100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , + FAN_SPEED_RPM_SETTING = 5, +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void *data, uint32_t *size);@@ -510,4 +520,6 @@ enum pp_smu_statusamdgpu_dpm_get_uclk_dpm_states(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0unsigned int *num_states);int amdgpu_dpm_get_dpm_clock_table (struct amdgpu_device *adev,struct dpm_clocks *clock_table); +int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+ enum fan_operation_id id);#endif
[AMD Official Use Only]
Quoted 113 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 4:31 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 31 lines · Evan
[AMD Official Use Only]
Quoted 27 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 4 lines · Evan Quan
Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating
in
Quoted 6 lines
3D graphics tests.
Signed-off-by Evan Quan <[email protected]>Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23+++++++++++++++++++++++
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++---------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)Quoted 6 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.cdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 4 lines
index
68d2e80a673b..e732418a9558100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1547,3 +1547,26 @@ intamdgpu_dpm_get_dpm_clock_table(struct
Quoted 39 lines
Quoted 39 lines
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0return ret; } + +int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device*adev,
Review
Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21
-0+ enum fan_operation_id id) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_pm.cdrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 4 lines
index
d3eab245e0fe..57721750c51a100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3263,15 +3263,15 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0return 0 ;/* mask fan attributes if we have no bindings for this asic to expose
Quoted 8 lines
Quoted 7 lines
*/
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&As per the current logic, it's really checking the hardware registers.
[Quan, Evan] I probably should mention the "current" version you see now
is actually a regression introduced by the commit below:
Quoted 1 line
801771de0331drm/amd/pm: do not expose power implementation detailsto
Review
Quoted 5 lines
amdgpu_pm.cThe very early version(which works good) is something like below:
(quoted diff) +0
-2- if (!is_support_sw_smu(adev)) { - /* mask fan attributes if we have no bindings for this asic to expose*/
Review
Quoted 2 lines
(quoted diff) +0
-2- if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm && - attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tquery fan */
Review
Quoted 2 lines
(quoted diff) +0
-2- (!adev->powerplay.pp_funcs->get_fan_control_mode && - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tquery state */
Quoted 2 lines
-
effective_mode&= ~S_IRUGO;
Quoted 8 lines
Quoted 1 line
So, the changes here are really just back to old working version. It aims to
provide a quick fix for the failures reported by CQE.
I see. Could you model on it based on below one? This is preferrable rather than introducing new API.
drm/amdgpu/pm: Don't show
pp_power_profile_modefor unsupported devices.
[Quan, Evan] In fact, those piece of code from the mentioned change was updated as below
} else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
*states = ATTR_STATE_UNSUPPORTED;
}As the access for adev->powerplay.pp_funcs from amdgpu_pm.c was forbidden after the pm cleanups. So, we have to rely on some (new)API in amdgpu_dpm.c to do those checks.
A more proper way to cleanup all those attributes support checks stuff is to have a flag like "adev->pm.sysfs_attribtues_flags".
It labels all those sysfs attributes supported on each ASIC. However, considering the ASICs involved and the difference between them, that may be not an easy job.
BR
Evan
Quoted 119 lines
Thanks,
LijoQuoted 49 lines
Quoted 49 lines
For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.
Quoted 2 lines
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tquery
fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_RETRIEVING) &&Quoted 2 lines
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*can't
query state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 3 lines
effective_mode &= ~S_IRUGO;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&Quoted 1 line
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tmanage fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_SETTING) &&Quoted 2 lines
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*can't
manage state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 3 lines
effective_mode &= ~S_IWUSR;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3291,16 +3291,16 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1return 0 ;/* hide max/min values if we can't both query and manage the fan */ - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_pwm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&If this is the case, I think we should set pm.no_fan since nothing is possible.
[Quan, Evan] Yep, I agree a more optimized version should be something
like that.
Quoted 46 lines
Let's take this a quick solution and do further optimizations later.
BR
EvanQuoted 42 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1(attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; - if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&Review
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0(attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hQuoted 9 lines
index
ba857ca75392..9e18151a3c46100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , + FAN_SPEED_RPM_SETTING = 5, +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void *data, uint32_t *size); @@ -510,4 +520,6 @@enum
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
pp_smu_statusamdgpu_dpm_get_uclk_dpm_states(struct
amdgpu_device*adev,Quoted 4 lines
unsigned int *num_states); int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev, struct dpm_clocks *clock_table);+int amdgpu_dpm_is_fan_operation_supported(struct
amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+ enum fan_operation_id id);#endif
Quoted 125 lines · Evan
[AMD Official Use Only]
Quoted 113 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 4:31 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 31 lines · Evan
[AMD Official Use Only]
Quoted 27 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 4 lines · Evan Quan
Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating
in
Quoted 6 lines
3D graphics tests.
Signed-off-by Evan Quan <[email protected]>Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23+++++++++++++++++++++++
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++---------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)Quoted 6 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.cdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 4 lines
index
68d2e80a673b..e732418a9558100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1547,3 +1547,26 @@ intamdgpu_dpm_get_dpm_clock_table(struct
Quoted 39 lines
Quoted 39 lines
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0return ret; } + +int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device*adev,
Review
Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21
-0+ enum fan_operation_id id) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_pm.cdrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 4 lines
index
d3eab245e0fe..57721750c51a100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3263,15 +3263,15 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0return 0 ;/* mask fan attributes if we have no bindings for this asic to expose
Quoted 8 lines
Quoted 7 lines
*/
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&As per the current logic, it's really checking the hardware registers.
[Quan, Evan] I probably should mention the "current" version you see now
is actually a regression introduced by the commit below:
Quoted 1 line
801771de0331drm/amd/pm: do not expose power implementation detailsto
Review
Quoted 5 lines
amdgpu_pm.cThe very early version(which works good) is something like below:
(quoted diff) +0
-2- if (!is_support_sw_smu(adev)) { - /* mask fan attributes if we have no bindings for this asic to expose*/
Review
Quoted 2 lines
(quoted diff) +0
-2- if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm && - attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tquery fan */
Review
Quoted 2 lines
(quoted diff) +0
-2- (!adev->powerplay.pp_funcs->get_fan_control_mode && - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tquery state */
Quoted 2 lines
-
effective_mode&= ~S_IRUGO;Quoted 8 lines
Quoted 1 line
So, the changes here are really just back to old working version. It aims to
provide a quick fix for the failures reported by CQE.
I see. Could you model on it based on below one? This is preferrable rather than introducing new API.
drm/amdgpu/pm: Don't show
pp_power_profile_modefor unsupported devices.
Quoted 8 lines
[Quan, Evan] In fact, those piece of code from the mentioned change was updated as below
} else if (DEVICE_ATTR_IS(pp_power_profile_mode)) { if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP) *states = ATTR_STATE_UNSUPPORTED; }As the access for
adev->powerplay.pp_funcsfromamdgpu_pm.cwas forbidden after the pm cleanups. So, we have to rely on some (new)API inamdgpu_dpm.cto do those checks.
To be clear, the model is to use a dummy call to check if the API is implemented -
amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP amdgpu_dpm_set_fan_speed_rpm(adev, -1) == -EOPNOTSUPP
That is better instead of adding another API and flags for each set/get API.
Thanks,
Lijo
Quoted 124 lines
A more proper way to cleanup all those attributes support checks stuff is to have a flag like "
adev->pm.sysfs_attribtues_flags".
It labels all those sysfs attributes supported on each ASIC. However, considering the ASICs involved and the difference between them, that may be not an easy job.BR
EvanQuoted 119 lines
Thanks,
LijoQuoted 49 lines
Quoted 49 lines
For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.
Quoted 2 lines
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tquery
fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_RETRIEVING) &&Quoted 2 lines
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*can't
query state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 3 lines
effective_mode &= ~S_IRUGO;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&Quoted 1 line
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tmanage fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_SETTING) &&Quoted 2 lines
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*can't
manage state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 3 lines
effective_mode &= ~S_IWUSR;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3291,16 +3291,16 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1return 0 ;/* hide max/min values if we can't both query and manage the fan */ - if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_pwm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_set_fan_speed_rpm (adev, speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&If this is the case, I think we should set pm.no_fan since nothing is possible.
[Quan, Evan] Yep, I agree a more optimized version should be something
like that.
Quoted 46 lines
Let's take this a quick solution and do further optimizations later.
BR
EvanQuoted 42 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1(attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; - if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm (adev, &speed) == -EINVAL )&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&Review
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0(attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hQuoted 9 lines
index
ba857ca75392..9e18151a3c46100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , + FAN_SPEED_RPM_SETTING = 5, +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void *data, uint32_t *size); @@ -510,4 +520,6 @@enum
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
pp_smu_statusamdgpu_dpm_get_uclk_dpm_states(struct
amdgpu_device*adev,Quoted 4 lines
unsigned int *num_states); int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev, struct dpm_clocks *clock_table);+int amdgpu_dpm_is_fan_operation_supported(struct
amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+ enum fan_operation_id id);#endif
[AMD Official Use Only]
Quoted 160 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 11:32 AM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 23 lines · Evan
[AMD Official Use Only]
Quoted 19 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 4:31 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 8 lines · Evan
[AMD Official Use Only]
Quoted 4 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; amd-Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 1 line · Evan Quan
Before we relied on the return values from the corresponding
interfaces.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating
in
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
3D graphics tests.
Signed-off-by Evan Quan <[email protected]>Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23+++++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++----------
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Review
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.cdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 4 lines
index
68d2e80a673b..e732418a9558100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1547,3 +1547,26 @@ intamdgpu_dpm_get_dpm_clock_table(struct
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0return ret; } + +int amdgpu_dpm_is_fan_operation_supported(struct
amdgpu_deviceQuoted 30 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
*adev,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+ enum fan_operation_id id) +{ + const struct amd_pm_funcs *pp_funcs = adev-powerplay.pp_funcs;
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Review
Quoted 19 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +18
-0+ +switch (id) { +case FAN_CONTROL_MODE_RETRIEVING : +return pp_funcs->get_fan_control_mode ?1 :0 ; +case FAN_CONTROL_MODE_SETTING : +return pp_funcs->set_fan_control_mode ?1 :0 ; +case FAN_SPEED_PWM_RETRIEVING : +return pp_funcs->get_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_PWM_SETTING : +return pp_funcs->set_fan_speed_pwm ?1 :0 ; +case FAN_SPEED_RPM_RETRIEVING : +return pp_funcs->get_fan_speed_rpm ?1 :0 ; +case FAN_SPEED_RPM_SETTING : +return pp_funcs->set_fan_speed_rpm ?1 :0 ; +default : +return 0 ; + } +}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_pm.cdrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 4 lines
index
d3eab245e0fe..57721750c51a100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3263,15 +3263,15 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0return 0 ;/* mask fan attributes if we have no bindings for this asic to expose
*/
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) ==
-EINVAL)Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&As per the current logic, it's really checking the hardware registers.
[Quan, Evan] I probably should mention the "current" version you see now
is actually a regression introduced by the commit below:
Quoted 1 line
801771de0331drm/amd/pm: do not expose power implementationdetails
Quoted 6 lines
Quoted 6 lines
to
Quoted 5 lines
amdgpu_pm.cThe very early version(which works good) is something like below:
(quoted diff) +0
-2- if (!is_support_sw_smu(adev)) { - /* mask fan attributes if we have no bindings for this asic toexpose
Quoted 6 lines
Quoted 6 lines
*/
Review
Quoted 2 lines
(quoted diff) +0
-2- if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm && - attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can'tquery fan */
Quoted 2 lines
(quoted diff) +0
-2- (!adev->powerplay.pp_funcs->get_fan_control_mode && - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*can't
Quoted 5 lines
Quoted 5 lines
query state */
Quoted 4 lines
-
effective_mode&= ~S_IRUGO;So, the changes here are really just back to old working version. It aims to
Quoted 8 lines
Quoted 7 lines
provide a quick fix for the failures reported by CQE.
I see. Could you model on it based on below one? This is preferrable rather than introducing new API.
drm/amdgpu/pm: Don't show
pp_power_profile_modefor unsupported devices.[Quan, Evan] In fact, those piece of code from the mentioned change was
updated as below
Quoted 2 lines
} else if (DEVICE_ATTR_IS(pp_power_profile_mode)) { if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
Quoted 3 lines
*states = ATTR_STATE_UNSUPPORTED; }As the access for
adev->powerplay.pp_funcsfromamdgpu_pm.cwasforbidden after the pm cleanups.
Quoted 1 line
So, we have to rely on some (new)API in
amdgpu_dpm.cto do thosechecks.
Quoted 1 line
Quoted 7 lines
To be clear, the model is to use a dummy call to check if the API is implemented -
amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP amdgpu_dpm_set_fan_speed_rpm(adev, -1) == -EOPNOTSUPPThat is better instead of adding another API and flags for each set/get API.
[Quan, Evan] I see. OK, I can refactor this patch that way.
BR
Evan
Quoted 149 lines
Thanks,
LijoQuoted 1 line
A more proper way to cleanup all those attributes support checks stuff is to
have a flag like "
adev->pm.sysfs_attribtues_flags".Quoted 1 line
It labels all those sysfs attributes supported on each ASIC. However,
considering the ASICs involved and the difference between them, that may be not an easy job.
Quoted 12 lines
BR
EvanQuoted 9 lines
Thanks,
LijoQuoted 5 lines
Quoted 5 lines
For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /*can't query
fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_get_fan_control_mode(adev, &speed) ==-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_RETRIEVING) &&Quoted 1 line
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/*
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
can't
query state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 3 lines
effective_mode &= ~S_IRUGO;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&Quoted 2 lines
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /*can't
manage fan */
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- ((amdgpu_dpm_set_fan_control_mode(adev, speed) ==-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ (!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_CONTROL_MODE_SETTING) &&Quoted 1 line
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/*
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
can't
manage state */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 3 lines
effective_mode &= ~S_IWUSR;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3291,16 +3291,16 @@ static umode_thwmon_attributes_visible(struct kobject *kobj,
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0return 0 ;/* hide max/min values if we can't both query and manage the fan */
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_PWM_RETRIEVING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&If this is the case, I think we should set pm.no_fan since nothing is possible.
[Quan, Evan] Yep, I agree a more optimized version should be something
like that.
Quoted 5 lines
Let's take this a quick solution and do further optimizations later.
BR
EvanQuoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1(attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; - if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1- (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((!amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_SETTING) &&drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ !amdgpu_dpm_is_fan_operation_supported(adev,
FAN_SPEED_RPM_RETRIEVING)) &&Review
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0(attr == &sensor_dev_attr_fan1_max.dev_attr.attr || attr == &sensor_dev_attr_fan1_min.dev_attr.attr))return 0 ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hQuoted 9 lines
index
ba857ca75392..9e18151a3c46100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0@@ -330,6 +330,16 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; +enum fan_operation_id +{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+FAN_CONTROL_MODE_RETRIEVING =0 , +FAN_CONTROL_MODE_SETTING =1 , +FAN_SPEED_PWM_RETRIEVING =2 , +FAN_SPEED_PWM_SETTING =3 , +FAN_SPEED_RPM_RETRIEVING =4 , + FAN_SPEED_RPM_SETTING = 5, +}; +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 345
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void *data, uint32_t *size); @@ -510,4+520,6 @@
Quoted 4 lines
Quoted 4 lines
enum
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
pp_smu_statusamdgpu_dpm_get_uclk_dpm_states(struct
amdgpu_device*adev,Quoted 1 line
unsigned int
*num_states);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
int amdgpu_dpm_get_dpm_clock_table(struct
amdgpu_device*adev,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
struct dpm_clocks *clock_table);+int amdgpu_dpm_is_fan_operation_supported(struct
amdgpu_deviceQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
*adev,
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+ enum fan_operation_id id);#endif