drm/amdgpu/pm: handle fan properly when card is powered down
Subsystems (2)
PATCH 1/6 drm/amdgpu/pm: handle fan properly when card is powered down
Return an error if the user tried to check or set the fan parameters while the card is powered down (e.g., on a PX/HG system for example). This makes the fan consistent with the temperature stuff.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +20 -0
@@ -991,6 +991,11 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,int err;int value; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; +if (!adev->powerplay.pp_funcs->set_fan_control_mode)return -EINVAL ;
@@ -1025,6 +1030,11 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,int err;u32 value; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + err =kstrtou32 (buf,10 , &value);if (err)return err;
@@ -1048,6 +1058,11 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,int err;u32 speed =0 ; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; +if (adev->powerplay.pp_funcs->get_fan_speed_percent) { err =amdgpu_dpm_get_fan_speed_percent (adev, &speed);if (err)
@@ -1067,6 +1082,11 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,int err;u32 speed =0 ; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; +if (adev->powerplay.pp_funcs->get_fan_speed_rpm) { err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);if (err)
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180124235536.3065-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/6 drm/amdgpu/pm: report gpu voltages via hwmon API
Expose vddgfx and vddnb via hwmon.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +82 -0
@@ -1096,6 +1096,80 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,return sprintf (buf,"%i\n" , speed); } +static ssize_t amdgpu_hwmon_show_vddgfx (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct amdgpu_device *adev =dev_get_drvdata (dev); +struct drm_device *ddev = adev->ddev; +u32 vddgfx; +int r, size =sizeof (vddgfx); + +/* Can't get voltage when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the voltage */ + r =amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_VDDGFX , + (void *)&vddgfx, &size); +if (r) +return r; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , vddgfx); +} + +static ssize_t amdgpu_hwmon_show_vddgfx_label (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +return snprintf (buf,PAGE_SIZE ,"vddgfx\n" ); +} + +static ssize_t amdgpu_hwmon_show_vddnb (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct amdgpu_device *adev =dev_get_drvdata (dev); +struct drm_device *ddev = adev->ddev; +u32 vddnb; +int r, size =sizeof (vddnb); + +/* only APUs have vddnb */ +if (adev->flags &AMD_IS_APU ) +return -EINVAL ; + +/* Can't get voltage when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the voltage */ + r =amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_VDDNB , + (void *)&vddnb, &size); +if (r) +return r; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , vddnb); +} + +static ssize_t amdgpu_hwmon_show_vddnb_label (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +return snprintf (buf,PAGE_SIZE ,"vddnb\n" ); +} + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
@@ -1104,6 +1178,10 @@ static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_ static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0); +static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0); +static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0); +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0); +static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, amdgpu_hwmon_show_vddnb_label, NULL, 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1114,6 +1192,10 @@ static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_pwm1_min.dev_attr.attr, &sensor_dev_attr_pwm1_max.dev_attr.attr, &sensor_dev_attr_fan1_input.dev_attr.attr, + &sensor_dev_attr_in0_input.dev_attr.attr, + &sensor_dev_attr_in0_label.dev_attr.attr, + &sensor_dev_attr_in1_input.dev_attr.attr, + &sensor_dev_attr_in1_label.dev_attr.attr, NULL };
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/6 drm/amdgpu/pm: report gpu average power via hwmon API
In reply to a message not in the archiveExpose power via hwmon.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +34 -0
@@ -1170,6 +1170,38 @@ static ssize_t amdgpu_hwmon_show_vddnb_label(struct device *dev,return snprintf (buf,PAGE_SIZE ,"vddnb\n" ); } +static ssize_t amdgpu_hwmon_show_power_avg (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct amdgpu_device *adev =dev_get_drvdata (dev); +struct drm_device *ddev = adev->ddev; +struct pp_gpu_power query = {0 }; +int r, size =sizeof (query); +unsigned uw; + +/* Can't get power when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the voltage */ + r =amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_POWER , + (void *)&query, &size); +if (r) +return r; + +/* convert to microwatts */ + uw = (query.average_gpu_power >>8 ) *1000000 ; + +return snprintf (buf,PAGE_SIZE ,"%u\n" , uw); +} + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
@@ -1182,6 +1214,7 @@ static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0) static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0); static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0); static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, amdgpu_hwmon_show_vddnb_label, NULL, 0); +static SENSOR_DEVICE_ATTR(power1_average, S_IRUGO, amdgpu_hwmon_show_power_avg, NULL, 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1196,6 +1229,7 @@ static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_in0_label.dev_attr.attr, &sensor_dev_attr_in1_input.dev_attr.attr, &sensor_dev_attr_in1_label.dev_attr.attr, + &sensor_dev_attr_power1_average.dev_attr.attr, NULL };
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/6 drm/amdgpu/pm: use read_sensor API to get temperature
In reply to a message not in the archiveRather than using the amdgpu_dpm_get_temperature. Both provide access to the temperature.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +16 -8
@@ -936,17 +936,23 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev, {struct amdgpu_device *adev =dev_get_drvdata (dev);struct drm_device *ddev = adev->ddev; -int temp; +int r, temp, size =sizeof (temp);/* Can't get temperature when the card is off */ if ((adev->flags &AMD_IS_PX ) && (ddev->switch_power_state !=DRM_SWITCH_POWER_ON ))return -EINVAL ; -if (!adev->powerplay.pp_funcs->get_temperature) - temp =0 ; -else - temp =amdgpu_dpm_get_temperature (adev); +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the temperature */ + r =amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&temp, &size); +if (r) +return r;return snprintf (buf,PAGE_SIZE ,"%d\n" , temp); }
@@ -1306,13 +1312,15 @@ void amdgpu_dpm_thermal_work_handler(struct work_struct *work) pm.dpm.thermal.work);/* switch to the thermal state */ enum amd_pm_state_type dpm_state =POWER_STATE_TYPE_INTERNAL_THERMAL ; +int temp, size =sizeof (temp);if (!adev->pm.dpm_enabled)return ; -if (adev->powerplay.pp_funcs->get_temperature) { -int temp =amdgpu_dpm_get_temperature (adev); - +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor && + !amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&temp, &size)) {if (temp < adev->pm.dpm.thermal.min_temp)/* switch back the user state */ dpm_state = adev->pm.dpm.user_state;
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/6 drm/amdgpu/pp: remove the get_temperature API
In reply to a message not in the archiveThis is also supported with the read_sensor API and there were no more users of the get_temperature API.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 3 --- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 3 --- drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 1 - drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 1 - drivers/gpu/drm/amd/amdgpu/si_dpm.c | 1 - drivers/gpu/drm/amd/include/kgd_pp_interface.h | 1 - drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 24 ---------------------- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 1 - drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 1 - drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 1 - drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 - 11 files changed, 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +0 -3
@@ -265,9 +265,6 @@ enum amdgpu_pcie_gen {#define amdgpu_dpm_read_sensor (adev, idx, value, size) \ ((adev)->powerplay.pp_funcs->read_sensor((adev)->powerplay.pp_handle, (idx), (value), (size))) -#define amdgpu_dpm_get_temperature (adev) \ - ((adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle)) -#define amdgpu_dpm_set_fan_control_mode (adev, m) \ ((adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)))
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0 -3
@@ -1620,9 +1620,6 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)if (adev->pm.dpm_enabled ==0 )return 0 ; -if (adev->powerplay.pp_funcs->get_temperature ==NULL ) -return 0 ; - adev->pm.int_hwmon_dev =hwmon_device_register_with_groups (adev->dev,DRIVER_NAME , adev, hwmon_groups);
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +0 -1
@@ -7029,7 +7029,6 @@ const struct amd_ip_funcs ci_dpm_ip_funcs = { };const struct amd_pm_funcs ci_dpm_funcs = { - .get_temperature = &ci_dpm_get_temp, .pre_set_power_state = &ci_dpm_pre_set_power_state, .set_power_state = &ci_dpm_set_power_state, .post_set_power_state = &ci_dpm_post_set_power_state,
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +0 -1
@@ -3319,7 +3319,6 @@ const struct amd_ip_funcs kv_dpm_ip_funcs = { };const struct amd_pm_funcs kv_dpm_funcs = { - .get_temperature = &kv_dpm_get_temp, .pre_set_power_state = &kv_dpm_pre_set_power_state, .set_power_state = &kv_dpm_set_power_state, .post_set_power_state = &kv_dpm_post_set_power_state,
drivers/gpu/drm/amd/amdgpu/si_dpm.c +0 -1
@@ -8056,7 +8056,6 @@ const struct amd_ip_funcs si_dpm_ip_funcs = { };const struct amd_pm_funcs si_dpm_funcs = { - .get_temperature = &si_dpm_get_temp, .pre_set_power_state = &si_dpm_pre_set_power_state, .set_power_state = &si_dpm_set_power_state, .post_set_power_state = &si_dpm_post_set_power_state,
drivers/gpu/drm/amd/include/kgd_pp_interface.h +0 -1
@@ -241,7 +241,6 @@ struct amd_pm_funcs {void *rps, bool *equal);/* export for sysfs */ -int (*get_temperature)(void *handle);void (*set_fan_control_mode)(void *handle,u32 mode);u32 (*get_fan_control_mode)(void *handle);int (*set_fan_speed_percent)(void *handle,u32 speed);
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0 -24
@@ -687,29 +687,6 @@ static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm)return ret; } -static int pp_dpm_get_temperature (void *handle) -{ -struct pp_hwmgr *hwmgr; -struct pp_instance *pp_handle = (struct pp_instance *)handle; -int ret =0 ; - - ret =pp_check (pp_handle); - -if (ret) -return ret; - - hwmgr = pp_handle->hwmgr; - -if (hwmgr->hwmgr_func->get_temperature ==NULL ) { -pr_info ("%s was not implemented.\n" , __func__); -return 0 ; - } -mutex_lock (&pp_handle->pp_lock); - ret = hwmgr->hwmgr_func->get_temperature (hwmgr); -mutex_unlock (&pp_handle->pp_lock); -return ret; -} -static int pp_dpm_get_pp_num_states (void *handle,struct pp_states_info *data) {
@@ -1492,7 +1469,6 @@ static int pp_get_display_mode_validation_clocks(void *handle, }const struct amd_pm_funcs pp_dpm_funcs = { - .get_temperature = pp_dpm_get_temperature, .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, .force_performance_level = pp_dpm_force_performance_level,
drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +0 -1
@@ -1907,7 +1907,6 @@ static const struct pp_hwmgr_func cz_hwmgr_funcs = { .get_current_shallow_sleep_clocks = cz_get_current_shallow_sleep_clocks, .get_clock_by_type = cz_get_clock_by_type, .get_max_high_clocks = cz_get_max_high_clocks, - .get_temperature = cz_thermal_get_temperature, .read_sensor = cz_read_sensor, .power_off_asic = cz_power_off_asic, .asic_setup = cz_setup_asic_task,
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +0 -1
@@ -4958,7 +4958,6 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = { .display_config_changed = smu7_display_configuration_changed_task, .set_max_fan_pwm_output = smu7_set_max_fan_pwm_output, .set_max_fan_rpm_output = smu7_set_max_fan_rpm_output, - .get_temperature = smu7_thermal_get_temperature, .stop_thermal_controller = smu7_thermal_stop_thermal_controller, .get_fan_speed_info = smu7_fan_ctrl_get_fan_speed_info, .get_fan_speed_percent = smu7_fan_ctrl_get_fan_speed_percent,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -1
@@ -5120,7 +5120,6 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = { .notify_smc_display_config_after_ps_adjustment = vega10_notify_smc_display_config_after_ps_adjustment, .force_dpm_level = vega10_dpm_force_dpm_level, - .get_temperature = vega10_thermal_get_temperature, .stop_thermal_controller = vega10_thermal_stop_thermal_controller, .get_fan_speed_info = vega10_fan_ctrl_get_fan_speed_info, .get_fan_speed_percent = vega10_fan_ctrl_get_fan_speed_percent,
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -1
@@ -279,7 +279,6 @@ struct pp_hwmgr_func { const uint32_t *msg_id);int (*set_max_fan_rpm_output)(struct pp_hwmgr *hwmgr,uint16_t us_max_fan_pwm);int (*set_max_fan_pwm_output)(struct pp_hwmgr *hwmgr,uint16_t us_max_fan_pwm); -int (*get_temperature)(struct pp_hwmgr *hwmgr);int (*stop_thermal_controller)(struct pp_hwmgr *hwmgr);int (*get_fan_speed_info)(struct pp_hwmgr *hwmgr,struct phm_fan_speed_info *fan_speed_info);void (*set_fan_control_mode)(struct pp_hwmgr *hwmgr,uint32_t mode);
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/6 drm/amdgpu/pm: rework the hwmon visibility settings
In reply to a message not in the archivePreviously we just always exposed everything for asics supported by powerplay. Make it a bit more fine grained. In practice this shouldn't change anything.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17 -13
@@ -1246,9 +1246,19 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -/* no skipping for powerplay */ -if (adev->powerplay.cgs_device) -return effective_mode; +/* handle non-powerplay limitations */ +if (!adev->powerplay.cgs_device) { +/* Skip fan attributes if fan is not present */ +if (adev->pm.no_fan && + (attr == &sensor_dev_attr_pwm1.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) +return 0 ; +/* requires powerplay */ +if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr) +return 0 ; + }/* Skip limit attributes if DPM is not enabled */ if (!adev->pm.dpm_enabled &&
@@ -1260,14 +1270,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; -/* Skip fan attributes if fan is not present */ -if (adev->pm.no_fan && - (attr == &sensor_dev_attr_pwm1.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) -return 0 ; -/* mask fan attributes if we have no bindings for this asic to expose */ if ((!adev->powerplay.pp_funcs->get_fan_speed_percent && attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
@@ -1288,8 +1290,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; -/* requires powerplay */ -if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr) +/* only APUs have vddnb */ +if (!(adev->flags &AMD_IS_APU ) && + (attr == &sensor_dev_attr_in1_input.dev_attr.attr || + attr == &sensor_dev_attr_in1_label.dev_attr.attr))return 0 ;return effective_mode;
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180124235536.3065-6-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 6/6] drm/amdgpu/pm: rework the hwmon visibility settings
Series is Reviewed-by: Rex Zhu <[email protected]>
Best Regards
Rex
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Alex Deucher <[email protected]>
Sent: Thursday, January 25, 2018 7:55 AM
To: [email protected]
Cc: Deucher, Alexander
Subject: [PATCH 6/6] drm/amdgpu/pm: rework the hwmon visibility settings
Previously we just always exposed everything for asics supported by powerplay. Make it a bit more fine grained. In practice this shouldn't change anything.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +17 -13
@@ -1246,9 +1246,19 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,struct amdgpu_device *adev =dev_get_drvdata (dev);umode_t effective_mode = attr->mode; -/* no skipping for powerplay */ -if (adev->powerplay.cgs_device) -return effective_mode; +/* handle non-powerplay limitations */ +if (!adev->powerplay.cgs_device) { +/* Skip fan attributes if fan is not present */ +if (adev->pm.no_fan && + (attr == &sensor_dev_attr_pwm1.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) +return 0 ; +/* requires powerplay */ +if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr) +return 0 ; + }/* Skip limit attributes if DPM is not enabled */ if (!adev->pm.dpm_enabled &&
@@ -1260,14 +1270,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; -/* Skip fan attributes if fan is not present */ -if (adev->pm.no_fan && - (attr == &sensor_dev_attr_pwm1.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) -return 0 ; -/* mask fan attributes if we have no bindings for this asic to expose */ if ((!adev->powerplay.pp_funcs->get_fan_speed_percent && attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
@@ -1288,8 +1290,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; -/* requires powerplay */ -if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr) +/* only APUs have vddnb */ +if (!(adev->flags &AMD_IS_APU ) && + (attr == &sensor_dev_attr_in1_input.dev_attr.attr || + attr == &sensor_dev_attr_in1_label.dev_attr.attr))return 0 ;return effective_mode;
--
2.13.6
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of ...
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
Acked-byAm 25.01.2018 um 00:55 schrieb Alex Deucher:
Quoted 6 lines
Return an error if the user tried to check or set the fan parameters while the card is powered down (e.g., on a PX/HG system for example). This makes the fan consistent with the temperature stuff.
Signed-off-by Alex Deucher <[email protected]>
Quoted 46 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +15
-0@@ -991,6 +991,11 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,int err;int value; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; +if (!adev->powerplay.pp_funcs->set_fan_control_mode)return -EINVAL ;@@ -1025,6 +1030,11 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,int err;u32 value; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + err =kstrtou32 (buf,10 , &value);if (err)return err;@@ -1048,6 +1058,11 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,int err;u32 speed =0 ; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; +if (adev->powerplay.pp_funcs->get_fan_speed_percent) { err =amdgpu_dpm_get_fan_speed_percent (adev, &speed);if (err)@@ -1067,6 +1082,11 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,int err;
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, · line 1092
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +5
-0u32 speed =0 ; +/* Can't adjust fan when the card is off */ +if ((adev->flags &AMD_IS_PX ) && + (adev->ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; +if (adev->powerplay.pp_funcs->get_fan_speed_rpm) { err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);if (err)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx