aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom St Denis <tom.stdenis@amd.com>2016-09-15 10:08:44 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-09-19 14:38:26 -0400
commitf2cdaf20664525227f721ac3a4c72ee8ef4b37b8 (patch)
treed4e48841d4b83d120eadfe8289a1126202f9929b
parenta6e3695221446cf825d12db9c6ad3502c45fb9de (diff)
drm/amd/amdgpu: Hook up read_sensor() to debugfs (v2)
(v2) Tidy'ed up read function. Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 377d81875c6d..490f04f0efe8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2771,6 +2771,29 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
2771 return result; 2771 return result;
2772} 2772}
2773 2773
2774static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf,
2775 size_t size, loff_t *pos)
2776{
2777 struct amdgpu_device *adev = f->f_inode->i_private;
2778 int idx, r;
2779 int32_t value;
2780
2781 if (size != 4 || *pos & 0x3)
2782 return -EINVAL;
2783
2784 /* convert offset to sensor number */
2785 idx = *pos >> 2;
2786
2787 if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->read_sensor)
2788 r = adev->powerplay.pp_funcs->read_sensor(adev->powerplay.pp_handle, idx, &value);
2789 else
2790 return -EINVAL;
2791
2792 if (!r)
2793 r = put_user(value, (int32_t *)buf);
2794
2795 return !r ? 4 : r;
2796}
2774 2797
2775static const struct file_operations amdgpu_debugfs_regs_fops = { 2798static const struct file_operations amdgpu_debugfs_regs_fops = {
2776 .owner = THIS_MODULE, 2799 .owner = THIS_MODULE,
@@ -2803,12 +2826,19 @@ static const struct file_operations amdgpu_debugfs_gca_config_fops = {
2803 .llseek = default_llseek 2826 .llseek = default_llseek
2804}; 2827};
2805 2828
2829static const struct file_operations amdgpu_debugfs_sensors_fops = {
2830 .owner = THIS_MODULE,
2831 .read = amdgpu_debugfs_sensor_read,
2832 .llseek = default_llseek
2833};
2834
2806static const struct file_operations *debugfs_regs[] = { 2835static const struct file_operations *debugfs_regs[] = {
2807 &amdgpu_debugfs_regs_fops, 2836 &amdgpu_debugfs_regs_fops,
2808 &amdgpu_debugfs_regs_didt_fops, 2837 &amdgpu_debugfs_regs_didt_fops,
2809 &amdgpu_debugfs_regs_pcie_fops, 2838 &amdgpu_debugfs_regs_pcie_fops,
2810 &amdgpu_debugfs_regs_smc_fops, 2839 &amdgpu_debugfs_regs_smc_fops,
2811 &amdgpu_debugfs_gca_config_fops, 2840 &amdgpu_debugfs_gca_config_fops,
2841 &amdgpu_debugfs_sensors_fops,
2812}; 2842};
2813 2843
2814static const char *debugfs_regs_names[] = { 2844static const char *debugfs_regs_names[] = {
@@ -2817,6 +2847,7 @@ static const char *debugfs_regs_names[] = {
2817 "amdgpu_regs_pcie", 2847 "amdgpu_regs_pcie",
2818 "amdgpu_regs_smc", 2848 "amdgpu_regs_smc",
2819 "amdgpu_gca_config", 2849 "amdgpu_gca_config",
2850 "amdgpu_sensors",
2820}; 2851};
2821 2852
2822static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) 2853static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)