diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2017-10-11 17:58:57 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-10-26 17:35:38 -0400 |
commit | e49d93a960f8995affeb4541941eb7f16d04eafd (patch) | |
tree | 7b5eb1365bfee8a237ddf7d8e0b02959e50f5704 /drivers/gpu/nvgpu/common/linux | |
parent | 9eebb7831facaa16b2975f50a716d2986c67b699 (diff) |
gpu: nvgpu: Linux specific GPU characteristics flags
Make GPU characteristics flags specific to Linux code only. The
rest of driver is moved to using nvgpu_is_enabled() API.
JIRA NVGPU-259
Change-Id: I2faf46ef64c964361c267887b28c9d19806d6d51
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1583876
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 7 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | 87 |
2 files changed, 87 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index ed00ad31..ee4755c8 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <nvgpu/log.h> | 28 | #include <nvgpu/log.h> |
29 | #include <nvgpu/list.h> | 29 | #include <nvgpu/list.h> |
30 | #include <nvgpu/debug.h> | 30 | #include <nvgpu/debug.h> |
31 | #include <nvgpu/enabled.h> | ||
31 | 32 | ||
32 | #include "gk20a/gk20a.h" | 33 | #include "gk20a/gk20a.h" |
33 | #include "gk20a/ctxsw_trace_gk20a.h" | 34 | #include "gk20a/ctxsw_trace_gk20a.h" |
@@ -99,8 +100,7 @@ static int gk20a_channel_cycle_stats(struct channel_gk20a *ch, | |||
99 | void *virtual_address; | 100 | void *virtual_address; |
100 | 101 | ||
101 | /* is it allowed to handle calls for current GPU? */ | 102 | /* is it allowed to handle calls for current GPU? */ |
102 | if (0 == (ch->g->gpu_characteristics.flags & | 103 | if (!nvgpu_is_enabled(ch->g, NVGPU_SUPPORT_CYCLE_STATS)) |
103 | NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS)) | ||
104 | return -ENOSYS; | 104 | return -ENOSYS; |
105 | 105 | ||
106 | if (args->dmabuf_fd && !ch->cyclestate.cyclestate_buffer_handler) { | 106 | if (args->dmabuf_fd && !ch->cyclestate.cyclestate_buffer_handler) { |
@@ -176,8 +176,7 @@ static int gk20a_channel_cycle_stats_snapshot(struct channel_gk20a *ch, | |||
176 | int ret; | 176 | int ret; |
177 | 177 | ||
178 | /* is it allowed to handle calls for current GPU? */ | 178 | /* is it allowed to handle calls for current GPU? */ |
179 | if (0 == (ch->g->gpu_characteristics.flags & | 179 | if (!nvgpu_is_enabled(ch->g, NVGPU_SUPPORT_CYCLE_STATS_SNAPSHOT)) |
180 | NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT)) | ||
181 | return -ENOSYS; | 180 | return -ENOSYS; |
182 | 181 | ||
183 | if (!args->dmabuf_fd) | 182 | if (!args->dmabuf_fd) |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c index 4bb79375..6c9fc26f 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/anon_inodes.h> | 20 | #include <linux/anon_inodes.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <uapi/linux/nvgpu.h> | 22 | #include <uapi/linux/nvgpu.h> |
23 | #include <uapi/linux/nvgpu-t18x.h> | ||
23 | 24 | ||
24 | #include <nvgpu/bitops.h> | 25 | #include <nvgpu/bitops.h> |
25 | #include <nvgpu/kmem.h> | 26 | #include <nvgpu/kmem.h> |
@@ -27,10 +28,14 @@ | |||
27 | #include <nvgpu/bus.h> | 28 | #include <nvgpu/bus.h> |
28 | #include <nvgpu/vidmem.h> | 29 | #include <nvgpu/vidmem.h> |
29 | #include <nvgpu/log.h> | 30 | #include <nvgpu/log.h> |
31 | #include <nvgpu/enabled.h> | ||
30 | 32 | ||
31 | #include <nvgpu/linux/vidmem.h> | 33 | #include <nvgpu/linux/vidmem.h> |
32 | 34 | ||
33 | #include "ioctl_ctrl.h" | 35 | #include "ioctl_ctrl.h" |
36 | #ifdef CONFIG_TEGRA_19x_GPU | ||
37 | #include "common/linux/ioctl_ctrl_t19x.h" | ||
38 | #endif | ||
34 | #include "ioctl_tsg.h" | 39 | #include "ioctl_tsg.h" |
35 | #include "ioctl_channel.h" | 40 | #include "ioctl_channel.h" |
36 | #include "gk20a/gk20a.h" | 41 | #include "gk20a/gk20a.h" |
@@ -113,6 +118,77 @@ int gk20a_ctrl_dev_release(struct inode *inode, struct file *filp) | |||
113 | return 0; | 118 | return 0; |
114 | } | 119 | } |
115 | 120 | ||
121 | struct nvgpu_flags_mapping { | ||
122 | u64 ioctl_flag; | ||
123 | int enabled_flag; | ||
124 | }; | ||
125 | |||
126 | static struct nvgpu_flags_mapping flags_mapping[] = { | ||
127 | {NVGPU_GPU_FLAGS_HAS_SYNCPOINTS, | ||
128 | NVGPU_HAS_SYNCPOINTS}, | ||
129 | {NVGPU_GPU_FLAGS_SUPPORT_PARTIAL_MAPPINGS, | ||
130 | NVGPU_SUPPORT_PARTIAL_MAPPINGS}, | ||
131 | {NVGPU_GPU_FLAGS_SUPPORT_SPARSE_ALLOCS, | ||
132 | NVGPU_SUPPORT_SPARSE_ALLOCS}, | ||
133 | {NVGPU_GPU_FLAGS_SUPPORT_SYNC_FENCE_FDS, | ||
134 | NVGPU_SUPPORT_SYNC_FENCE_FDS}, | ||
135 | {NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS, | ||
136 | NVGPU_SUPPORT_CYCLE_STATS}, | ||
137 | {NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT, | ||
138 | NVGPU_SUPPORT_CYCLE_STATS_SNAPSHOT}, | ||
139 | {NVGPU_GPU_FLAGS_SUPPORT_USERSPACE_MANAGED_AS, | ||
140 | NVGPU_SUPPORT_USERSPACE_MANAGED_AS}, | ||
141 | {NVGPU_GPU_FLAGS_SUPPORT_TSG, | ||
142 | NVGPU_SUPPORT_TSG}, | ||
143 | {NVGPU_GPU_FLAGS_SUPPORT_CLOCK_CONTROLS, | ||
144 | NVGPU_SUPPORT_CLOCK_CONTROLS}, | ||
145 | {NVGPU_GPU_FLAGS_SUPPORT_GET_VOLTAGE, | ||
146 | NVGPU_SUPPORT_GET_VOLTAGE}, | ||
147 | {NVGPU_GPU_FLAGS_SUPPORT_GET_CURRENT, | ||
148 | NVGPU_SUPPORT_GET_CURRENT}, | ||
149 | {NVGPU_GPU_FLAGS_SUPPORT_GET_POWER, | ||
150 | NVGPU_SUPPORT_GET_POWER}, | ||
151 | {NVGPU_GPU_FLAGS_SUPPORT_GET_TEMPERATURE, | ||
152 | NVGPU_SUPPORT_GET_TEMPERATURE}, | ||
153 | {NVGPU_GPU_FLAGS_SUPPORT_SET_THERM_ALERT_LIMIT, | ||
154 | NVGPU_SUPPORT_SET_THERM_ALERT_LIMIT}, | ||
155 | {NVGPU_GPU_FLAGS_SUPPORT_DEVICE_EVENTS, | ||
156 | NVGPU_SUPPORT_DEVICE_EVENTS}, | ||
157 | {NVGPU_GPU_FLAGS_SUPPORT_FECS_CTXSW_TRACE, | ||
158 | NVGPU_SUPPORT_FECS_CTXSW_TRACE}, | ||
159 | {NVGPU_GPU_FLAGS_SUPPORT_DETERMINISTIC_SUBMIT_NO_JOBTRACKING, | ||
160 | NVGPU_SUPPORT_DETERMINISTIC_SUBMIT_NO_JOBTRACKING}, | ||
161 | {NVGPU_GPU_FLAGS_SUPPORT_DETERMINISTIC_SUBMIT_FULL, | ||
162 | NVGPU_SUPPORT_DETERMINISTIC_SUBMIT_FULL}, | ||
163 | {NVGPU_GPU_FLAGS_SUPPORT_IO_COHERENCE, | ||
164 | NVGPU_SUPPORT_IO_COHERENCE}, | ||
165 | {NVGPU_GPU_FLAGS_SUPPORT_RESCHEDULE_RUNLIST, | ||
166 | NVGPU_SUPPORT_RESCHEDULE_RUNLIST}, | ||
167 | {NVGPU_GPU_FLAGS_SUPPORT_MAP_DIRECT_KIND_CTRL, | ||
168 | NVGPU_SUPPORT_MAP_DIRECT_KIND_CTRL}, | ||
169 | {NVGPU_GPU_FLAGS_ECC_ENABLED_SM_LRF, | ||
170 | NVGPU_ECC_ENABLED_SM_LRF}, | ||
171 | {NVGPU_GPU_FLAGS_ECC_ENABLED_SM_SHM, | ||
172 | NVGPU_ECC_ENABLED_SM_SHM}, | ||
173 | {NVGPU_GPU_FLAGS_ECC_ENABLED_TEX, | ||
174 | NVGPU_ECC_ENABLED_TEX}, | ||
175 | {NVGPU_GPU_FLAGS_ECC_ENABLED_LTC, | ||
176 | NVGPU_ECC_ENABLED_LTC}, | ||
177 | }; | ||
178 | |||
179 | static u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags(struct gk20a *g) | ||
180 | { | ||
181 | unsigned int i; | ||
182 | u64 ioctl_flags = 0; | ||
183 | |||
184 | for (i = 0; i < sizeof(flags_mapping)/sizeof(*flags_mapping); i++) { | ||
185 | if (nvgpu_is_enabled(g, flags_mapping[i].enabled_flag)) | ||
186 | ioctl_flags |= flags_mapping[i].ioctl_flag; | ||
187 | } | ||
188 | |||
189 | return ioctl_flags; | ||
190 | } | ||
191 | |||
116 | static long | 192 | static long |
117 | gk20a_ctrl_ioctl_gpu_characteristics( | 193 | gk20a_ctrl_ioctl_gpu_characteristics( |
118 | struct gk20a *g, | 194 | struct gk20a *g, |
@@ -121,6 +197,11 @@ gk20a_ctrl_ioctl_gpu_characteristics( | |||
121 | struct nvgpu_gpu_characteristics *pgpu = &g->gpu_characteristics; | 197 | struct nvgpu_gpu_characteristics *pgpu = &g->gpu_characteristics; |
122 | long err = 0; | 198 | long err = 0; |
123 | 199 | ||
200 | pgpu->flags = nvgpu_ctrl_ioctl_gpu_characteristics_flags(g); | ||
201 | #ifdef CONFIG_TEGRA_19x_GPU | ||
202 | pgpu->flags |= nvgpu_ctrl_ioctl_gpu_characteristics_flags_t19x(g); | ||
203 | #endif | ||
204 | |||
124 | if (request->gpu_characteristics_buf_size > 0) { | 205 | if (request->gpu_characteristics_buf_size > 0) { |
125 | size_t write_size = sizeof(*pgpu); | 206 | size_t write_size = sizeof(*pgpu); |
126 | 207 | ||
@@ -1108,7 +1189,7 @@ static int nvgpu_gpu_get_voltage(struct gk20a *g, | |||
1108 | if (args->reserved) | 1189 | if (args->reserved) |
1109 | return -EINVAL; | 1190 | return -EINVAL; |
1110 | 1191 | ||
1111 | if (!(g->gpu_characteristics.flags & NVGPU_GPU_FLAGS_SUPPORT_GET_VOLTAGE)) | 1192 | if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_GET_VOLTAGE)) |
1112 | return -EINVAL; | 1193 | return -EINVAL; |
1113 | 1194 | ||
1114 | err = gk20a_busy(g); | 1195 | err = gk20a_busy(g); |
@@ -1144,7 +1225,7 @@ static int nvgpu_gpu_get_current(struct gk20a *g, | |||
1144 | if (args->reserved[0] || args->reserved[1] || args->reserved[2]) | 1225 | if (args->reserved[0] || args->reserved[1] || args->reserved[2]) |
1145 | return -EINVAL; | 1226 | return -EINVAL; |
1146 | 1227 | ||
1147 | if (!(g->gpu_characteristics.flags & NVGPU_GPU_FLAGS_SUPPORT_GET_CURRENT)) | 1228 | if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_GET_CURRENT)) |
1148 | return -EINVAL; | 1229 | return -EINVAL; |
1149 | 1230 | ||
1150 | err = gk20a_busy(g); | 1231 | err = gk20a_busy(g); |
@@ -1168,7 +1249,7 @@ static int nvgpu_gpu_get_power(struct gk20a *g, | |||
1168 | if (args->reserved[0] || args->reserved[1] || args->reserved[2]) | 1249 | if (args->reserved[0] || args->reserved[1] || args->reserved[2]) |
1169 | return -EINVAL; | 1250 | return -EINVAL; |
1170 | 1251 | ||
1171 | if (!(g->gpu_characteristics.flags & NVGPU_GPU_FLAGS_SUPPORT_GET_POWER)) | 1252 | if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_GET_POWER)) |
1172 | return -EINVAL; | 1253 | return -EINVAL; |
1173 | 1254 | ||
1174 | err = gk20a_busy(g); | 1255 | err = gk20a_busy(g); |