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
On functionality unsupported, -EOPNOTSUPP will be returned. And we rely on that to determine the fan attributes support.
amdgpu_pm.c")
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115 +++++++++--------- 6 files changed, 132 insertions(+), 108 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -2
@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed);int (*force_clock_level)(void *handle,enum pp_clock_type type,uint32_t mask);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +26 -5
@@ -1030,15 +1030,20 @@ int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, uint32_t *fan_mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev->powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev->powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; } int amdgpu_dpm_set_fan_speed_pwm(struct amdgpu_device *adev,
@@ -1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);
@@ -1065,6 +1073,9 @@ int amdgpu_dpm_get_fan_speed_pwm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);
@@ -1082,6 +1093,9 @@ int amdgpu_dpm_get_fan_speed_rpm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);
@@ -1099,6 +1113,9 @@ int amdgpu_dpm_set_fan_speed_rpm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);
@@ -1113,16 +1130,20 @@ int amdgpu_dpm_set_fan_control_mode(struct amdgpu_device *adev, uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, - mode); + ret = pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; } int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
drivers/gpu/drm/amd/pm/amdgpu_pm.c +10 -11
@@ -3197,7 +3197,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported */ if (amdgpu_sriov_vf (adev) && !amdgpu_sriov_is_pp_one_vf (adev))
@@ -3263,15 +3262,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_get_fan_speed_pwm (adev,NULL ) == -EOPNOTSUPP ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't query fan */ - ((amdgpu_dpm_get_fan_control_mode (adev, &speed) == -EOPNOTSUPP ) && + ((amdgpu_dpm_get_fan_control_mode (adev,NULL ) == -EOPNOTSUPP ) && 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_set_fan_speed_pwm (adev,U32_MAX ) == -EOPNOTSUPP ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't manage fan */ - ((amdgpu_dpm_set_fan_control_mode (adev, speed) == -EOPNOTSUPP ) && + ((amdgpu_dpm_set_fan_control_mode (adev,U32_MAX ) == -EOPNOTSUPP ) && attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't manage state */ effective_mode &= ~S_IWUSR ;
@@ -3291,16 +3290,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_set_fan_speed_pwm (adev,U32_MAX ) == -EOPNOTSUPP ) && + (amdgpu_dpm_get_fan_speed_pwm (adev,NULL ) == -EOPNOTSUPP ) && + (amdgpu_dpm_set_fan_speed_rpm (adev,U32_MAX ) == -EOPNOTSUPP ) && + (amdgpu_dpm_get_fan_speed_rpm (adev,NULL ) == -EOPNOTSUPP )) && (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_set_fan_speed_rpm (adev,U32_MAX ) == -EOPNOTSUPP ) && + (amdgpu_dpm_get_fan_speed_rpm (adev,NULL ) == -EOPNOTSUPP ) && (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/legacy-dpm/si_dpm.c +7 -3
@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void *handle,return 0 ; } -static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -6685,9 +6685,11 @@ static void si_dpm_set_fan_control_mode(void *handle, u32 mode)else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; } -static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode (void *handle,u32 *fan_mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct si_power_info *si_pi =si_get_pi (adev);
@@ -6697,7 +6699,9 @@ static u32 si_dpm_get_fan_control_mode(void *handle)return 0 ; tmp =RREG32 (CG_FDO_CTRL2 ) &FDO_PWM_MODE_MASK ; -return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +27 -32
111 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +60 -55
210 lines not on this page · raw message
Signature · 1 line
2.29.0
Quoted 38 lines · Evan Quan
On functionality unsupported,
-EOPNOTSUPPwill be returned. And we rely on that to determine the fan attributes support.Fixes 801771de0331 ("drm/amd/pm: do not expose power implementation details to
amdgpu_pm.c")Signed-off-by Evan Quan <[email protected]>Change-Id I95e7e0beebd678a446221a72234cd356e14f0fcd--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115 +++++++++--------- 6 files changed, 132 insertions(+), 108 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-2@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed);int (*force_clock_level)(void *handle,enum pp_clock_type type,uint32_t mask);drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1030,15 +1030,20 @@ int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, uint32_t *fan_mode)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, · line 1040
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0{const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +
pp_funcs most likely will be there for smu/powerplay subsystem. I think the checks should be at one layer down - smu_get_fan_control_mode() and pp_dpm_get_fan_control_mode()
First one will check if ppt func is implemented and second one will check if hwmgr func is implemented for the specific ASIC.
Thanks,
Lijo
Quoted 511 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +22
-5mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev->powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev->powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; } int amdgpu_dpm_set_fan_speed_pwm(struct amdgpu_device *adev,@@ -1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1065,6 +1073,9 @@ int amdgpu_dpm_get_fan_speed_pwm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1082,6 +1093,9 @@ int amdgpu_dpm_get_fan_speed_rpm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1099,6 +1113,9 @@ int amdgpu_dpm_set_fan_speed_rpm(struct amdgpu_device *adev,int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1113,16 +1130,20 @@ int amdgpu_dpm_set_fan_control_mode(struct amdgpu_device *adev, uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, - mode); + ret = pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; } int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_pm.c +10
-11@@ -3197,7 +3197,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported */ if (amdgpu_sriov_vf (adev) && !amdgpu_sriov_is_pp_one_vf (adev))@@ -3263,15 +3262,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_get_fan_speed_pwm (adev,NULL ) == -EOPNOTSUPP ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't query fan */ - ((amdgpu_dpm_get_fan_control_mode (adev, &speed) == -EOPNOTSUPP ) && + ((amdgpu_dpm_get_fan_control_mode (adev,NULL ) == -EOPNOTSUPP ) && 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_set_fan_speed_pwm (adev,U32_MAX ) == -EOPNOTSUPP ) && attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't manage fan */ - ((amdgpu_dpm_set_fan_control_mode (adev, speed) == -EOPNOTSUPP ) && + ((amdgpu_dpm_set_fan_control_mode (adev,U32_MAX ) == -EOPNOTSUPP ) && attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't manage state */ effective_mode &= ~S_IWUSR ;@@ -3291,16 +3290,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_set_fan_speed_pwm (adev,U32_MAX ) == -EOPNOTSUPP ) && + (amdgpu_dpm_get_fan_speed_pwm (adev,NULL ) == -EOPNOTSUPP ) && + (amdgpu_dpm_set_fan_speed_rpm (adev,U32_MAX ) == -EOPNOTSUPP ) && + (amdgpu_dpm_get_fan_speed_rpm (adev,NULL ) == -EOPNOTSUPP )) && (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_set_fan_speed_rpm (adev,U32_MAX ) == -EOPNOTSUPP ) && + (amdgpu_dpm_get_fan_speed_rpm (adev,NULL ) == -EOPNOTSUPP ) && (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/legacy-dpm/si_dpm.c +7
-3@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void *handle,return 0 ; } -static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -6685,9 +6685,11 @@ static void si_dpm_set_fan_control_mode(void *handle, u32 mode)else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; } -static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode (void *handle,u32 *fan_mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct si_power_info *si_pi =si_get_pi (adev);@@ -6697,7 +6699,9 @@ static u32 si_dpm_get_fan_control_mode(void *handle)return 0 ; tmp =RREG32 (CG_FDO_CTRL2 ) &FDO_PWM_MODE_MASK ; -return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +27
-32@@ -488,38 +488,37 @@ static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)return pm_type; } -static void pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) +static int pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) {struct pp_hwmgr *hwmgr = handle;if (!hwmgr || !hwmgr->pm_en) -return ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) { -pr_info_ratelimited ("%s was not implemented.\n" , __func__); -return ; - }mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode (hwmgr, mode);mutex_unlock (&hwmgr->smu_lock); + +return 0 ; } -static uint32_t pp_dpm_get_fan_control_mode (void *handle) +static int pp_dpm_get_fan_control_mode (void *handle,uint32_t *fan_mode) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;if (!hwmgr || !hwmgr->pm_en) -return 0 ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) { -pr_info_ratelimited ("%s was not implemented.\n" , __func__); -return 0 ; - }mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); + *fan_mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr);mutex_unlock (&hwmgr->smu_lock); -return mode; +return 0 ; }static int pp_dpm_set_fan_speed_pwm (void *handle,uint32_t speed)@@ -528,12 +527,11 @@ static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) { -pr_info_ratelimited ("%s was not implemented.\n" , __func__); -return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed);mutex_unlock (&hwmgr->smu_lock);@@ -546,12 +544,10 @@ static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) { -pr_info_ratelimited ("%s was not implemented.\n" , __func__); -return 0 ; - } +if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed);@@ -565,10 +561,10 @@ static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm)int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ;if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL ) -return -EINVAL ; +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm);@@ -582,12 +578,11 @@ static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) { -pr_info_ratelimited ("%s was not implemented.\n" , __func__); -return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm);mutex_unlock (&hwmgr->smu_lock);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +60
-55@@ -59,7 +59,7 @@ static int smu_handle_task(struct smu_context *smu, bool lock_needed);static int smu_reset (struct smu_context *smu);static int smu_set_fan_speed_pwm (void *handle,u32 speed); -static int smu_set_fan_control_mode (struct smu_context *smu,int value); +static int smu_set_fan_control_mode (void *handle,u32 value);static int smu_set_power_limit (void *handle,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);@@ -407,7 +407,7 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)if (smu->user_dpm_profile.fan_mode ==AMD_FAN_CTRL_MANUAL || smu->user_dpm_profile.fan_mode ==AMD_FAN_CTRL_NONE ) { ret =smu_set_fan_control_mode (smu, smu->user_dpm_profile.fan_mode); -if (ret) { +if (ret != -EOPNOTSUPP ) { smu->user_dpm_profile.fan_speed_pwm =0 ; smu->user_dpm_profile.fan_speed_rpm =0 ; smu->user_dpm_profile.fan_mode =AMD_FAN_CTRL_AUTO ;@@ -416,13 +416,13 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)if (smu->user_dpm_profile.fan_speed_pwm) { ret =smu_set_fan_speed_pwm (smu, smu->user_dpm_profile.fan_speed_pwm); -if (ret) +if (ret != -EOPNOTSUPP )dev_err (smu->adev->dev,"Failed to set manual fan speed in pwm\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) +if (ret != -EOPNOTSUPP )dev_err (smu->adev->dev,"Failed to set manual fan speed in rpm\n" ); } }@@ -2218,18 +2218,19 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -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 )) { - smu->user_dpm_profile.flags |=SMU_CUSTOM_FAN_SPEED_RPM ; - smu->user_dpm_profile.fan_speed_rpm = speed; + ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed); +if (!ret && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) { + 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_pwm =0 ; - } +/* 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_pwm =0 ; }mutex_unlock (&smu->mutex);@@ -2562,60 +2563,59 @@ static int smu_set_power_profile_mode(void *handle, } -static u32 smu_get_fan_control_mode (void *handle) +static int smu_get_fan_control_mode (void *handle,u32 *fan_mode) {struct smu_context *smu = handle; -u32 ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return AMD_FAN_CTRL_NONE ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->get_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) - ret = smu->ppt_funcs->get_fan_control_mode (smu); + *fan_mode = smu->ppt_funcs->get_fan_control_mode (smu);mutex_unlock (&smu->mutex); -return ret; +return 0 ; } -static int smu_set_fan_control_mode (struct smu_context *smu,int value) +static int smu_set_fan_control_mode (void *handle,u32 value) { +struct smu_context *smu = handle;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return -EOPNOTSUPP ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->set_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { - ret = smu->ppt_funcs->set_fan_control_mode (smu, value); -if (!ret && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) - smu->user_dpm_profile.fan_mode = value; - } + ret = smu->ppt_funcs->set_fan_control_mode (smu, value); +if (ret) + goto out; -mutex_unlock (&smu->mutex); +if (!(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) { + smu->user_dpm_profile.fan_mode = 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.fan_speed_pwm =0 ; - smu->user_dpm_profile.fan_speed_rpm =0 ; - smu->user_dpm_profile.flags &= ~(SMU_CUSTOM_FAN_SPEED_RPM |SMU_CUSTOM_FAN_SPEED_PWM ); +/* reset user dpm fan speed */ +if (value !=AMD_FAN_CTRL_MANUAL ) { + smu->user_dpm_profile.fan_speed_pwm =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; -} - -static void smu_pp_set_fan_control_mode (void *handle,u32 value) -{ -struct smu_context *smu = handle; +out: +mutex_unlock (&smu->mutex); -smu_set_fan_control_mode (smu, value); +return ret; } -static int smu_get_fan_speed_pwm (void *handle,u32 *speed) {struct smu_context *smu = handle;@@ -2624,10 +2624,12 @@ static int smu_get_fan_speed_pwm(void *handle, u32 *speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) - ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed);mutex_unlock (&smu->mutex);@@ -2642,18 +2644,19 @@ static int smu_set_fan_speed_pwm(void *handle, u32 speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { - ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); -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_pwm = speed; + ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); +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_pwm = 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 ; - } +/* 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);@@ -2669,10 +2672,12 @@ static int smu_get_fan_speed_rpm(void *handle, uint32_t *speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) - ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed);mutex_unlock (&smu->mutex);@@ -3101,7 +3106,7 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)static const struct amd_pm_funcs swsmu_pm_funcs = {/* export for sysfs */ - .set_fan_control_mode = smu_pp_set_fan_control_mode, + .set_fan_control_mode = smu_set_fan_control_mode, .get_fan_control_mode = smu_get_fan_control_mode, .set_fan_speed_pwm = smu_set_fan_speed_pwm, .get_fan_speed_pwm = smu_get_fan_speed_pwm,
[AMD Official Use Only]
Quoted 71 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 4:14 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 4 lines · Evan Quan
On functionality unsupported,
-EOPNOTSUPPwill be returned. And we rely on that to determine the fan attributes support.Fixes 801771de0331 ("drm/amd/pm: do not expose powerimplementation
Quoted 5 lines
details to
amdgpu_pm.c")Signed-off-by Evan Quan <[email protected]>Change-Id I95e7e0beebd678a446221a72234cd356e14f0fcdQuoted 7 lines
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115 +++++++++---------
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 24 lines
6 files changed, 132 insertions(+), 108 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-2@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed); int (*force_clock_level)(void *handle, enum pp_clock_type type,
uint32_tmask); diff --gita/drivers/gpu/drm/amd/pm/amdgpu_dpm.cb/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index68d2e80a673b..fe69785df403100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1030,15 +1030,20 @@ intamdgpu_dpm_get_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, · line 1040
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0uint32_t *fan_mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +
pp_funcsmost likely will be there for smu/powerplay subsystem. I think the checks should be at one layer down -smu_get_fan_control_mode()andpp_dpm_get_fan_control_mode()
Quoted 2 lines
First one will check if ppt func is implemented and second one will check if hwmgr func is implemented for the specific ASIC.
[Quan, Evan] Yes, I agree. And if you go through the changes below, you will see the checks (for the layers down) there. This patch checks not only those amdgpu_dpm_xxxx APIs, but also those downstream interfaces(smu_xxxx and pp_dpm_xxxx).
BR
Evan
Quoted 610 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-2mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 1 line
int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,@@
Quoted 1 line
-1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_pwm(struct
Quoted 10 lines
int ret = 0;if (!pp_funcs->set_fan_speed_pwm)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1065,6 +1073,9 @@ int amdgpu_dpm_get_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1082,6 +1093,9 @@ int amdgpu_dpm_get_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1099,6 +1113,9 @@ int amdgpu_dpm_set_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1113,16 +1130,20 @@ intamdgpu_dpm_set_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct
Quoted 30 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7
-3uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, - mode); + ret = pp_funcs->set_fan_control_mode (adev- powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }int amdgpu_dpm_get_power_limit(struct
amdgpu_device*adev, diff
--gita/drivers/gpu/drm/amd/pm/amdgpu_pm.cb/drivers/gpu/drm/amd/pm/amdgpu_pm.c
indexd3eab245e0fe..940cbe751163100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3197,7 +3197,6 @@ static umode_t hwmon_attributes_visible(structkobject *kobj,
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj, · line 3202
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0if (amdgpu_sriov_vf (adev) && !amdgpu_sriov_is_pp_one_vf (adev))@@
Quoted 1 line
-3263,15 +3262,15 @@ static
umode_thwmon_attributes_visible(structkobject *kobj,
Quoted 3 lines
return 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)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
Quoted 1 line
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't queryfan */
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_get_fan_control_mode(adev, NULL) == -EOPNOTSUPP) &&
Quoted 1 line
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_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2
-0+ ((amdgpu_dpm_set_fan_control_mode (adev,U32_MAX ) == +-EOPNOTSUPP ) && attr == &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
effective_mode &= ~S_IWUSR;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3291,16 +3290,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 3293
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP)) &&
drivers/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 3301
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((amdgpu_dpm_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_dpm_set_fan_speed_pwm(void
Quoted 9 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 ;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void*handle,
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void si_dpm_set_fan_control_mode(void
Quoted 9 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-1return 0 ; } -static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -6685,9 +6685,11 @@ static void si_dpm_set_fan_control_mode(void*handle, u32 mode)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type
Quoted 29 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; } -static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode (void *handle,u32 *fan_mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct si_power_info *si_pi = si_get_pi(adev); @@ -6697,7 +6699,9@@ static u32
si_dpm_get_fan_control_mode(void *handle)
return 0;tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1-return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0@@ -488,38 +488,37 @@ static enum amd_pm_state_type
pp_dpm_get_current_power_state(void *handle)Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1return pm_type; } -static void pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) +static int pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) {struct pp_hwmgr *hwmgr = handle;drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3if (!hwmgr || !hwmgr->pm_en) -return ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 15 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-4-return ; - }mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode (hwmgr, mode);mutex_unlock (&hwmgr->smu_lock); + +return 0 ; } -static uint32_t pp_dpm_get_fan_control_mode (void *handle) +static int pp_dpm_get_fan_control_mode (void *handle,uint32_t +*fan_mode) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3if (!hwmgr || !hwmgr->pm_en) -return 0 ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle) · line 524
Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-4-return 0 ; - }mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); + *fan_mode = hwmgr->hwmgr_func-get_fan_control_mode (hwmgr);mutex_unlock (&hwmgr->smu_lock); -return mode; +return 0 ; }static int pp_dpm_set_fan_speed_pwm (void *handle,uint32_t speed)@@
Quoted 1 line
-528,12 +527,11 @@ static int pp_dpm_set_fan_speed_pwm(void *handle,
uint32_tspeed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed);mutex_unlock (&hwmgr->smu_lock);@@ -546,12 +544,10 @@ static int pp_dpm_get_fan_speed_pwm(void*handle,
uint32_t*speed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-3int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed) · line 553
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return 0 ; - } +if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed);@@
Quoted 1 line
-565,10 +561,10 @@ static int pp_dpm_get_fan_speed_rpm(void *handle,
uint32_t*rpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) · line 570
Quoted 12 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return -EINVAL ; +return -EOPNOTSUPP ;if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL ) -return -EINVAL ; +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm);@@ -582,12
Quoted 1 line
+578,11 @@ static int pp_dpm_set_fan_speed_rpm(void *handle,
uint32_trpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct
Quoted 20 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm);mutex_unlock (&hwmgr->smu_lock);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0@@ -59,7 +59,7 @@ static int smu_handle_task(struct smu_context *smu, bool lock_needed);static int smu_reset (struct smu_context *smu); static int smu_set_fan_speed_pwm(void *handle, u32 speed); -staticint smu_set_fan_control_mode (struct smu_context *smu,int value); +static int smu_set_fan_control_mode (void *handle,u32 value);static int smu_set_power_limit (void *handle,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);@@ -407,7 +407,7 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct · line 407
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0if (smu->user_dpm_profile.fan_mode ==
AMD_FAN_CTRL_MANUAL||Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_NONE) { ret =smu_set_fan_control_mode (smu, smu- user_dpm_profile.fan_mode); -if (ret) { +if (ret != -EOPNOTSUPP ) { smu->user_dpm_profile.fan_speed_pwm =0 ; smu->user_dpm_profile.fan_speed_rpm =0 ;
smu->user_dpm_profile.fan_mode=
AMD_FAN_CTRL_AUTO; @@ -416,13Quoted 1 line
+416,13 @@ static void smu_restore_dpm_user_profile(struct
smu_contextdrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
*smu)
if (
smu->user_dpm_profile.fan_speed_pwm) {
ret = smu_set_fan_speed_pwm(smu, smu-
user_dpm_profile.fan_speed_pwm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in pwm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
}if (
smu->user_dpm_profile.fan_speed_rpm) {
ret = smu_set_fan_speed_rpm(smu, smu-
user_dpm_profile.fan_speed_rpm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in rpm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void
Quoted 3 lines
} }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2218,18 +2218,19 @@ static int smu_set_fan_speed_rpm(void*handle,
uint32_tspeed)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -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)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2226
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_rpm = speed; + ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2228
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_rpm = speed; -/* Override custom PWM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2230
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_pwm =0 ; - } +/* Override custom PWM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_pwm =0 ; }mutex_unlock (&smu->mutex);@@ -2562,60 +2563,59 @@ static int smu_set_power_profile_mode(void*handle,
Quoted 37 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +9
-8} -static u32 smu_get_fan_control_mode (void *handle) +static int smu_get_fan_control_mode (void *handle,u32 *fan_mode) {struct smu_context *smu = handle; -u32 ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return AMD_FAN_CTRL_NONE ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->get_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) - ret = smu->ppt_funcs->get_fan_control_mode (smu); + *fan_mode = smu->ppt_funcs->get_fan_control_mode (smu);mutex_unlock (&smu->mutex); -return ret; +return 0 ; } -static int smu_set_fan_control_mode (struct smu_context *smu,int value) +static int smu_set_fan_control_mode(void *handle, u32 value) { +struct smu_context *smu = handle;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return -EOPNOTSUPP ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3+return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->set_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { - ret = smu->ppt_funcs->set_fan_control_mode (smu, value); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3- smu->user_dpm_profile.fan_mode = value; - } + ret = smu->ppt_funcs->set_fan_control_mode (smu, value); +if (ret) + goto out; -mutex_unlock (&smu->mutex); + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-3+ smu->user_dpm_profile.fan_mode = value; -/* reset user dpm fan speed */ - if (!ret && value != AMD_FAN_CTRL_MANUAL && - !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3- smu->user_dpm_profile.fan_speed_pwm =0 ; - smu->user_dpm_profile.fan_speed_rpm =0 ; - smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+/* reset user dpm fan speed */ +if (value !=AMD_FAN_CTRL_MANUAL ) { + smu->user_dpm_profile.fan_speed_pwm =0 ; + smu->user_dpm_profile.fan_speed_rpm =0 ; + smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_pwm(void
Quoted 20 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-7+ } } -return ret; -} - -static void smu_pp_set_fan_control_mode(void *handle, u32 value) -{ -struct smu_context *smu = handle; +out: +mutex_unlock (&smu->mutex); -smu_set_fan_control_mode (smu, value); +return ret; } -static int smu_get_fan_speed_pwm (void *handle,u32 *speed) {struct smu_context *smu = handle;@@ -2624,10 +2624,12 @@ static int smu_get_fan_speed_pwm(void*handle, u32 *speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void
Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) - ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed);mutex_unlock (&smu->mutex);@@ -2642,18 +2644,19 @@ static int smu_set_fan_speed_pwm(void*handle, u32 speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { - ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2650
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_pwm = speed; + ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_pwm = speed; -/* Override custom RPM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_rpm =0 ; - } +/* Override custom RPM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_rpm(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_rpm =0 ; }mutex_unlock (&smu->mutex);@@ -2669,10 +2672,12 @@ static int smu_get_fan_speed_rpm(void*handle,
uint32_t*speed)Quoted 25 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) - ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed);mutex_unlock (&smu->mutex);@@ -3101,7 +3106,7 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)static const struct amd_pm_funcs swsmu_pm_funcs = {/* export for sysfs */ - .set_fan_control_mode = smu_pp_set_fan_control_mode, + .set_fan_control_mode = smu_set_fan_control_mode, .get_fan_control_mode = smu_get_fan_control_mode, .set_fan_speed_pwm = smu_set_fan_speed_pwm,.get_fan_speed_pwm =
smu_get_fan_speed_pwm,
Quoted 75 lines · Evan
[AMD Official Use Only]
Quoted 71 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 4:14 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 4 lines · Evan Quan
On functionality unsupported,
-EOPNOTSUPPwill be returned. And we rely on that to determine the fan attributes support.Fixes 801771de0331 ("drm/amd/pm: do not expose powerimplementation
Quoted 5 lines
details to
amdgpu_pm.c")Signed-off-by Evan Quan <[email protected]>Change-Id I95e7e0beebd678a446221a72234cd356e14f0fcdQuoted 7 lines
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115 +++++++++---------
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 24 lines
6 files changed, 132 insertions(+), 108 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-2@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed); int (*force_clock_level)(void *handle, enum pp_clock_type type,
uint32_tmask); diff --gita/drivers/gpu/drm/amd/pm/amdgpu_dpm.cb/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index68d2e80a673b..fe69785df403100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1030,15 +1030,20 @@ intamdgpu_dpm_get_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, · line 1040
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0uint32_t *fan_mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +
pp_funcsmost likely will be there for smu/powerplay subsystem. I think the checks should be at one layer down -smu_get_fan_control_mode()andpp_dpm_get_fan_control_mode()
Quoted 5 lines
Quoted 2 lines
First one will check if ppt func is implemented and second one will check if hwmgr func is implemented for the specific ASIC.
[Quan, Evan] Yes, I agree. And if you go through the changes below, you will see the checks (for the layers down) there. This patch checks not only those
amdgpu_dpm_xxxxAPIs, but also those downstreaminterfaces(smu_xxxx and pp_dpm_xxxx).
Say you call amdgpu_dpm_get_fan_control_mode(adev, NULL) from amdgpu_pm
pp_funcs->get_fan_control_mode => this will point to smu_get_fan_control_mode for all swsmu ASICs. So "if (!pp_funcs->get_fan_control_mode)" will be false.
The next statement is NULL check and it will return -EINVAL.
What we want to know is ppt_func is implemented or not for the particualr swsmu ASIC. Isn't that the case or am I reading it differently?
Thanks,
Lijo
Quoted 612 lines
BR
EvanQuoted 610 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-2mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 1 line
int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,@@
Quoted 1 line
-1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_pwm(struct
Quoted 10 lines
int ret = 0;if (!pp_funcs->set_fan_speed_pwm)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1065,6 +1073,9 @@ int amdgpu_dpm_get_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1082,6 +1093,9 @@ int amdgpu_dpm_get_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1099,6 +1113,9 @@ int amdgpu_dpm_set_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1113,16 +1130,20 @@ intamdgpu_dpm_set_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct
Quoted 30 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7
-3uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, - mode); + ret = pp_funcs->set_fan_control_mode (adev- powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }int amdgpu_dpm_get_power_limit(struct
amdgpu_device*adev, diff
--gita/drivers/gpu/drm/amd/pm/amdgpu_pm.cb/drivers/gpu/drm/amd/pm/amdgpu_pm.c
indexd3eab245e0fe..940cbe751163100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3197,7 +3197,6 @@ static umode_t hwmon_attributes_visible(structkobject *kobj,
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported */
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj, · line 3202
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0if (amdgpu_sriov_vf (adev) && !amdgpu_sriov_is_pp_one_vf (adev))@@
Quoted 1 line
-3263,15 +3262,15 @@ static
umode_thwmon_attributes_visible(structkobject *kobj,
Quoted 3 lines
return 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)&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
Quoted 1 line
attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't queryfan */
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_get_fan_control_mode(adev, NULL) == -EOPNOTSUPP) &&
Quoted 1 line
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can'tquery 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_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2
-0+ ((amdgpu_dpm_set_fan_control_mode (adev,U32_MAX ) == +-EOPNOTSUPP ) && attr == &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
effective_mode &= ~S_IWUSR;drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3291,16 +3290,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 3293
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP)) &&
drivers/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 3301
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((amdgpu_dpm_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_dpm_set_fan_speed_pwm(void
Quoted 9 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 ;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void*handle,
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void si_dpm_set_fan_control_mode(void
Quoted 9 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-1return 0 ; } -static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -6685,9 +6685,11 @@ static void si_dpm_set_fan_control_mode(void*handle, u32 mode)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type
Quoted 29 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; } -static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode (void *handle,u32 *fan_mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct si_power_info *si_pi = si_get_pi(adev); @@ -6697,7 +6699,9@@ static u32
si_dpm_get_fan_control_mode(void *handle)
return 0;tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1-return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0@@ -488,38 +488,37 @@ static enum amd_pm_state_type
pp_dpm_get_current_power_state(void *handle)Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1return pm_type; } -static void pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) +static int pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) {struct pp_hwmgr *hwmgr = handle;drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3if (!hwmgr || !hwmgr->pm_en) -return ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 15 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-4-return ; - }mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode (hwmgr, mode);mutex_unlock (&hwmgr->smu_lock); + +return 0 ; } -static uint32_t pp_dpm_get_fan_control_mode (void *handle) +static int pp_dpm_get_fan_control_mode (void *handle,uint32_t +*fan_mode) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3if (!hwmgr || !hwmgr->pm_en) -return 0 ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle) · line 524
Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-4-return 0 ; - }mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); + *fan_mode = hwmgr->hwmgr_func-get_fan_control_mode (hwmgr);mutex_unlock (&hwmgr->smu_lock); -return mode; +return 0 ; }static int pp_dpm_set_fan_speed_pwm (void *handle,uint32_t speed)@@
Quoted 1 line
-528,12 +527,11 @@ static int pp_dpm_set_fan_speed_pwm(void *handle,
uint32_tspeed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed);mutex_unlock (&hwmgr->smu_lock);@@ -546,12 +544,10 @@ static int pp_dpm_get_fan_speed_pwm(void*handle,
uint32_t*speed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-3int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed) · line 553
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return 0 ; - } +if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed);@@
Quoted 1 line
-565,10 +561,10 @@ static int pp_dpm_get_fan_speed_rpm(void *handle,
uint32_t*rpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) · line 570
Quoted 12 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return -EINVAL ; +return -EOPNOTSUPP ;if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL ) -return -EINVAL ; +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm);@@ -582,12
Quoted 1 line
+578,11 @@ static int pp_dpm_set_fan_speed_rpm(void *handle,
uint32_trpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct
Quoted 20 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm);mutex_unlock (&hwmgr->smu_lock);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0@@ -59,7 +59,7 @@ static int smu_handle_task(struct smu_context *smu, bool lock_needed);static int smu_reset (struct smu_context *smu); static int smu_set_fan_speed_pwm(void *handle, u32 speed); -staticint smu_set_fan_control_mode (struct smu_context *smu,int value); +static int smu_set_fan_control_mode (void *handle,u32 value);static int smu_set_power_limit (void *handle,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);@@ -407,7 +407,7 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct · line 407
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0if (smu->user_dpm_profile.fan_mode ==
AMD_FAN_CTRL_MANUAL||Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_NONE) { ret =smu_set_fan_control_mode (smu, smu- user_dpm_profile.fan_mode); -if (ret) { +if (ret != -EOPNOTSUPP ) { smu->user_dpm_profile.fan_speed_pwm =0 ; smu->user_dpm_profile.fan_speed_rpm =0 ;smu->user_dpm_profile.fan_mode =
AMD_FAN_CTRL_AUTO; @@ -416,13Quoted 1 line
+416,13 @@ static void smu_restore_dpm_user_profile(struct
smu_contextdrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
*smu)
if (
smu->user_dpm_profile.fan_speed_pwm) {
ret = smu_set_fan_speed_pwm(smu, smu-
user_dpm_profile.fan_speed_pwm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in pwm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
}if (
smu->user_dpm_profile.fan_speed_rpm) {
ret = smu_set_fan_speed_rpm(smu, smu-
user_dpm_profile.fan_speed_rpm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in rpm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void
Quoted 3 lines
} }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2218,18 +2218,19 @@ static int smu_set_fan_speed_rpm(void*handle,
uint32_tspeed)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -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)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2226
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_rpm = speed; + ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2228
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_rpm = speed; -/* Override custom PWM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2230
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_pwm =0 ; - } +/* Override custom PWM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_pwm =0 ; }mutex_unlock (&smu->mutex);@@ -2562,60 +2563,59 @@ static int smu_set_power_profile_mode(void*handle,
Quoted 37 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +9
-8} -static u32 smu_get_fan_control_mode (void *handle) +static int smu_get_fan_control_mode (void *handle,u32 *fan_mode) {struct smu_context *smu = handle; -u32 ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return AMD_FAN_CTRL_NONE ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->get_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) - ret = smu->ppt_funcs->get_fan_control_mode (smu); + *fan_mode = smu->ppt_funcs->get_fan_control_mode (smu);mutex_unlock (&smu->mutex); -return ret; +return 0 ; } -static int smu_set_fan_control_mode (struct smu_context *smu,int value) +static int smu_set_fan_control_mode(void *handle, u32 value) { +struct smu_context *smu = handle;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return -EOPNOTSUPP ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3+return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->set_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { - ret = smu->ppt_funcs->set_fan_control_mode (smu, value); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3- smu->user_dpm_profile.fan_mode = value; - } + ret = smu->ppt_funcs->set_fan_control_mode (smu, value); +if (ret) + goto out; -mutex_unlock (&smu->mutex); + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-3+ smu->user_dpm_profile.fan_mode = value; -/* reset user dpm fan speed */ - if (!ret && value != AMD_FAN_CTRL_MANUAL && - !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3- smu->user_dpm_profile.fan_speed_pwm =0 ; - smu->user_dpm_profile.fan_speed_rpm =0 ; - smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+/* reset user dpm fan speed */ +if (value !=AMD_FAN_CTRL_MANUAL ) { + smu->user_dpm_profile.fan_speed_pwm =0 ; + smu->user_dpm_profile.fan_speed_rpm =0 ; + smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_pwm(void
Quoted 20 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-7+ } } -return ret; -} - -static void smu_pp_set_fan_control_mode(void *handle, u32 value) -{ -struct smu_context *smu = handle; +out: +mutex_unlock (&smu->mutex); -smu_set_fan_control_mode (smu, value); +return ret; } -static int smu_get_fan_speed_pwm (void *handle,u32 *speed) {struct smu_context *smu = handle;@@ -2624,10 +2624,12 @@ static int smu_get_fan_speed_pwm(void*handle, u32 *speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void
Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) - ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed);mutex_unlock (&smu->mutex);@@ -2642,18 +2644,19 @@ static int smu_set_fan_speed_pwm(void*handle, u32 speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { - ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2650
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_pwm = speed; + ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_pwm = speed; -/* Override custom RPM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_rpm =0 ; - } +/* Override custom RPM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_rpm(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_rpm =0 ; }mutex_unlock (&smu->mutex);@@ -2669,10 +2672,12 @@ static int smu_get_fan_speed_rpm(void*handle,
uint32_t*speed)Quoted 25 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) - ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed);mutex_unlock (&smu->mutex);@@ -3101,7 +3106,7 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)static const struct amd_pm_funcs swsmu_pm_funcs = {/* export for sysfs */ - .set_fan_control_mode = smu_pp_set_fan_control_mode, + .set_fan_control_mode = smu_set_fan_control_mode, .get_fan_control_mode = smu_get_fan_control_mode, .set_fan_speed_pwm = smu_set_fan_speed_pwm,.get_fan_speed_pwm =
smu_get_fan_speed_pwm,
[AMD Official Use Only]
Quoted 100 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 6:15 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 33 lines · Evan
[AMD Official Use Only]
Quoted 29 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 4:14 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 4 lines · Evan Quan
On functionality unsupported,
-EOPNOTSUPPwill be returned. And we rely on that to determine the fan attributes support.Fixes 801771de0331 ("drm/amd/pm: do not expose powerimplementation
Quoted 12 lines
details to
amdgpu_pm.c")Signed-off-by Evan Quan <[email protected]>Change-Id I95e7e0beebd678a446221a72234cd356e14f0fcd--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115+++++++++----
Quoted 43 lines
Quoted 43 lines
-----
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 24 lines
6 files changed, 132 insertions(+), 108 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-2@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed); int (*force_clock_level)(void *handle, enum pp_clock_type type,
uint32_tmask); diff --gita/drivers/gpu/drm/amd/pm/amdgpu_dpm.cb/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index68d2e80a673b..fe69785df403100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1030,15 +1030,20 @@ intamdgpu_dpm_get_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, · line 1040
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0uint32_t *fan_mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +
pp_funcsmost likely will be there for smu/powerplay subsystem. I think the checks should be at one layer down -smu_get_fan_control_mode()andpp_dpm_get_fan_control_mode()Quoted 3 lines
Quoted 2 lines
First one will check if ppt func is implemented and second one will check if hwmgr func is implemented for the specific ASIC.
[Quan, Evan] Yes, I agree. And if you go through the changes below, you
will see the checks (for the layers down) there.
Quoted 1 line
This patch checks not only those
amdgpu_dpm_xxxxAPIs, but also thosedownstream
interfaces(smu_xxxx and pp_dpm_xxxx).Quoted 1 line
Say you call
amdgpu_dpm_get_fan_control_mode(adev, NULL)fromamdgpu_pm
Quoted 9 lines
pp_funcs->get_fan_control_mode=> this will point tosmu_get_fan_control_modefor all swsmu ASICs. So "if (!pp_funcs-Quoted 1 line
get_fan_control_mode)" will be false.The next statement is NULL check and it will return
-EINVAL.What we want to know is
ppt_funcis implemented or not for the particualr swsmu ASIC. Isn't that the case or am I reading it differently?
[Quan, Evan] OK, I get your point now. Hmm, that will be a little tricky.
I suppose the EINVAL check needs to be dispatched in every instance(pp_dpm_xxxxx, smu_xxxx, si_dpm_xxxx) then. Any better idea?
BR
Evan
Quoted 633 lines
Thanks,
LijoQuoted 89 lines
BR
EvanQuoted 87 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-2mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 1 line
int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,@@
Quoted 1 line
-1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_pwm(struct
Quoted 10 lines
int ret = 0;if (!pp_funcs->set_fan_speed_pwm)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1065,6 +1073,9 @@ int amdgpu_dpm_get_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1082,6 +1093,9 @@ int amdgpu_dpm_get_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1099,6 +1113,9 @@ int amdgpu_dpm_set_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1113,16 +1130,20 @@ intamdgpu_dpm_set_fan_control_mode(struct
amdgpu_device*adev,Quoted 23 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7
-3uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, - mode); + ret = pp_funcs->set_fan_control_mode (adev- powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 7 lines
int amdgpu_dpm_get_power_limit(struct
amdgpu_device*adev, diff
--gita/drivers/gpu/drm/amd/pm/amdgpu_pm.cb/drivers/gpu/drm/amd/pm/amdgpu_pm.c
indexd3eab245e0fe..940cbe751163100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3197,7 +3197,6 @@ static umode_thwmon_attributes_visible(struct
Quoted 95 lines
Quoted 95 lines
kobject *kobj,
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported
*/
Quoted 1 line
if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))@@
Quoted 1 line
-3263,15 +3262,15 @@ static
umode_thwmon_attributes_visible(structkobject *kobj,
Quoted 4 lines
return 0; /* mask fan attributes if we have no bindings for this asic toexpose
*/
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_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_get_fan_control_mode(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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) &&
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2
-0+ ((amdgpu_dpm_set_fan_control_mode (adev,U32_MAX ) == +-EOPNOTSUPP ) && 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 +3290,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 3293
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP)) &&
drivers/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 3301
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((amdgpu_dpm_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_dpm_set_fan_speed_pwm(void
Quoted 9 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 ;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void*handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0return 0 ; }Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void
Quoted 6 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-1-static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -6685,9 +6685,11 @@ static voidsi_dpm_set_fan_control_mode(void
Quoted 10 lines
Quoted 10 lines
*handle, u32 mode)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void si_dpm_set_fan_control_mode(void *handle, u32 mode)
Quoted 9 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; } -static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode(void *handle, u32
*fan_mode)Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type
Quoted 20 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4
-1{struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct si_power_info *si_pi = si_get_pi(adev); @@ -6697,7 +6699,9 @@ static u32 si_dpm_get_fan_control_mode(void *handle) return 0; tmp =RREG32 (CG_FDO_CTRL2 ) &FDO_PWM_MODE_MASK ; -return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0@@ -488,38 +488,37 @@ static enum amd_pm_state_type
pp_dpm_get_current_power_state(void *handle)Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1return pm_type; } -static void pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) +static int pp_dpm_set_fan_control_mode(void *handle, uint32_tmode)
Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3{struct pp_hwmgr *hwmgr = handle;if (!hwmgr || !hwmgr->pm_en) -return ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 15 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-4-return ; - }mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode (hwmgr, mode);mutex_unlock (&hwmgr->smu_lock); + +return 0 ; } -static uint32_t pp_dpm_get_fan_control_mode (void *handle) +static int pp_dpm_get_fan_control_mode (void *handle,uint32_t +*fan_mode) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3if (!hwmgr || !hwmgr->pm_en) -return 0 ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-4-return 0 ; - }mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); + *fan_mode = hwmgr->hwmgr_func-get_fan_control_mode (hwmgr);mutex_unlock (&hwmgr->smu_lock); -return mode; +return 0 ; }Quoted 3 lines
Quoted 3 lines
Quoted 1 line
static int
pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)@@
Quoted 1 line
-528,12 +527,11 @@ static int pp_dpm_set_fan_speed_pwm(void
*handle,
Quoted 34 lines
Quoted 34 lines
uint32_tspeed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed);mutex_unlock (&hwmgr->smu_lock);@@ -546,12 +544,10 @@ static int pp_dpm_get_fan_speed_pwm(void*handle,
uint32_t*speed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-3int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return 0 ; - } +if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed) · line 553
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed);@@
Quoted 1 line
-565,10 +561,10 @@ static int pp_dpm_get_fan_speed_rpm(void
*handle,
Quoted 28 lines
Quoted 28 lines
uint32_t*rpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) · line 570
Quoted 12 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return -EINVAL ; +return -EOPNOTSUPP ;if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL ) -return -EINVAL ; +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm);@@ -582,12
Quoted 1 line
+578,11 @@ static int pp_dpm_set_fan_speed_rpm(void *handle,
uint32_trpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_handle_task(struct smu_context
Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm);mutex_unlock (&hwmgr->smu_lock);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -59,7 +59,7 @@ static int smu_handle_task(struct smu_context*smu,
Quoted 78 lines
Quoted 78 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1bool lock_needed);static int smu_reset (struct smu_context *smu);static int smu_set_fan_speed_pwm (void *handle,u32 speed); -static int smu_set_fan_control_mode (struct smu_context *smu,int value); +static int smu_set_fan_control_mode (void *handle,u32 value);static int smu_set_power_limit (void *handle,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg(struct
smu_context*smu, bool
enabled); @@ -407,7 +407,7 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)Quoted 1 line
if (smu->user_dpm_profile.fan_mode ==
AMD_FAN_CTRL_MANUAL||drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
smu->user_dpm_profile.fan_mode==AMD_FAN_CTRL_NONE) {
ret = smu_set_fan_control_mode(smu, smu-
user_dpm_profile.fan_mode);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) { +if (ret != -EOPNOTSUPP ) { smu->user_dpm_profile.fan_speed_pwm =0 ; smu->user_dpm_profile.fan_speed_rpm =0 ; smu->user_dpm_profile.fan_mode =
AMD_FAN_CTRL_AUTO; @@ -416,13Quoted 1 line
+416,13 @@ static void smu_restore_dpm_user_profile(struct
smu_contextdrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
*smu)
if (
smu->user_dpm_profile.fan_speed_pwm) {
ret = smu_set_fan_speed_pwm(smu, smu-
user_dpm_profile.fan_speed_pwm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in pwm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
}if (
smu->user_dpm_profile.fan_speed_rpm) {
ret = smu_set_fan_speed_rpm(smu, smu-
user_dpm_profile.fan_speed_rpm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in rpm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void
Quoted 3 lines
} }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2218,18 +2218,19 @@ static int smu_set_fan_speed_rpm(void*handle,
uint32_tspeed)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -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)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2226
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_rpm = speed; + ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2228
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_rpm = speed; -/* Override custom PWM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2230
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_pwm =0 ; - } +/* Override custom PWM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_pwm =0 ; }mutex_unlock (&smu->mutex);@@ -2562,60 +2563,59 @@ static intsmu_set_power_profile_mode(void
Quoted 60 lines
Quoted 60 lines
*handle,
Quoted 37 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +9
-8} -static u32 smu_get_fan_control_mode (void *handle) +static int smu_get_fan_control_mode (void *handle,u32 *fan_mode) {struct smu_context *smu = handle; -u32 ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return AMD_FAN_CTRL_NONE ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->get_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) - ret = smu->ppt_funcs->get_fan_control_mode (smu); + *fan_mode = smu->ppt_funcs->get_fan_control_mode (smu);mutex_unlock (&smu->mutex); -return ret; +return 0 ; } -static int smu_set_fan_control_mode (struct smu_context *smu,int value) +static int smu_set_fan_control_mode(void *handle, u32 value) { +struct smu_context *smu = handle;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return -EOPNOTSUPP ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3+return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->set_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { - ret = smu->ppt_funcs->set_fan_control_mode (smu, value); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3- smu->user_dpm_profile.fan_mode = value; - } + ret = smu->ppt_funcs->set_fan_control_mode (smu, value); +if (ret) + goto out; -mutex_unlock (&smu->mutex); + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_mode = value;Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3-/* reset user dpm fan speed */ - if (!ret && value != AMD_FAN_CTRL_MANUAL && - !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3- smu->user_dpm_profile.fan_speed_pwm =0 ; - smu->user_dpm_profile.fan_speed_rpm =0 ; - smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+/* reset user dpm fan speed */ +if (value !=AMD_FAN_CTRL_MANUAL ) { + smu->user_dpm_profile.fan_speed_pwm =0 ; + smu->user_dpm_profile.fan_speed_rpm =0 ; + smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);Quoted 99 lines
Quoted 99 lines
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-7+ } } -return ret; -} - -static void smu_pp_set_fan_control_mode(void *handle, u32 value) -{ -struct smu_context *smu = handle; +out: +mutex_unlock (&smu->mutex); -smu_set_fan_control_mode (smu, value); +return ret; } -static int smu_get_fan_speed_pwm (void *handle,u32 *speed) { struct smu_context *smu = handle; @@ -2624,10 +2624,12 @@ staticQuoted 1 line
int smu_get_fan_speed_pwm(void
*handle, u32 *speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void
Quoted 15 lines
if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) return -EOPNOTSUPP;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2+if (!smu->ppt_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) - ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed);mutex_unlock (&smu->mutex);@@ -2642,18 +2644,19 @@ static int smu_set_fan_speed_pwm(void*handle, u32 speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { - ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2650
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_pwm = speed; + ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_pwm = speed; -/* Override custom RPM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_rpm =0 ; - } +/* Override custom RPM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_rpm(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_rpm =0 ; }mutex_unlock (&smu->mutex);@@ -2669,10 +2672,12 @@ static int smu_get_fan_speed_rpm(void*handle,
uint32_t*speed)Quoted 25 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) - ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed);mutex_unlock (&smu->mutex);@@ -3101,7 +3106,7 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)static const struct amd_pm_funcs swsmu_pm_funcs = {/* export for sysfs */ - .set_fan_control_mode = smu_pp_set_fan_control_mode, + .set_fan_control_mode = smu_set_fan_control_mode, .get_fan_control_mode = smu_get_fan_control_mode, .set_fan_speed_pwm = smu_set_fan_speed_pwm,.get_fan_speed_pwm =
smu_get_fan_speed_pwm,
Quoted 108 lines · Evan
[AMD Official Use Only]
Quoted 104 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 6:15 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 33 lines · Evan
[AMD Official Use Only]
Quoted 29 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 4:14 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 4 lines · Evan Quan
On functionality unsupported,
-EOPNOTSUPPwill be returned. And we rely on that to determine the fan attributes support.Fixes 801771de0331 ("drm/amd/pm: do not expose powerimplementation
Quoted 12 lines
details to
amdgpu_pm.c")Signed-off-by Evan Quan <[email protected]>Change-Id I95e7e0beebd678a446221a72234cd356e14f0fcd--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115+++++++++----
Quoted 43 lines
Quoted 43 lines
-----
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 24 lines
6 files changed, 132 insertions(+), 108 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-2@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed); int (*force_clock_level)(void *handle, enum pp_clock_type type,
uint32_tmask); diff --gita/drivers/gpu/drm/amd/pm/amdgpu_dpm.cb/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index68d2e80a673b..fe69785df403100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1030,15 +1030,20 @@ intamdgpu_dpm_get_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, · line 1040
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0uint32_t *fan_mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +
pp_funcsmost likely will be there for smu/powerplay subsystem. I think the checks should be at one layer down -smu_get_fan_control_mode()andpp_dpm_get_fan_control_mode()Quoted 3 lines
Quoted 2 lines
First one will check if ppt func is implemented and second one will check if hwmgr func is implemented for the specific ASIC.
[Quan, Evan] Yes, I agree. And if you go through the changes below, you
will see the checks (for the layers down) there.
Quoted 1 line
This patch checks not only those
amdgpu_dpm_xxxxAPIs, but also thosedownstream
interfaces(smu_xxxx and pp_dpm_xxxx).Quoted 1 line
Say you call
amdgpu_dpm_get_fan_control_mode(adev, NULL)fromamdgpu_pm
pp_funcs->get_fan_control_mode=> this will point tosmu_get_fan_control_modefor all swsmu ASICs. So "if (!pp_funcs-Quoted 1 line
get_fan_control_mode)" will be false.
Quoted 8 lines
Quoted 5 lines
The next statement is NULL check and it will return
-EINVAL.What we want to know is
ppt_funcis implemented or not for the particualr swsmu ASIC. Isn't that the case or am I reading it differently?[Quan, Evan] OK, I get your point now. Hmm, that will be a little tricky.
I suppose the EINVAL check needs to be dispatched in everyinstance(pp_dpm_xxxxx, smu_xxxx, si_dpm_xxxx)then. Any better idea?
Yeah, that is what I meant by "checks should be at one layer down".
Thanks,
Lijo
Quoted 635 lines
BR
EvanQuoted 633 lines
Thanks,
LijoQuoted 89 lines
BR
EvanQuoted 87 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-2mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 1 line
int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,@@
Quoted 1 line
-1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_pwm(struct
Quoted 10 lines
int ret = 0; if (!pp_funcs->set_fan_speed_pwm)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1065,6 +1073,9 @@ int amdgpu_dpm_get_fan_speed_pwm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1082,6 +1093,9 @@ int amdgpu_dpm_get_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_fan_speed_rpm(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1099,6 +1113,9 @@ int amdgpu_dpm_set_fan_speed_rpm(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1113,16 +1130,20 @@ intamdgpu_dpm_set_fan_control_mode(struct
amdgpu_device*adev,Quoted 23 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7
-3uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, - mode); + ret = pp_funcs->set_fan_control_mode (adev- powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 7 lines
int amdgpu_dpm_get_power_limit(struct
amdgpu_device*adev, diff
--gita/drivers/gpu/drm/amd/pm/amdgpu_pm.cb/drivers/gpu/drm/amd/pm/amdgpu_pm.c
indexd3eab245e0fe..940cbe751163100644drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3197,7 +3197,6 @@ static umode_thwmon_attributes_visible(struct
Quoted 95 lines
Quoted 95 lines
kobject *kobj,
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported
*/
Quoted 1 line
if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))@@
Quoted 1 line
-3263,15 +3262,15 @@ static
umode_thwmon_attributes_visible(structkobject *kobj,
Quoted 4 lines
return 0; /* mask fan attributes if we have no bindings for this asic toexpose
*/
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_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_get_fan_control_mode(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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) &&
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2
-0+ ((amdgpu_dpm_set_fan_control_mode (adev,U32_MAX ) == +-EOPNOTSUPP ) && 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 +3290,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 3293
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_set_fan_speed_pwm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP)) &&
drivers/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 3301
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((amdgpu_dpm_set_fan_speed_rpm(adev, U32_MAX) == -EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_dpm_set_fan_speed_pwm(void
Quoted 9 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 ;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void*handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0return 0 ; }Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void
Quoted 6 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-1-static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -6685,9 +6685,11 @@ static voidsi_dpm_set_fan_control_mode(void
Quoted 10 lines
Quoted 10 lines
*handle, u32 mode)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void si_dpm_set_fan_control_mode(void *handle, u32 mode)
Quoted 9 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; } -static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode(void *handle, u32
*fan_mode)Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type
Quoted 20 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4
-1{struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct si_power_info *si_pi = si_get_pi(adev); @@ -6697,7 +6699,9 @@ static u32 si_dpm_get_fan_control_mode(void *handle) return 0; tmp =RREG32 (CG_FDO_CTRL2 ) &FDO_PWM_MODE_MASK ; -return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0@@ -488,38 +488,37 @@ static enum amd_pm_state_type
pp_dpm_get_current_power_state(void *handle)Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1return pm_type; } -static void pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) +static int pp_dpm_set_fan_control_mode(void *handle, uint32_tmode)
Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3{struct pp_hwmgr *hwmgr = handle;if (!hwmgr || !hwmgr->pm_en) -return ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 15 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-4-return ; - }mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode (hwmgr, mode);mutex_unlock (&hwmgr->smu_lock); + +return 0 ; } -static uint32_t pp_dpm_get_fan_control_mode (void *handle) +static int pp_dpm_get_fan_control_mode (void *handle,uint32_t +*fan_mode) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3if (!hwmgr || !hwmgr->pm_en) -return 0 ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-4-return 0 ; - }mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); + *fan_mode = hwmgr->hwmgr_func-get_fan_control_mode (hwmgr);mutex_unlock (&hwmgr->smu_lock); -return mode; +return 0 ; }Quoted 3 lines
Quoted 3 lines
Quoted 1 line
static int
pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)@@
Quoted 1 line
-528,12 +527,11 @@ static int pp_dpm_set_fan_speed_pwm(void
*handle,
Quoted 34 lines
Quoted 34 lines
uint32_tspeed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed);mutex_unlock (&hwmgr->smu_lock);@@ -546,12 +544,10 @@ static int pp_dpm_get_fan_speed_pwm(void*handle,
uint32_t*speed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-3int ret =0 ;if (!hwmgr || !hwmgr->pm_en) -return -EINVAL ; +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return 0 ; - } +if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed) · line 553
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed);@@
Quoted 1 line
-565,10 +561,10 @@ static int pp_dpm_get_fan_speed_rpm(void
*handle,
Quoted 28 lines
Quoted 28 lines
uint32_t*rpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) · line 570
Quoted 12 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return -EINVAL ; +return -EOPNOTSUPP ;if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL ) -return -EINVAL ; +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm);@@ -582,12
Quoted 1 line
+578,11 @@ static int pp_dpm_set_fan_speed_rpm(void *handle,
uint32_trpm)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)
Quoted 11 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-3-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_handle_task(struct smu_context
Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm);mutex_unlock (&hwmgr->smu_lock);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -59,7 +59,7 @@ static int smu_handle_task(struct smu_context*smu,
Quoted 78 lines
Quoted 78 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1bool lock_needed);static int smu_reset (struct smu_context *smu);static int smu_set_fan_speed_pwm (void *handle,u32 speed); -static int smu_set_fan_control_mode (struct smu_context *smu,int value); +static int smu_set_fan_control_mode (void *handle,u32 value);static int smu_set_power_limit (void *handle,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg(struct
smu_context*smu, bool
enabled); @@ -407,7 +407,7 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)Quoted 1 line
if (smu->user_dpm_profile.fan_mode ==
AMD_FAN_CTRL_MANUAL||drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
smu->user_dpm_profile.fan_mode==AMD_FAN_CTRL_NONE) {
ret = smu_set_fan_control_mode(smu, smu-
user_dpm_profile.fan_mode);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) { +if (ret != -EOPNOTSUPP ) { smu->user_dpm_profile.fan_speed_pwm =0 ; smu->user_dpm_profile.fan_speed_rpm =0 ; smu->user_dpm_profile.fan_mode =
AMD_FAN_CTRL_AUTO; @@ -416,13Quoted 1 line
+416,13 @@ static void smu_restore_dpm_user_profile(struct
smu_contextdrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
*smu)
if (
smu->user_dpm_profile.fan_speed_pwm) {
ret = smu_set_fan_speed_pwm(smu, smu-
user_dpm_profile.fan_speed_pwm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in pwm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
} if (smu->user_dpm_profile.fan_speed_rpm) { ret = smu_set_fan_speed_rpm(smu, smu-user_dpm_profile.fan_speed_rpm);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed to setmanual fan speed in rpm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void
Quoted 3 lines
} }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2218,18 +2218,19 @@ static int smu_set_fan_speed_rpm(void*handle,
uint32_tspeed)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -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)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2226
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_rpm = speed; + ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2228
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_rpm = speed; -/* Override custom PWM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2230
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_pwm =0 ; - } +/* Override custom PWM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_pwm =0 ; }mutex_unlock (&smu->mutex);@@ -2562,60 +2563,59 @@ static intsmu_set_power_profile_mode(void
Quoted 60 lines
Quoted 60 lines
*handle,
Quoted 37 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +9
-8} -static u32 smu_get_fan_control_mode (void *handle) +static int smu_get_fan_control_mode (void *handle,u32 *fan_mode) {struct smu_context *smu = handle; -u32 ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return AMD_FAN_CTRL_NONE ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->get_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) - ret = smu->ppt_funcs->get_fan_control_mode (smu); + *fan_mode = smu->ppt_funcs->get_fan_control_mode (smu);mutex_unlock (&smu->mutex); -return ret; +return 0 ; } -static int smu_set_fan_control_mode (struct smu_context *smu,int value) +static int smu_set_fan_control_mode(void *handle, u32 value) { +struct smu_context *smu = handle;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return -EOPNOTSUPP ;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3+return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->set_fan_control_mode) +return -EOPNOTSUPP ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { - ret = smu->ppt_funcs->set_fan_control_mode (smu, value); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3- smu->user_dpm_profile.fan_mode = value; - } + ret = smu->ppt_funcs->set_fan_control_mode (smu, value); +if (ret) + goto out; -mutex_unlock (&smu->mutex); + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_mode = value;Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3-/* reset user dpm fan speed */ - if (!ret && value != AMD_FAN_CTRL_MANUAL && - !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3- smu->user_dpm_profile.fan_speed_pwm =0 ; - smu->user_dpm_profile.fan_speed_rpm =0 ; - smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0+/* reset user dpm fan speed */ +if (value !=AMD_FAN_CTRL_MANUAL ) { + smu->user_dpm_profile.fan_speed_pwm =0 ; + smu->user_dpm_profile.fan_speed_rpm =0 ; + smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);Quoted 99 lines
Quoted 99 lines
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-7+ } } -return ret; -} - -static void smu_pp_set_fan_control_mode(void *handle, u32 value) -{ -struct smu_context *smu = handle; +out: +mutex_unlock (&smu->mutex); -smu_set_fan_control_mode (smu, value); +return ret; } -static int smu_get_fan_speed_pwm (void *handle,u32 *speed) { struct smu_context *smu = handle; @@ -2624,10 +2624,12 @@ staticQuoted 1 line
int smu_get_fan_speed_pwm(void
*handle, u32 *speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void
Quoted 15 lines
if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) return -EOPNOTSUPP;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-2+if (!smu->ppt_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) - ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed);mutex_unlock (&smu->mutex);@@ -2642,18 +2644,19 @@ static int smu_set_fan_speed_pwm(void*handle, u32 speed)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { - ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); - if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2650
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1- smu->user_dpm_profile.fan_speed_pwm = speed; + ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_pwm = speed; -/* Override custom RPM setting as they cannot co- exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-2- smu->user_dpm_profile.fan_speed_rpm =0 ; - } +/* Override custom RPM setting as they cannot co-exist */ + smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_rpm(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_rpm =0 ; }mutex_unlock (&smu->mutex);@@ -2669,10 +2672,12 @@ static int smu_get_fan_speed_rpm(void*handle,
uint32_t*speed)Quoted 25 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-3if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; +if (!smu->ppt_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) - ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed); + ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed);mutex_unlock (&smu->mutex);@@ -3101,7 +3106,7 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)static const struct amd_pm_funcs swsmu_pm_funcs = {/* export for sysfs */ - .set_fan_control_mode = smu_pp_set_fan_control_mode, + .set_fan_control_mode = smu_set_fan_control_mode, .get_fan_control_mode = smu_get_fan_control_mode, .set_fan_speed_pwm = smu_set_fan_speed_pwm,.get_fan_speed_pwm =
smu_get_fan_speed_pwm,
[AMD Official Use Only]
Quoted 132 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 6:53 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 24 lines · Evan
[AMD Official Use Only]
Quoted 20 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 6:15 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[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: Tuesday, January 11, 2022 4:14 PM
To: Quan, Evan <[email protected]>; amd-Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Deucher, Alexander <[email protected]>; Chen,Guchun
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
<[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes supportQuoted 1 line · Evan Quan
On functionality unsupported,
-EOPNOTSUPPwill be returned. Andwe
Quoted 84 lines
Quoted 84 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
rely on that to determine the fan attributes support.
Fixes 801771de0331 ("drm/amd/pm: do not expose powerimplementation
Quoted 3 lines
details to
amdgpu_pm.c")Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Signed-off-by Evan Quan <[email protected]>Change-Id I95e7e0beebd678a446221a72234cd356e14f0fcd--- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 31 ++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 21 ++-- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 59 ++++----- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 115+++++++++----
Quoted 45 lines
Quoted 45 lines
-----
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 25 lines
6 files changed, 132 insertions(+), 108 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-2@@ -315,8 +315,8 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -void (*set_fan_control_mode)(void *handle,u32 mode); -u32 (*get_fan_control_mode)(void *handle); +int (*set_fan_control_mode)(void *handle,u32 mode); +int (*get_fan_control_mode)(void *handle,u32 *fan_mode);int (*set_fan_speed_pwm)(void *handle,u32 speed);int (*get_fan_speed_pwm)(void *handle,u32 *speed); int (*force_clock_level)(void *handle, enum pp_clock_typetype,
uint32_tmask); diff --gita/drivers/gpu/drm/amd/pm/amdgpu_dpm.cb/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index68d2e80a673b..fe69785df403100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1030,15 +1030,20 @@ intamdgpu_dpm_get_fan_control_mode(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_fan_control_mode(struct amdgpu_device *adev, · line 1040
Quoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0uint32_t *fan_mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;if (!pp_funcs->get_fan_control_mode)return -EOPNOTSUPP ; +if (!fan_mode) +return -EINVAL ; +
pp_funcsmost likely will be there for smu/powerplay subsystem. I think the checks should be at one layer down -smu_get_fan_control_mode()andpp_dpm_get_fan_control_mode()Quoted 4 lines
Quoted 2 lines
First one will check if ppt func is implemented and second one will check if hwmgr func is implemented for the specific ASIC.
[Quan, Evan] Yes, I agree. And if you go through the changes below, you
will see the checks (for the layers down) there.
Quoted 2 lines
This patch checks not only those
amdgpu_dpm_xxxxAPIs, but also thosedownstream
interfaces(smu_xxxx and pp_dpm_xxxx).Quoted 1 line
Say you call
amdgpu_dpm_get_fan_control_mode(adev, NULL)fromamdgpu_pm
pp_funcs->get_fan_control_mode=> this will point tosmu_get_fan_control_modefor all swsmu ASICs. So "if (!pp_funcs-Quoted 1 line
get_fan_control_mode)" will be false.The next statement is NULL check and it will return
-EINVAL.What we want to know is
ppt_funcis implemented or not for the particualr swsmu ASIC. Isn't that the case or am I reading it differently?
Quoted 6 lines
Quoted 2 lines
[Quan, Evan] OK, I get your point now. Hmm, that will be a little tricky. I suppose the EINVAL check needs to be dispatched in every
instance(pp_dpm_xxxxx, smu_xxxx, si_dpm_xxxx)then. Any better idea?Quoted 1 line
Yeah, that is what I meant by "checks should be at one layer down".
[Quan, Evan] OK, please check the updated V2.
BR
Evan
Quoted 696 lines
Thanks,
LijoQuoted 19 lines
BR
EvanQuoted 17 lines
Thanks,
LijoQuoted 14 lines
BR
EvanQuoted 12 lines
Thanks,
LijoQuoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-1mutex_lock (&adev->pm.mutex); - *fan_mode = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle); + ret = pp_funcs->get_fan_control_mode (adev- powerplay.pp_handle, + fan_mode);mutex_unlock (&adev->pm.mutex);Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1-return 0 ; +return ret;}
int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
@@
Quoted 1 line
-1048,6 +1053,9 @@ int amdgpu_dpm_set_fan_speed_pwm(struct
amdgpu_device*adev,Quoted 2 lines
int ret = 0;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 8 lines
if (!pp_funcs->set_fan_speed_pwm)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1065,6 +1073,9 @@ intamdgpu_dpm_get_fan_speed_pwm(struct
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1082,6 +1093,9 @@ intamdgpu_dpm_get_fan_speed_rpm(struct
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (!speed)return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1099,6 +1113,9 @@ intamdgpu_dpm_set_fan_speed_rpm(struct
Quoted 59 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0int ret =0 ;if (!pp_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; + +if (speed ==U32_MAX )return -EINVAL ;mutex_lock (&adev->pm.mutex);@@ -1113,16 +1130,20 @@ intamdgpu_dpm_set_fan_control_mode(struct
amdgpu_device*adev,Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-0uint32_t mode) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret =0 ;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_fan_control_mode(struct amdgpu_device *adev,
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-1if (!pp_funcs->set_fan_control_mode)return -EOPNOTSUPP ; +if (mode ==U32_MAX ) +return -EINVAL ; +mutex_lock (&adev->pm.mutex); - pp_funcs->set_fan_control_mode(adev-powerplay.pp_handle,
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-2- mode); + ret = pp_funcs->set_fan_control_mode (adev- powerplay.pp_handle, + mode);mutex_unlock (&adev->pm.mutex); -return 0 ; +return ret; }Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t
Quoted 7 lines
int amdgpu_dpm_get_power_limit(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -3197,7 +3197,6 @@ static umode_thwmon_attributes_visible(struct
Quoted 14 lines
Quoted 14 lines
kobject *kobj,
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1struct device *dev =kobj_to_dev (kobj);struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -uint32_t speed =0 ;/* under multi-vf mode, the hwmon attributes are all not supported
*/
Quoted 2 lines
if (amdgpu_sriov_vf(adev) &&!amdgpu_sriov_is_pp_one_vf(adev))
@@
Quoted 2 lines
-3263,15 +3262,15 @@ static
umode_t
hwmon_attributes_visible(structQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
kobject *kobj,
Quoted 4 lines
return 0; /* mask fan attributes if we have no bindings for this asicto 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 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_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_get_fan_control_mode(adev, NULL) == -EOPNOTSUPP) &&
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 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 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_set_fan_speed_pwm(adev, U32_MAX)== -
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
EOPNOTSUPP) &&
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 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 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_set_fan_control_mode(adev, U32_MAX)==
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+-EOPNOTSUPP) &&
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 +3290,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 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3293
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if (((amdgpu_dpm_set_fan_speed_pwm(adev, U32_MAX)== -
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_pwm(adev, NULL) == -EOPNOTSUPP) &&
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_set_fan_speed_rpm(adev, U32_MAX) ==-
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
EOPNOTSUPP) &&
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_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP)) &&
drivers/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 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
&&
drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3301
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1
-0+ if ((amdgpu_dpm_set_fan_speed_rpm(adev, U32_MAX) ==-
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
EOPNOTSUPP) &&
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+ (amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP) &&
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_dpm_set_fan_speed_pwm(void
Quoted 9 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 ;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -6669,7 +6669,7 @@ static int si_dpm_set_fan_speed_pwm(void*handle,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_dpm_set_fan_speed_pwm(void *handle,
Quoted 7 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-1return 0 ; } -static void si_dpm_set_fan_control_mode (void *handle,u32 mode) +static int si_dpm_set_fan_control_mode (void *handle,u32 mode) { struct amdgpu_device *adev = (struct amdgpu_device*)handle;
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void
Quoted 2 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -6685,9 +6685,11 @@ static voidsi_dpm_set_fan_control_mode(void
Quoted 8 lines
Quoted 8 lines
*handle, u32 mode)
Quoted 7 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +2
-0else si_fan_ctrl_set_default_mode (adev); } + +return 0 ; }Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static void · line 6692
Quoted 2 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-1-static u32 si_dpm_get_fan_control_mode (void *handle) +static int si_dpm_get_fan_control_mode(void *handle, u32
*fan_mode)Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0{ struct amdgpu_device *adev = (struct amdgpu_device*)handle;
Quoted 36 lines
Quoted 36 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type
Quoted 18 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4
-1struct si_power_info *si_pi = si_get_pi(adev); @@ -6697,7 +6699,9 @@ static u32 si_dpm_get_fan_control_mode(void *handle) return 0; tmp =RREG32 (CG_FDO_CTRL2 ) &FDO_PWM_MODE_MASK ; -return (tmp >>FDO_PWM_MODE_SHIFT ); + *fan_mode = (tmp >>FDO_PWM_MODE_SHIFT ); + +return 0 ; }#if 0 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-0@@ -488,38 +488,37 @@ static enum amd_pm_state_type
pp_dpm_get_current_power_state(void *handle)Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1return pm_type; } -static void pp_dpm_set_fan_control_mode (void *handle,uint32_t mode) +static int pp_dpm_set_fan_control_mode(void *handle, uint32_tmode)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-1{struct pp_hwmgr *hwmgr = handle;if (!hwmgr || !hwmgr->pm_en) -return ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) +return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type · line 500
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-if (hwmgr->hwmgr_func->set_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return ; - }mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode(hwmgr,mode);
Quoted 49 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +8
-3mutex_unlock (&hwmgr->smu_lock); + +return 0 ; } -static uint32_t pp_dpm_get_fan_control_mode (void *handle) +static int pp_dpm_get_fan_control_mode (void *handle,uint32_t +*fan_mode) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;if (!hwmgr || !hwmgr->pm_en) -return 0 ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) +return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type · line 517
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-if (hwmgr->hwmgr_func->get_fan_control_mode ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-3-return 0 ; - }mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func-
get_fan_control_mode(hwmgr);Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-1+ *fan_mode = hwmgr->hwmgr_func-get_fan_control_mode (hwmgr);mutex_unlock (&hwmgr->smu_lock); -return mode; +return 0 ; } static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_tspeed)
@@
Quoted 1 line
-528,12 +527,11 @@ static int pp_dpm_set_fan_speed_pwm(void
*handle,
Quoted 10 lines
Quoted 10 lines
uint32_tspeed)Quoted 9 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-1-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-if (hwmgr->hwmgr_func->set_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_pwm(hwmgr,speed);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
mutex_unlock(&hwmgr->smu_lock); @@ -546,12 +544,10@@ static
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
int pp_dpm_get_fan_speed_pwm(void
*handle,
uint32_t*speed)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)
Quoted 8 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-3-return -EINVAL ; +return -EOPNOTSUPP ; -if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-2-return 0 ; - } +if (hwmgr->hwmgr_func->get_fan_speed_pwm ==NULL ) +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_pwm(hwmgr,speed);
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
@@
Quoted 1 line
-565,10 +561,10 @@ static int pp_dpm_get_fan_speed_rpm(void
*handle,
Quoted 7 lines
Quoted 7 lines
uint32_t*rpm)Quoted 6 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1-return -EINVAL ; +return -EOPNOTSUPP ;Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)
Quoted 6 lines
if (hwmgr->hwmgr_func->get_fan_speed_rpm == NULL)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-1-return -EINVAL ; +return -EOPNOTSUPP ;mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->get_fan_speed_rpm(hwmgr,rpm);
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
@@ -582,12
Quoted 1 line
+578,11 @@ static int pp_dpm_set_fan_speed_rpm(void *handle,
uint32_trpm)Quoted 9 lines
int ret = 0; if (!hwmgr || !hwmgr->pm_en)drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +4
-1-return -EINVAL ; +return -EOPNOTSUPP ; + +if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) +return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-if (hwmgr->hwmgr_func->set_fan_speed_rpm ==NULL ) { - pr_info_ratelimited("%s was not implemented.\n",
__func__);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0
-2-return 0 ; - }mutex_lock (&hwmgr->smu_lock); ret = hwmgr->hwmgr_func->set_fan_speed_rpm(hwmgr,rpm);
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_handle_task(struct smu_context
Quoted 7 lines
mutex_unlock(&hwmgr->smu_lock); diff --git
a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.cb/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
indexc374c3067496..474f1f04cc96100644drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -59,7 +59,7 @@ static int smu_handle_task(struct smu_context*smu,
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1bool lock_needed);static int smu_reset (struct smu_context *smu);static int smu_set_fan_speed_pwm (void *handle,u32 speed); -static int smu_set_fan_control_mode (struct smu_context *smu,int value); +static int smu_set_fan_control_mode (void *handle,u32 value);static int smu_set_power_limit (void *handle,uint32_t limit);static int smu_set_fan_speed_rpm (void *handle,uint32_t speed);static int smu_set_gfx_cgpg(struct
smu_context*smu, bool
enabled); @@ -407,7 +407,7 @@ static void smu_restore_dpm_user_profile(struct
smu_context*smu)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
if (smu->user_dpm_profile.fan_mode ==
AMD_FAN_CTRL_MANUAL||Quoted 1 line
smu->user_dpm_profile.fan_mode ==
AMD_FAN_CTRL_NONE) {Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 5 lines
ret = smu_set_fan_control_mode(smu, smu-
user_dpm_profile.fan_mode);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) { +if (ret != -EOPNOTSUPP ) { smu->user_dpm_profile.fan_speed_pwm =0;
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
smu->user_dpm_profile.fan_speed_rpm = 0; smu->user_dpm_profile.fan_mode =
AMD_FAN_CTRL_AUTO; @@ -416,13Quoted 1 line
+416,13 @@ static void smu_restore_dpm_user_profile(struct
smu_contextQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
*smu)
if (
smu->user_dpm_profile.fan_speed_pwm) {
ret = smu_set_fan_speed_pwm(smu, smu-
user_dpm_profile.fan_speed_pwm);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed toset
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
manual fan speed in pwm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static void smu_restore_dpm_user_profile(struct smu_context *smu)
Quoted 8 lines
} if (smu->user_dpm_profile.fan_speed_rpm) { ret = smu_set_fan_speed_rpm(smu, smu-user_dpm_profile.fan_speed_rpm);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1-if (ret) +if (ret != -EOPNOTSUPP ) dev_err(smu->adev->dev, "Failed toset
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
manual fan speed in rpm\n");
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void
Quoted 3 lines
} }drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2218,18 +2218,19 @@ static int smu_set_fan_speed_rpm(void*handle,
uint32_tspeed)Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-2+if (!smu->ppt_funcs->set_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_rpm) { - ret = smu->ppt_funcs->set_fan_speed_rpm(smu,speed);
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2225
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2226
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2227
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.fan_speed_rpm =speed;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2227
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+ ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2228
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_RPM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_rpm = speed; -/* Override custom PWM setting as they cannot co-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2230
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2231
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.fan_speed_pwm =0;
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2231
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1- } +/* Override custom PWM setting as they cannot co- exist */
Quoted 52 lines
Quoted 25 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void · line 2232
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_PWM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_pwm =0 ; }mutex_unlock (&smu->mutex);@@ -2562,60 +2563,59 @@ static intsmu_set_power_profile_mode(void
Quoted 17 lines
Quoted 17 lines
*handle,
Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-3} -static u32 smu_get_fan_control_mode (void *handle) +static int smu_get_fan_control_mode (void *handle,u32 *fan_mode) {struct smu_context *smu = handle; -u32 ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return AMD_FAN_CTRL_NONE ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->get_fan_control_mode) +return -EOPNOTSUPP ;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-2mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) - ret = smu->ppt_funcs->get_fan_control_mode (smu); + *fan_mode = smu->ppt_funcs-
get_fan_control_mode(smu);Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7
-3mutex_unlock (&smu->mutex); -return ret; +return 0 ; } -static int smu_set_fan_control_mode (struct smu_context *smu,int value) +static int smu_set_fan_control_mode(void *handle, u32 value) { +struct smu_context *smu = handle;int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) -return -EOPNOTSUPP ; +return -EOPNOTSUPP ; + +if (!smu->ppt_funcs->set_fan_control_mode) +return -EOPNOTSUPP ;Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-2mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { - ret = smu->ppt_funcs->set_fan_control_mode(smu,value);
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int · line 2594
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE))drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3- smu->user_dpm_profile.fan_mode = value; - } + ret = smu->ppt_funcs->set_fan_control_mode (smu, value); +if (ret) + goto out; -mutex_unlock (&smu->mutex); + if (!(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-3+ smu->user_dpm_profile.fan_mode = value; -/* reset user dpm fan speed */ - if (!ret && value != AMD_FAN_CTRL_MANUAL && - !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-3- smu->user_dpm_profile.fan_speed_pwm =0 ; - smu->user_dpm_profile.fan_speed_rpm =0 ; - smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+/* reset user dpm fan speed */ +if (value !=AMD_FAN_CTRL_MANUAL ) { + smu->user_dpm_profile.fan_speed_pwm =0;
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int · line 2609
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+ smu->user_dpm_profile.fan_speed_rpm =0 ; + smu->user_dpm_profile.flags &=~(SMU_CUSTOM_FAN_SPEED_RPM |
SMU_CUSTOM_FAN_SPEED_PWM);Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle, · line 2611
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-4+ } } -return ret; -} - -static void smu_pp_set_fan_control_mode (void *handle,u32 value)-{
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1-struct smu_context *smu = handle; +out: +mutex_unlock (&smu->mutex);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-2-smu_set_fan_control_mode (smu, value); +return ret; } -static int smu_get_fan_speed_pwm (void *handle,u32 *speed) { struct smu_context *smu = handle; @@ -2624,10 +2624,12@@
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
static int smu_get_fan_speed_pwm(void
*handle, u32 *speed)
Quoted 3 lines
if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) return -EOPNOTSUPP;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_pwm(void *handle, u32 *speed)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-2+if (!smu->ppt_funcs->get_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) - ret = smu->ppt_funcs->get_fan_speed_pwm(smu,speed);
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed);mutex_unlock (&smu->mutex);@@ -2642,18 +2644,19 @@ static int smu_set_fan_speed_pwm(void*handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-2+if (!smu->ppt_funcs->set_fan_speed_pwm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { - ret = smu->ppt_funcs->set_fan_speed_pwm(smu,speed);
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2649
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2650
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2651
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.fan_speed_pwm =speed;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2653
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0+ ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed); + if (!ret && !(smu->user_dpm_profile.flags &
SMU_DPM_USER_PROFILE_RESTORE)) {drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags |=
SMU_CUSTOM_FAN_SPEED_PWM;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void *handle, u32 speed)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+ smu->user_dpm_profile.fan_speed_pwm = speed; -/* Override custom RPM setting as they cannot co-
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
exist */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2654
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1- smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_power_profile_mode(void *handle,
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-2- smu->user_dpm_profile.fan_speed_rpm =0 ; - } +/* Override custom RPM setting as they cannot co- exist */
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_pwm(void · line 2658
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.flags &=~SMU_CUSTOM_FAN_SPEED_RPM;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_rpm(void
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ smu->user_dpm_profile.fan_speed_rpm =0 ; }mutex_unlock (&smu->mutex);@@ -2669,10 +2672,12 @@ static int smu_get_fan_speed_rpm(void*handle,
uint32_t*speed)Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_get_fan_speed_rpm(void *handle, uint32_t *speed)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-2+if (!smu->ppt_funcs->get_fan_speed_rpm) +return -EOPNOTSUPP ; +mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) - ret = smu->ppt_funcs->get_fan_speed_rpm(smu,speed);
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1+ ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed);mutex_unlock (&smu->mutex);@@ -3101,7 +3106,7 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size)static const struct amd_pm_funcs swsmu_pm_funcs = {/* export for sysfs */ - .set_fan_control_mode = smu_pp_set_fan_control_mode, + .set_fan_control_mode = smu_set_fan_control_mode, .get_fan_control_mode = smu_get_fan_control_mode, .set_fan_speed_pwm = smu_set_fan_speed_pwm,.get_fan_speed_pwm =
smu_get_fan_speed_pwm,