diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3281-drm-amdgpu-pm-report-gpu-voltages-via-hwmon-API.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3281-drm-amdgpu-pm-report-gpu-voltages-via-hwmon-API.patch | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3281-drm-amdgpu-pm-report-gpu-voltages-via-hwmon-API.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3281-drm-amdgpu-pm-report-gpu-voltages-via-hwmon-API.patch new file mode 100644 index 00000000..9857f86d --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3281-drm-amdgpu-pm-report-gpu-voltages-via-hwmon-API.patch @@ -0,0 +1,123 @@ +From 70dcf4d6e5c9e6bf72c7768051279c911b166a34 Mon Sep 17 00:00:00 2001 +From: Alex Deucher <alexander.deucher@amd.com> +Date: Wed, 24 Jan 2018 17:19:33 -0500 +Subject: [PATCH 3281/4131] drm/amdgpu/pm: report gpu voltages via hwmon API + +Expose vddgfx and vddnb via hwmon. + +Reviewed-by: Rex Zhu <Rex.Zhu@amd.com> +Signed-off-by: Alex Deucher <alexander.deucher@amd.com> +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 82 ++++++++++++++++++++++++++++++++++ + 1 file changed, 82 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +index 773a915..674aeac 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +@@ -1094,6 +1094,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); +@@ -1102,6 +1176,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, +@@ -1112,6 +1190,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 + }; + +-- +2.7.4 + |