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/pmgr | |
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/pmgr')
-rw-r--r-- | drivers/gpu/nvgpu/pmgr/pmgr.c | 53 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/pmgr/pmgr.h | 3 |
2 files changed, 46 insertions, 10 deletions
diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.c b/drivers/gpu/nvgpu/pmgr/pmgr.c index f625e37d..e101aba8 100644 --- a/drivers/gpu/nvgpu/pmgr/pmgr.c +++ b/drivers/gpu/nvgpu/pmgr/pmgr.c | |||
@@ -16,12 +16,10 @@ | |||
16 | #include "pmgrpmu.h" | 16 | #include "pmgrpmu.h" |
17 | #include <linux/debugfs.h> | 17 | #include <linux/debugfs.h> |
18 | 18 | ||
19 | #ifdef CONFIG_DEBUG_FS | 19 | int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val) |
20 | static int pmgr_pwr_devices_get_current_power(void *data, u64 *val) | ||
21 | { | 20 | { |
22 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; | 21 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; |
23 | int status; | 22 | int status; |
24 | struct gk20a *g = (struct gk20a *)data; | ||
25 | 23 | ||
26 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); | 24 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); |
27 | if (status) | 25 | if (status) |
@@ -34,11 +32,10 @@ static int pmgr_pwr_devices_get_current_power(void *data, u64 *val) | |||
34 | return status; | 32 | return status; |
35 | } | 33 | } |
36 | 34 | ||
37 | static int pmgr_pwr_devices_get_current(void *data, u64 *val) | 35 | int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val) |
38 | { | 36 | { |
39 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; | 37 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; |
40 | int status; | 38 | int status; |
41 | struct gk20a *g = (struct gk20a *)data; | ||
42 | 39 | ||
43 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); | 40 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); |
44 | if (status) | 41 | if (status) |
@@ -51,11 +48,10 @@ static int pmgr_pwr_devices_get_current(void *data, u64 *val) | |||
51 | return status; | 48 | return status; |
52 | } | 49 | } |
53 | 50 | ||
54 | static int pmgr_pwr_devices_get_current_voltage(void *data, u64 *val) | 51 | int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val) |
55 | { | 52 | { |
56 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; | 53 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; |
57 | int status; | 54 | int status; |
58 | struct gk20a *g = (struct gk20a *)data; | ||
59 | 55 | ||
60 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); | 56 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); |
61 | if (status) | 57 | if (status) |
@@ -68,14 +64,51 @@ static int pmgr_pwr_devices_get_current_voltage(void *data, u64 *val) | |||
68 | return status; | 64 | return status; |
69 | } | 65 | } |
70 | 66 | ||
67 | #ifdef CONFIG_DEBUG_FS | ||
68 | int pmgr_pwr_devices_get_power_u64(void *data, u64 *p) | ||
69 | { | ||
70 | struct gk20a *g = (struct gk20a *)data; | ||
71 | int err; | ||
72 | u32 val; | ||
73 | |||
74 | err = pmgr_pwr_devices_get_power(g, &val); | ||
75 | *p = val; | ||
76 | |||
77 | return err; | ||
78 | } | ||
79 | |||
80 | int pmgr_pwr_devices_get_current_u64(void *data, u64 *p) | ||
81 | { | ||
82 | struct gk20a *g = (struct gk20a *)data; | ||
83 | int err; | ||
84 | u32 val; | ||
85 | |||
86 | err = pmgr_pwr_devices_get_current(g, &val); | ||
87 | *p = val; | ||
88 | |||
89 | return err; | ||
90 | } | ||
91 | |||
92 | int pmgr_pwr_devices_get_voltage_u64(void *data, u64 *p) | ||
93 | { | ||
94 | struct gk20a *g = (struct gk20a *)data; | ||
95 | int err; | ||
96 | u32 val; | ||
97 | |||
98 | err = pmgr_pwr_devices_get_voltage(g, &val); | ||
99 | *p = val; | ||
100 | |||
101 | return err; | ||
102 | } | ||
103 | |||
71 | DEFINE_SIMPLE_ATTRIBUTE( | 104 | DEFINE_SIMPLE_ATTRIBUTE( |
72 | pmgr_power_ctrl_fops, pmgr_pwr_devices_get_current_power, NULL, "%llu\n"); | 105 | pmgr_power_ctrl_fops, pmgr_pwr_devices_get_power_u64, NULL, "%llu\n"); |
73 | 106 | ||
74 | DEFINE_SIMPLE_ATTRIBUTE( | 107 | DEFINE_SIMPLE_ATTRIBUTE( |
75 | pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current, NULL, "%llu\n"); | 108 | pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current_u64, NULL, "%llu\n"); |
76 | 109 | ||
77 | DEFINE_SIMPLE_ATTRIBUTE( | 110 | DEFINE_SIMPLE_ATTRIBUTE( |
78 | pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_current_voltage, NULL, "%llu\n"); | 111 | pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n"); |
79 | 112 | ||
80 | static void pmgr_debugfs_init(struct gk20a *g) { | 113 | static void pmgr_debugfs_init(struct gk20a *g) { |
81 | struct gk20a_platform *platform = dev_get_drvdata(g->dev); | 114 | struct gk20a_platform *platform = dev_get_drvdata(g->dev); |
diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.h b/drivers/gpu/nvgpu/pmgr/pmgr.h index 97e7b609..cf511fd1 100644 --- a/drivers/gpu/nvgpu/pmgr/pmgr.h +++ b/drivers/gpu/nvgpu/pmgr/pmgr.h | |||
@@ -27,5 +27,8 @@ struct pmgr_pmupstate { | |||
27 | 27 | ||
28 | u32 pmgr_domain_sw_setup(struct gk20a *g); | 28 | u32 pmgr_domain_sw_setup(struct gk20a *g); |
29 | u32 pmgr_domain_pmu_setup(struct gk20a *g); | 29 | u32 pmgr_domain_pmu_setup(struct gk20a *g); |
30 | int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val); | ||
31 | int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val); | ||
32 | int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val); | ||
30 | 33 | ||
31 | #endif | 34 | #endif |