diff options
author | Thomas Fleury <tfleury@nvidia.com> | 2016-10-21 19:43:39 -0400 |
---|---|---|
committer | Deepak Nibade <dnibade@nvidia.com> | 2016-12-27 04:56:52 -0500 |
commit | 849c5317e8509b390da626bcb607e66cc5ef847f (patch) | |
tree | a50207bd32926991b1a482dd1de5a24c1d44b97f /drivers/gpu/nvgpu/gp106 | |
parent | 5ab254c6e84d741f56e9bcc93512f82eb7ce518c (diff) |
gpu: nvgpu: get voltage, current, power and temperature
Add ioctls to retrieve voltage, current, power and temperature.
Add flags in GPU characteristics to indicate if feature is supported.
Jira DNVGPU-166
Change-Id: Ifaafe2efdb6b09d7b28215b641814f28e894151e
Signed-off-by: David Martinez Nieto <dmartineznie@nvidia.com>
Reviewed-on: http://git-master/r/1241861
Tested-by: Thomas Fleury <tfleury@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-on: http://git-master/r/1267122
Diffstat (limited to 'drivers/gpu/nvgpu/gp106')
-rw-r--r-- | drivers/gpu/nvgpu/gp106/hal_gp106.c | 20 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gp106/therm_gp106.c | 21 |
2 files changed, 36 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index dc27cdae..ee361953 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c | |||
@@ -187,6 +187,24 @@ static int gp106_get_litter_value(struct gk20a *g, int value) | |||
187 | return ret; | 187 | return ret; |
188 | } | 188 | } |
189 | 189 | ||
190 | int gp106_init_gpu_characteristics(struct gk20a *g) | ||
191 | { | ||
192 | struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics; | ||
193 | |||
194 | int err; | ||
195 | |||
196 | err = gk20a_init_gpu_characteristics(g); | ||
197 | if (err) | ||
198 | return err; | ||
199 | |||
200 | gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_GET_VOLTAGE | | ||
201 | NVGPU_GPU_FLAGS_SUPPORT_GET_CURRENT | | ||
202 | NVGPU_GPU_FLAGS_SUPPORT_GET_POWER | | ||
203 | NVGPU_GPU_FLAGS_SUPPORT_GET_TEMPERATURE; | ||
204 | |||
205 | return 0; | ||
206 | } | ||
207 | |||
190 | int gp106_init_hal(struct gk20a *g) | 208 | int gp106_init_hal(struct gk20a *g) |
191 | { | 209 | { |
192 | struct gpu_ops *gops = &g->ops; | 210 | struct gpu_ops *gops = &g->ops; |
@@ -224,7 +242,7 @@ int gp106_init_hal(struct gk20a *g) | |||
224 | 242 | ||
225 | gops->name = "gp10x"; | 243 | gops->name = "gp10x"; |
226 | gops->get_litter_value = gp106_get_litter_value; | 244 | gops->get_litter_value = gp106_get_litter_value; |
227 | gops->chip_init_gpu_characteristics = gk20a_init_gpu_characteristics; | 245 | gops->chip_init_gpu_characteristics = gp106_init_gpu_characteristics; |
228 | gops->gr_ctx.use_dma_for_fw_bootstrap = true; | 246 | gops->gr_ctx.use_dma_for_fw_bootstrap = true; |
229 | gops->read_ptimer = gk20a_read_ptimer; | 247 | gops->read_ptimer = gk20a_read_ptimer; |
230 | 248 | ||
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.c b/drivers/gpu/nvgpu/gp106/therm_gp106.c index a3aa3636..15aff89c 100644 --- a/drivers/gpu/nvgpu/gp106/therm_gp106.c +++ b/drivers/gpu/nvgpu/gp106/therm_gp106.c | |||
@@ -15,10 +15,8 @@ | |||
15 | #include <linux/debugfs.h> | 15 | #include <linux/debugfs.h> |
16 | #include "hw_therm_gp106.h" | 16 | #include "hw_therm_gp106.h" |
17 | 17 | ||
18 | #ifdef CONFIG_DEBUG_FS | 18 | static int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8) |
19 | static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) | ||
20 | { | 19 | { |
21 | struct gk20a *g = (struct gk20a *)data; | ||
22 | int err = 0; | 20 | int err = 0; |
23 | u32 readval; | 21 | u32 readval; |
24 | 22 | ||
@@ -38,7 +36,21 @@ static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) | |||
38 | // Convert from F9.5 -> F27.5 -> F24.8. | 36 | // Convert from F9.5 -> F27.5 -> F24.8. |
39 | readval &= therm_temp_sensor_tsense_fixed_point_m(); | 37 | readval &= therm_temp_sensor_tsense_fixed_point_m(); |
40 | 38 | ||
41 | *val = readval; | 39 | *temp_f24_8 = readval; |
40 | |||
41 | return err; | ||
42 | } | ||
43 | |||
44 | #ifdef CONFIG_DEBUG_FS | ||
45 | static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) | ||
46 | { | ||
47 | struct gk20a *g = (struct gk20a *)data; | ||
48 | u32 readval; | ||
49 | int err; | ||
50 | |||
51 | err = gp106_get_internal_sensor_curr_temp(g, &readval); | ||
52 | if (!err) | ||
53 | *val = readval; | ||
42 | 54 | ||
43 | return err; | 55 | return err; |
44 | } | 56 | } |
@@ -104,4 +116,5 @@ void gp106_init_therm_ops(struct gpu_ops *gops) { | |||
104 | gops->therm.therm_debugfs_init = gp106_therm_debugfs_init; | 116 | gops->therm.therm_debugfs_init = gp106_therm_debugfs_init; |
105 | #endif | 117 | #endif |
106 | gops->therm.elcg_init_idle_filters = gp106_elcg_init_idle_filters; | 118 | gops->therm.elcg_init_idle_filters = gp106_elcg_init_idle_filters; |
119 | gops->therm.get_internal_sensor_curr_temp = gp106_get_internal_sensor_curr_temp; | ||
107 | } | 120 | } |