diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2017-06-20 15:18:47 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-06-21 20:34:49 -0400 |
commit | 92c43deefca150854193c6720717d56b61989c23 (patch) | |
tree | 2dbfdcdb3a0809b80d4fc50e1d882326e54c7d17 /drivers | |
parent | 2ffbdc50d884215ba043e8afd3c3bcbefd1e66f8 (diff) |
gpu: nvgpu: Remove Linux devnode fields from gk20a
Move Linux devnode related fields to a new header file os_linux.h.
The class structure is defined in module.c, so move its declaration
to module.h.
JIRA NVGPU-38
Change-Id: I5d8920169064f4289ff61004f7f81543a9aba221
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1505927
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl.c | 74 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_as.c | 5 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | 14 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_tsg.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/module.c | 7 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/module.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/os_linux.h | 76 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/pci.c | 11 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 12 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.h | 47 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/sched_gk20a.c | 8 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/vgpu.c | 9 |
14 files changed, 177 insertions, 112 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl.c b/drivers/gpu/nvgpu/common/linux/ioctl.c index 5a2753a5..8262c326 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include "ioctl_ctrl.h" | 28 | #include "ioctl_ctrl.h" |
29 | #include "ioctl_as.h" | 29 | #include "ioctl_as.h" |
30 | #include "ioctl_tsg.h" | 30 | #include "ioctl_tsg.h" |
31 | #include "module.h" | ||
32 | #include "os_linux.h" | ||
31 | 33 | ||
32 | #define GK20A_NUM_CDEVS 7 | 34 | #define GK20A_NUM_CDEVS 7 |
33 | 35 | ||
@@ -162,49 +164,50 @@ static int gk20a_create_device( | |||
162 | void gk20a_user_deinit(struct device *dev, struct class *class) | 164 | void gk20a_user_deinit(struct device *dev, struct class *class) |
163 | { | 165 | { |
164 | struct gk20a *g = gk20a_from_dev(dev); | 166 | struct gk20a *g = gk20a_from_dev(dev); |
167 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
165 | 168 | ||
166 | if (g->channel.node) { | 169 | if (l->channel.node) { |
167 | device_destroy(class, g->channel.cdev.dev); | 170 | device_destroy(class, l->channel.cdev.dev); |
168 | cdev_del(&g->channel.cdev); | 171 | cdev_del(&l->channel.cdev); |
169 | } | 172 | } |
170 | 173 | ||
171 | if (g->as_dev.node) { | 174 | if (l->as_dev.node) { |
172 | device_destroy(class, g->as_dev.cdev.dev); | 175 | device_destroy(class, l->as_dev.cdev.dev); |
173 | cdev_del(&g->as_dev.cdev); | 176 | cdev_del(&l->as_dev.cdev); |
174 | } | 177 | } |
175 | 178 | ||
176 | if (g->ctrl.node) { | 179 | if (l->ctrl.node) { |
177 | device_destroy(class, g->ctrl.cdev.dev); | 180 | device_destroy(class, l->ctrl.cdev.dev); |
178 | cdev_del(&g->ctrl.cdev); | 181 | cdev_del(&l->ctrl.cdev); |
179 | } | 182 | } |
180 | 183 | ||
181 | if (g->dbg.node) { | 184 | if (l->dbg.node) { |
182 | device_destroy(class, g->dbg.cdev.dev); | 185 | device_destroy(class, l->dbg.cdev.dev); |
183 | cdev_del(&g->dbg.cdev); | 186 | cdev_del(&l->dbg.cdev); |
184 | } | 187 | } |
185 | 188 | ||
186 | if (g->prof.node) { | 189 | if (l->prof.node) { |
187 | device_destroy(class, g->prof.cdev.dev); | 190 | device_destroy(class, l->prof.cdev.dev); |
188 | cdev_del(&g->prof.cdev); | 191 | cdev_del(&l->prof.cdev); |
189 | } | 192 | } |
190 | 193 | ||
191 | if (g->tsg.node) { | 194 | if (l->tsg.node) { |
192 | device_destroy(class, g->tsg.cdev.dev); | 195 | device_destroy(class, l->tsg.cdev.dev); |
193 | cdev_del(&g->tsg.cdev); | 196 | cdev_del(&l->tsg.cdev); |
194 | } | 197 | } |
195 | 198 | ||
196 | if (g->ctxsw.node) { | 199 | if (l->ctxsw.node) { |
197 | device_destroy(class, g->ctxsw.cdev.dev); | 200 | device_destroy(class, l->ctxsw.cdev.dev); |
198 | cdev_del(&g->ctxsw.cdev); | 201 | cdev_del(&l->ctxsw.cdev); |
199 | } | 202 | } |
200 | 203 | ||
201 | if (g->sched.node) { | 204 | if (l->sched.node) { |
202 | device_destroy(class, g->sched.cdev.dev); | 205 | device_destroy(class, l->sched.cdev.dev); |
203 | cdev_del(&g->sched.cdev); | 206 | cdev_del(&l->sched.cdev); |
204 | } | 207 | } |
205 | 208 | ||
206 | if (g->cdev_region) | 209 | if (l->cdev_region) |
207 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); | 210 | unregister_chrdev_region(l->cdev_region, GK20A_NUM_CDEVS); |
208 | } | 211 | } |
209 | 212 | ||
210 | int gk20a_user_init(struct device *dev, const char *interface_name, | 213 | int gk20a_user_init(struct device *dev, const char *interface_name, |
@@ -213,51 +216,52 @@ int gk20a_user_init(struct device *dev, const char *interface_name, | |||
213 | int err; | 216 | int err; |
214 | dev_t devno; | 217 | dev_t devno; |
215 | struct gk20a *g = gk20a_from_dev(dev); | 218 | struct gk20a *g = gk20a_from_dev(dev); |
219 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
216 | 220 | ||
217 | err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev)); | 221 | err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev)); |
218 | if (err) { | 222 | if (err) { |
219 | dev_err(dev, "failed to allocate devno\n"); | 223 | dev_err(dev, "failed to allocate devno\n"); |
220 | goto fail; | 224 | goto fail; |
221 | } | 225 | } |
222 | g->cdev_region = devno; | 226 | l->cdev_region = devno; |
223 | 227 | ||
224 | err = gk20a_create_device(dev, devno++, interface_name, "", | 228 | err = gk20a_create_device(dev, devno++, interface_name, "", |
225 | &g->channel.cdev, &g->channel.node, | 229 | &l->channel.cdev, &l->channel.node, |
226 | &gk20a_channel_ops, | 230 | &gk20a_channel_ops, |
227 | class); | 231 | class); |
228 | if (err) | 232 | if (err) |
229 | goto fail; | 233 | goto fail; |
230 | 234 | ||
231 | err = gk20a_create_device(dev, devno++, interface_name, "-as", | 235 | err = gk20a_create_device(dev, devno++, interface_name, "-as", |
232 | &g->as_dev.cdev, &g->as_dev.node, | 236 | &l->as_dev.cdev, &l->as_dev.node, |
233 | &gk20a_as_ops, | 237 | &gk20a_as_ops, |
234 | class); | 238 | class); |
235 | if (err) | 239 | if (err) |
236 | goto fail; | 240 | goto fail; |
237 | 241 | ||
238 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", | 242 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", |
239 | &g->ctrl.cdev, &g->ctrl.node, | 243 | &l->ctrl.cdev, &l->ctrl.node, |
240 | &gk20a_ctrl_ops, | 244 | &gk20a_ctrl_ops, |
241 | class); | 245 | class); |
242 | if (err) | 246 | if (err) |
243 | goto fail; | 247 | goto fail; |
244 | 248 | ||
245 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", | 249 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", |
246 | &g->dbg.cdev, &g->dbg.node, | 250 | &l->dbg.cdev, &l->dbg.node, |
247 | &gk20a_dbg_ops, | 251 | &gk20a_dbg_ops, |
248 | class); | 252 | class); |
249 | if (err) | 253 | if (err) |
250 | goto fail; | 254 | goto fail; |
251 | 255 | ||
252 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", | 256 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", |
253 | &g->prof.cdev, &g->prof.node, | 257 | &l->prof.cdev, &l->prof.node, |
254 | &gk20a_prof_ops, | 258 | &gk20a_prof_ops, |
255 | class); | 259 | class); |
256 | if (err) | 260 | if (err) |
257 | goto fail; | 261 | goto fail; |
258 | 262 | ||
259 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", | 263 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", |
260 | &g->tsg.cdev, &g->tsg.node, | 264 | &l->tsg.cdev, &l->tsg.node, |
261 | &gk20a_tsg_ops, | 265 | &gk20a_tsg_ops, |
262 | class); | 266 | class); |
263 | if (err) | 267 | if (err) |
@@ -265,7 +269,7 @@ int gk20a_user_init(struct device *dev, const char *interface_name, | |||
265 | 269 | ||
266 | #ifdef CONFIG_GK20A_CTXSW_TRACE | 270 | #ifdef CONFIG_GK20A_CTXSW_TRACE |
267 | err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw", | 271 | err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw", |
268 | &g->ctxsw.cdev, &g->ctxsw.node, | 272 | &l->ctxsw.cdev, &l->ctxsw.node, |
269 | &gk20a_ctxsw_ops, | 273 | &gk20a_ctxsw_ops, |
270 | class); | 274 | class); |
271 | if (err) | 275 | if (err) |
@@ -273,7 +277,7 @@ int gk20a_user_init(struct device *dev, const char *interface_name, | |||
273 | #endif | 277 | #endif |
274 | 278 | ||
275 | err = gk20a_create_device(dev, devno++, interface_name, "-sched", | 279 | err = gk20a_create_device(dev, devno++, interface_name, "-sched", |
276 | &g->sched.cdev, &g->sched.node, | 280 | &l->sched.cdev, &l->sched.node, |
277 | &gk20a_sched_ops, | 281 | &gk20a_sched_ops, |
278 | class); | 282 | class); |
279 | if (err) | 283 | if (err) |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_as.c b/drivers/gpu/nvgpu/common/linux/ioctl_as.c index 1d6410cc..405301ee 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_as.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gk20a/platform_gk20a.h" | 30 | #include "gk20a/platform_gk20a.h" |
31 | #include "ioctl_as.h" | 31 | #include "ioctl_as.h" |
32 | #include "vm_priv.h" | 32 | #include "vm_priv.h" |
33 | #include "os_linux.h" | ||
33 | 34 | ||
34 | static int gk20a_as_ioctl_bind_channel( | 35 | static int gk20a_as_ioctl_bind_channel( |
35 | struct gk20a_as_share *as_share, | 36 | struct gk20a_as_share *as_share, |
@@ -253,13 +254,15 @@ static int gk20a_as_ioctl_map_buffer_compbits( | |||
253 | 254 | ||
254 | int gk20a_as_dev_open(struct inode *inode, struct file *filp) | 255 | int gk20a_as_dev_open(struct inode *inode, struct file *filp) |
255 | { | 256 | { |
257 | struct nvgpu_os_linux *l; | ||
256 | struct gk20a_as_share *as_share; | 258 | struct gk20a_as_share *as_share; |
257 | struct gk20a *g; | 259 | struct gk20a *g; |
258 | int err; | 260 | int err; |
259 | 261 | ||
260 | gk20a_dbg_fn(""); | 262 | gk20a_dbg_fn(""); |
261 | 263 | ||
262 | g = container_of(inode->i_cdev, struct gk20a, as_dev.cdev); | 264 | l = container_of(inode->i_cdev, struct nvgpu_os_linux, as_dev.cdev); |
265 | g = &l->g; | ||
263 | 266 | ||
264 | err = gk20a_as_alloc_share(g, 0, 0, &as_share); | 267 | err = gk20a_as_alloc_share(g, 0, 0, &as_share); |
265 | if (err) { | 268 | if (err) { |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 17340e8c..2466db40 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "gk20a/dbg_gpu_gk20a.h" | 33 | #include "gk20a/dbg_gpu_gk20a.h" |
34 | #include "gk20a/fence_gk20a.h" | 34 | #include "gk20a/fence_gk20a.h" |
35 | #include "ioctl_channel.h" | 35 | #include "ioctl_channel.h" |
36 | #include "os_linux.h" | ||
36 | 37 | ||
37 | static void gk20a_channel_trace_sched_param( | 38 | static void gk20a_channel_trace_sched_param( |
38 | void (*trace)(int chid, int tsgid, pid_t pid, u32 timeslice, | 39 | void (*trace)(int chid, int tsgid, pid_t pid, u32 timeslice, |
@@ -359,8 +360,9 @@ free_ref: | |||
359 | 360 | ||
360 | int gk20a_channel_open(struct inode *inode, struct file *filp) | 361 | int gk20a_channel_open(struct inode *inode, struct file *filp) |
361 | { | 362 | { |
362 | struct gk20a *g = container_of(inode->i_cdev, | 363 | struct nvgpu_os_linux *l = container_of(inode->i_cdev, |
363 | struct gk20a, channel.cdev); | 364 | struct nvgpu_os_linux, channel.cdev); |
365 | struct gk20a *g = &l->g; | ||
364 | int ret; | 366 | int ret; |
365 | 367 | ||
366 | gk20a_dbg_fn("start"); | 368 | gk20a_dbg_fn("start"); |
@@ -378,6 +380,7 @@ int gk20a_channel_open_ioctl(struct gk20a *g, | |||
378 | struct file *file; | 380 | struct file *file; |
379 | char name[64]; | 381 | char name[64]; |
380 | s32 runlist_id = args->in.runlist_id; | 382 | s32 runlist_id = args->in.runlist_id; |
383 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
381 | 384 | ||
382 | err = get_unused_fd_flags(O_RDWR); | 385 | err = get_unused_fd_flags(O_RDWR); |
383 | if (err < 0) | 386 | if (err < 0) |
@@ -387,7 +390,7 @@ int gk20a_channel_open_ioctl(struct gk20a *g, | |||
387 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", | 390 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", |
388 | dev_name(g->dev), fd); | 391 | dev_name(g->dev), fd); |
389 | 392 | ||
390 | file = anon_inode_getfile(name, g->channel.cdev.ops, NULL, O_RDWR); | 393 | file = anon_inode_getfile(name, l->channel.cdev.ops, NULL, O_RDWR); |
391 | if (IS_ERR(file)) { | 394 | if (IS_ERR(file)) { |
392 | err = PTR_ERR(file); | 395 | err = PTR_ERR(file); |
393 | goto clean_up; | 396 | goto clean_up; |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c index caf8d309..5c5ac645 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "gk20a/gk20a.h" | 31 | #include "gk20a/gk20a.h" |
32 | #include "gk20a/platform_gk20a.h" | 32 | #include "gk20a/platform_gk20a.h" |
33 | #include "gk20a/fence_gk20a.h" | 33 | #include "gk20a/fence_gk20a.h" |
34 | #include "os_linux.h" | ||
34 | 35 | ||
35 | #include <nvgpu/log.h> | 36 | #include <nvgpu/log.h> |
36 | 37 | ||
@@ -48,15 +49,16 @@ struct gk20a_ctrl_priv { | |||
48 | 49 | ||
49 | int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) | 50 | int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) |
50 | { | 51 | { |
52 | struct nvgpu_os_linux *l; | ||
51 | struct gk20a *g; | 53 | struct gk20a *g; |
52 | struct gk20a_ctrl_priv *priv; | 54 | struct gk20a_ctrl_priv *priv; |
53 | int err = 0; | 55 | int err = 0; |
54 | 56 | ||
55 | gk20a_dbg_fn(""); | 57 | gk20a_dbg_fn(""); |
56 | 58 | ||
57 | g = container_of(inode->i_cdev, | 59 | l = container_of(inode->i_cdev, |
58 | struct gk20a, ctrl.cdev); | 60 | struct nvgpu_os_linux, ctrl.cdev); |
59 | g = gk20a_get(g); | 61 | g = gk20a_get(&l->g); |
60 | if (!g) | 62 | if (!g) |
61 | return -ENODEV; | 63 | return -ENODEV; |
62 | 64 | ||
@@ -199,6 +201,7 @@ static int gk20a_ctrl_alloc_as( | |||
199 | struct gk20a *g, | 201 | struct gk20a *g, |
200 | struct nvgpu_alloc_as_args *args) | 202 | struct nvgpu_alloc_as_args *args) |
201 | { | 203 | { |
204 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
202 | struct gk20a_as_share *as_share; | 205 | struct gk20a_as_share *as_share; |
203 | int err; | 206 | int err; |
204 | int fd; | 207 | int fd; |
@@ -212,7 +215,7 @@ static int gk20a_ctrl_alloc_as( | |||
212 | 215 | ||
213 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); | 216 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); |
214 | 217 | ||
215 | file = anon_inode_getfile(name, g->as_dev.cdev.ops, NULL, O_RDWR); | 218 | file = anon_inode_getfile(name, l->as_dev.cdev.ops, NULL, O_RDWR); |
216 | if (IS_ERR(file)) { | 219 | if (IS_ERR(file)) { |
217 | err = PTR_ERR(file); | 220 | err = PTR_ERR(file); |
218 | goto clean_up; | 221 | goto clean_up; |
@@ -239,6 +242,7 @@ clean_up: | |||
239 | static int gk20a_ctrl_open_tsg(struct gk20a *g, | 242 | static int gk20a_ctrl_open_tsg(struct gk20a *g, |
240 | struct nvgpu_gpu_open_tsg_args *args) | 243 | struct nvgpu_gpu_open_tsg_args *args) |
241 | { | 244 | { |
245 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
242 | int err; | 246 | int err; |
243 | int fd; | 247 | int fd; |
244 | struct file *file; | 248 | struct file *file; |
@@ -251,7 +255,7 @@ static int gk20a_ctrl_open_tsg(struct gk20a *g, | |||
251 | 255 | ||
252 | snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd); | 256 | snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd); |
253 | 257 | ||
254 | file = anon_inode_getfile(name, g->tsg.cdev.ops, NULL, O_RDWR); | 258 | file = anon_inode_getfile(name, l->tsg.cdev.ops, NULL, O_RDWR); |
255 | if (IS_ERR(file)) { | 259 | if (IS_ERR(file)) { |
256 | err = PTR_ERR(file); | 260 | err = PTR_ERR(file); |
257 | goto clean_up; | 261 | goto clean_up; |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c index 9b722e9e..46bc5f59 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gk20a/tsg_gk20a.h" | 29 | #include "gk20a/tsg_gk20a.h" |
30 | #include "ioctl_tsg.h" | 30 | #include "ioctl_tsg.h" |
31 | #include "ioctl_channel.h" | 31 | #include "ioctl_channel.h" |
32 | #include "os_linux.h" | ||
32 | 33 | ||
33 | struct tsg_private { | 34 | struct tsg_private { |
34 | struct gk20a *g; | 35 | struct gk20a *g; |
@@ -240,13 +241,13 @@ free_ref: | |||
240 | 241 | ||
241 | int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp) | 242 | int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp) |
242 | { | 243 | { |
243 | struct gk20a *g; | 244 | struct nvgpu_os_linux *l; |
244 | int ret; | 245 | int ret; |
245 | 246 | ||
246 | g = container_of(inode->i_cdev, | 247 | l = container_of(inode->i_cdev, |
247 | struct gk20a, tsg.cdev); | 248 | struct nvgpu_os_linux, tsg.cdev); |
248 | gk20a_dbg_fn(""); | 249 | gk20a_dbg_fn(""); |
249 | ret = nvgpu_ioctl_tsg_open(g, filp); | 250 | ret = nvgpu_ioctl_tsg_open(&l->g, filp); |
250 | gk20a_dbg_fn("done"); | 251 | gk20a_dbg_fn("done"); |
251 | return ret; | 252 | return ret; |
252 | } | 253 | } |
diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index af137c19..bfd2c790 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #ifdef CONFIG_TEGRA_19x_GPU | 42 | #ifdef CONFIG_TEGRA_19x_GPU |
43 | #include "nvgpu_gpuid_t19x.h" | 43 | #include "nvgpu_gpuid_t19x.h" |
44 | #endif | 44 | #endif |
45 | #include "os_linux.h" | ||
45 | 46 | ||
46 | #define CLASS_NAME "nvidia-gpu" | 47 | #define CLASS_NAME "nvidia-gpu" |
47 | /* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */ | 48 | /* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */ |
@@ -849,6 +850,7 @@ static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a) | |||
849 | 850 | ||
850 | static int gk20a_probe(struct platform_device *dev) | 851 | static int gk20a_probe(struct platform_device *dev) |
851 | { | 852 | { |
853 | struct nvgpu_os_linux *l; | ||
852 | struct gk20a *gk20a; | 854 | struct gk20a *gk20a; |
853 | int err; | 855 | int err; |
854 | struct gk20a_platform *platform = NULL; | 856 | struct gk20a_platform *platform = NULL; |
@@ -874,12 +876,13 @@ static int gk20a_probe(struct platform_device *dev) | |||
874 | if (gk20a_gpu_is_virtual(&dev->dev)) | 876 | if (gk20a_gpu_is_virtual(&dev->dev)) |
875 | return vgpu_probe(dev); | 877 | return vgpu_probe(dev); |
876 | 878 | ||
877 | gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); | 879 | l = kzalloc(sizeof(*l), GFP_KERNEL); |
878 | if (!gk20a) { | 880 | if (!l) { |
879 | dev_err(&dev->dev, "couldn't allocate gk20a support"); | 881 | dev_err(&dev->dev, "couldn't allocate gk20a support"); |
880 | return -ENOMEM; | 882 | return -ENOMEM; |
881 | } | 883 | } |
882 | 884 | ||
885 | gk20a = &l->g; | ||
883 | set_gk20a(dev, gk20a); | 886 | set_gk20a(dev, gk20a); |
884 | gk20a->dev = &dev->dev; | 887 | gk20a->dev = &dev->dev; |
885 | gk20a->log_mask = NVGPU_DEFAULT_DBG_MASK; | 888 | gk20a->log_mask = NVGPU_DEFAULT_DBG_MASK; |
diff --git a/drivers/gpu/nvgpu/common/linux/module.h b/drivers/gpu/nvgpu/common/linux/module.h index 45fa2f5c..0fde0b41 100644 --- a/drivers/gpu/nvgpu/common/linux/module.h +++ b/drivers/gpu/nvgpu/common/linux/module.h | |||
@@ -19,4 +19,6 @@ struct device; | |||
19 | int gk20a_pm_finalize_poweron(struct device *dev); | 19 | int gk20a_pm_finalize_poweron(struct device *dev); |
20 | void gk20a_remove_support(struct gk20a *g); | 20 | void gk20a_remove_support(struct gk20a *g); |
21 | 21 | ||
22 | extern struct class nvgpu_class; | ||
23 | |||
22 | #endif | 24 | #endif |
diff --git a/drivers/gpu/nvgpu/common/linux/os_linux.h b/drivers/gpu/nvgpu/common/linux/os_linux.h new file mode 100644 index 00000000..f23926b3 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/os_linux.h | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | #ifndef NVGPU_OS_LINUX_H | ||
17 | #define NVGPU_OS_LINUX_H | ||
18 | |||
19 | #include <linux/cdev.h> | ||
20 | |||
21 | #include "gk20a/gk20a.h" | ||
22 | |||
23 | struct nvgpu_os_linux { | ||
24 | struct gk20a g; | ||
25 | |||
26 | struct { | ||
27 | struct cdev cdev; | ||
28 | struct device *node; | ||
29 | } channel; | ||
30 | |||
31 | struct { | ||
32 | struct cdev cdev; | ||
33 | struct device *node; | ||
34 | } ctrl; | ||
35 | |||
36 | struct { | ||
37 | struct cdev cdev; | ||
38 | struct device *node; | ||
39 | } as_dev; | ||
40 | |||
41 | struct { | ||
42 | struct cdev cdev; | ||
43 | struct device *node; | ||
44 | } dbg; | ||
45 | |||
46 | struct { | ||
47 | struct cdev cdev; | ||
48 | struct device *node; | ||
49 | } prof; | ||
50 | |||
51 | struct { | ||
52 | struct cdev cdev; | ||
53 | struct device *node; | ||
54 | } tsg; | ||
55 | |||
56 | struct { | ||
57 | struct cdev cdev; | ||
58 | struct device *node; | ||
59 | } ctxsw; | ||
60 | |||
61 | struct { | ||
62 | struct cdev cdev; | ||
63 | struct device *node; | ||
64 | } sched; | ||
65 | |||
66 | dev_t cdev_region; | ||
67 | }; | ||
68 | |||
69 | static inline struct nvgpu_os_linux *nvgpu_os_linux_from_gk20a(struct gk20a *g) | ||
70 | { | ||
71 | return container_of(g, struct nvgpu_os_linux, g); | ||
72 | } | ||
73 | |||
74 | #define INTERFACE_NAME "nvhost%s-gpu" | ||
75 | |||
76 | #endif | ||
diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index 94ef340d..cb315973 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c | |||
@@ -32,6 +32,8 @@ | |||
32 | 32 | ||
33 | #include "pci.h" | 33 | #include "pci.h" |
34 | 34 | ||
35 | #include "os_linux.h" | ||
36 | |||
35 | #define PCI_INTERFACE_NAME "card-%s%%s" | 37 | #define PCI_INTERFACE_NAME "card-%s%%s" |
36 | 38 | ||
37 | static int nvgpu_pci_tegra_probe(struct device *dev) | 39 | static int nvgpu_pci_tegra_probe(struct device *dev) |
@@ -346,6 +348,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, | |||
346 | const struct pci_device_id *pent) | 348 | const struct pci_device_id *pent) |
347 | { | 349 | { |
348 | struct gk20a_platform *platform = NULL; | 350 | struct gk20a_platform *platform = NULL; |
351 | struct nvgpu_os_linux *l; | ||
349 | struct gk20a *g; | 352 | struct gk20a *g; |
350 | int err; | 353 | int err; |
351 | char nodefmt[64]; | 354 | char nodefmt[64]; |
@@ -359,12 +362,14 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, | |||
359 | platform = &nvgpu_pci_device[pent->driver_data]; | 362 | platform = &nvgpu_pci_device[pent->driver_data]; |
360 | pci_set_drvdata(pdev, platform); | 363 | pci_set_drvdata(pdev, platform); |
361 | 364 | ||
362 | g = kzalloc(sizeof(struct gk20a), GFP_KERNEL); | 365 | l = kzalloc(sizeof(*l), GFP_KERNEL); |
363 | if (!g) { | 366 | if (!l) { |
364 | nvgpu_err(g, "couldn't allocate gk20a support"); | 367 | dev_err(&pdev->dev, "couldn't allocate gk20a support"); |
365 | return -ENOMEM; | 368 | return -ENOMEM; |
366 | } | 369 | } |
367 | 370 | ||
371 | g = &l->g; | ||
372 | |||
368 | nvgpu_kmem_init(g); | 373 | nvgpu_kmem_init(g); |
369 | 374 | ||
370 | err = nvgpu_init_enabled_flags(g); | 375 | err = nvgpu_init_enabled_flags(g); |
diff --git a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c index ceee1ae9..c189a00c 100644 --- a/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctxsw_trace_gk20a.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "gk20a.h" | 25 | #include "gk20a.h" |
26 | #include "platform_gk20a.h" | 26 | #include "platform_gk20a.h" |
27 | #include "gr_gk20a.h" | 27 | #include "gr_gk20a.h" |
28 | #include "common/linux/os_linux.h" | ||
28 | 29 | ||
29 | #include <nvgpu/log.h> | 30 | #include <nvgpu/log.h> |
30 | #include <nvgpu/atomic.h> | 31 | #include <nvgpu/atomic.h> |
@@ -266,6 +267,7 @@ static int gk20a_ctxsw_dev_ioctl_poll(struct gk20a_ctxsw_dev *dev) | |||
266 | 267 | ||
267 | int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp) | 268 | int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp) |
268 | { | 269 | { |
270 | struct nvgpu_os_linux *l; | ||
269 | struct gk20a *g; | 271 | struct gk20a *g; |
270 | struct gk20a_ctxsw_trace *trace; | 272 | struct gk20a_ctxsw_trace *trace; |
271 | struct gk20a_ctxsw_dev *dev; | 273 | struct gk20a_ctxsw_dev *dev; |
@@ -276,8 +278,8 @@ int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp) | |||
276 | /* only one VM for now */ | 278 | /* only one VM for now */ |
277 | const int vmid = 0; | 279 | const int vmid = 0; |
278 | 280 | ||
279 | g = container_of(inode->i_cdev, struct gk20a, ctxsw.cdev); | 281 | l = container_of(inode->i_cdev, struct nvgpu_os_linux, ctxsw.cdev); |
280 | g = gk20a_get(g); | 282 | g = gk20a_get(&l->g); |
281 | if (!g) | 283 | if (!g) |
282 | return -ENODEV; | 284 | return -ENODEV; |
283 | 285 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 77890da8..84edacbb 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "gr_gk20a.h" | 32 | #include "gr_gk20a.h" |
33 | #include "dbg_gpu_gk20a.h" | 33 | #include "dbg_gpu_gk20a.h" |
34 | #include "regops_gk20a.h" | 34 | #include "regops_gk20a.h" |
35 | #include "common/linux/os_linux.h" | ||
35 | 36 | ||
36 | #include <nvgpu/hw/gk20a/hw_therm_gk20a.h> | 37 | #include <nvgpu/hw/gk20a/hw_therm_gk20a.h> |
37 | #include <nvgpu/hw/gk20a/hw_gr_gk20a.h> | 38 | #include <nvgpu/hw/gk20a/hw_gr_gk20a.h> |
@@ -115,6 +116,7 @@ static int alloc_profiler(struct gk20a *g, | |||
115 | static int gk20a_dbg_gpu_do_dev_open(struct inode *inode, | 116 | static int gk20a_dbg_gpu_do_dev_open(struct inode *inode, |
116 | struct file *filp, bool is_profiler) | 117 | struct file *filp, bool is_profiler) |
117 | { | 118 | { |
119 | struct nvgpu_os_linux *l; | ||
118 | struct dbg_session_gk20a *dbg_session; | 120 | struct dbg_session_gk20a *dbg_session; |
119 | struct gk20a *g; | 121 | struct gk20a *g; |
120 | 122 | ||
@@ -123,12 +125,12 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode, | |||
123 | int err; | 125 | int err; |
124 | 126 | ||
125 | if (!is_profiler) | 127 | if (!is_profiler) |
126 | g = container_of(inode->i_cdev, | 128 | l = container_of(inode->i_cdev, |
127 | struct gk20a, dbg.cdev); | 129 | struct nvgpu_os_linux, dbg.cdev); |
128 | else | 130 | else |
129 | g = container_of(inode->i_cdev, | 131 | l = container_of(inode->i_cdev, |
130 | struct gk20a, prof.cdev); | 132 | struct nvgpu_os_linux, prof.cdev); |
131 | g = gk20a_get(g); | 133 | g = gk20a_get(&l->g); |
132 | if (!g) | 134 | if (!g) |
133 | return -ENODEV; | 135 | return -ENODEV; |
134 | 136 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 5acc1074..cda70249 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h | |||
@@ -37,7 +37,6 @@ struct nvgpu_cpu_time_correlation_sample; | |||
37 | 37 | ||
38 | #include <nvgpu/lock.h> | 38 | #include <nvgpu/lock.h> |
39 | #include <nvgpu/thread.h> | 39 | #include <nvgpu/thread.h> |
40 | #include <linux/cdev.h> | ||
41 | #ifdef CONFIG_DEBUG_FS | 40 | #ifdef CONFIG_DEBUG_FS |
42 | #include <linux/debugfs.h> | 41 | #include <linux/debugfs.h> |
43 | #endif | 42 | #endif |
@@ -1157,53 +1156,11 @@ struct gk20a { | |||
1157 | 1156 | ||
1158 | struct nvgpu_gpu_characteristics gpu_characteristics; | 1157 | struct nvgpu_gpu_characteristics gpu_characteristics; |
1159 | 1158 | ||
1160 | struct { | ||
1161 | struct cdev cdev; | ||
1162 | struct device *node; | ||
1163 | } channel; | ||
1164 | |||
1165 | struct gk20a_as as; | 1159 | struct gk20a_as as; |
1166 | 1160 | ||
1167 | struct { | ||
1168 | struct cdev cdev; | ||
1169 | struct device *node; | ||
1170 | } ctrl; | ||
1171 | |||
1172 | struct { | ||
1173 | struct cdev cdev; | ||
1174 | struct device *node; | ||
1175 | } as_dev; | ||
1176 | |||
1177 | struct { | ||
1178 | struct cdev cdev; | ||
1179 | struct device *node; | ||
1180 | } dbg; | ||
1181 | |||
1182 | struct { | ||
1183 | struct cdev cdev; | ||
1184 | struct device *node; | ||
1185 | } prof; | ||
1186 | |||
1187 | struct { | ||
1188 | struct cdev cdev; | ||
1189 | struct device *node; | ||
1190 | } tsg; | ||
1191 | |||
1192 | struct { | ||
1193 | struct cdev cdev; | ||
1194 | struct device *node; | ||
1195 | } ctxsw; | ||
1196 | |||
1197 | struct { | ||
1198 | struct cdev cdev; | ||
1199 | struct device *node; | ||
1200 | } sched; | ||
1201 | |||
1202 | struct nvgpu_mutex client_lock; | 1161 | struct nvgpu_mutex client_lock; |
1203 | int client_refcount; /* open channels and ctrl nodes */ | 1162 | int client_refcount; /* open channels and ctrl nodes */ |
1204 | 1163 | ||
1205 | dev_t cdev_region; | ||
1206 | |||
1207 | struct gpu_ops ops; | 1164 | struct gpu_ops ops; |
1208 | 1165 | ||
1209 | int irqs_enabled; | 1166 | int irqs_enabled; |
@@ -1518,10 +1475,6 @@ static inline u32 scale_ptimer(u32 timeout , u32 scale10x) | |||
1518 | return (timeout * 10) / scale10x; | 1475 | return (timeout * 10) / scale10x; |
1519 | } | 1476 | } |
1520 | 1477 | ||
1521 | extern struct class nvgpu_class; | ||
1522 | |||
1523 | #define INTERFACE_NAME "nvhost%s-gpu" | ||
1524 | |||
1525 | int gk20a_prepare_poweroff(struct gk20a *g); | 1478 | int gk20a_prepare_poweroff(struct gk20a *g); |
1526 | int gk20a_finalize_poweron(struct gk20a *g); | 1479 | int gk20a_finalize_poweron(struct gk20a *g); |
1527 | 1480 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c index 3f3119af..014848ba 100644 --- a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "gk20a.h" | 25 | #include "gk20a.h" |
26 | #include "gr_gk20a.h" | 26 | #include "gr_gk20a.h" |
27 | #include "sched_gk20a.h" | 27 | #include "sched_gk20a.h" |
28 | #include "common/linux/os_linux.h" | ||
28 | 29 | ||
29 | #include <nvgpu/hw/gk20a/hw_ctxsw_prog_gk20a.h> | 30 | #include <nvgpu/hw/gk20a/hw_ctxsw_prog_gk20a.h> |
30 | #include <nvgpu/hw/gk20a/hw_gr_gk20a.h> | 31 | #include <nvgpu/hw/gk20a/hw_gr_gk20a.h> |
@@ -370,12 +371,13 @@ static int gk20a_sched_dev_ioctl_put_tsg(struct gk20a_sched_ctrl *sched, | |||
370 | 371 | ||
371 | int gk20a_sched_dev_open(struct inode *inode, struct file *filp) | 372 | int gk20a_sched_dev_open(struct inode *inode, struct file *filp) |
372 | { | 373 | { |
373 | struct gk20a *g = container_of(inode->i_cdev, | 374 | struct nvgpu_os_linux *l = container_of(inode->i_cdev, |
374 | struct gk20a, sched.cdev); | 375 | struct nvgpu_os_linux, sched.cdev); |
376 | struct gk20a *g; | ||
375 | struct gk20a_sched_ctrl *sched; | 377 | struct gk20a_sched_ctrl *sched; |
376 | int err = 0; | 378 | int err = 0; |
377 | 379 | ||
378 | g = gk20a_get(g); | 380 | g = gk20a_get(&l->g); |
379 | if (!g) | 381 | if (!g) |
380 | return -ENODEV; | 382 | return -ENODEV; |
381 | sched = &g->sched_ctrl; | 383 | sched = &g->sched_ctrl; |
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index a9f102c8..b3bb4242 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #include "gk20a/channel_gk20a.h" | 35 | #include "gk20a/channel_gk20a.h" |
36 | #include "gm20b/hal_gm20b.h" | 36 | #include "gm20b/hal_gm20b.h" |
37 | 37 | ||
38 | #include "common/linux/module.h" | ||
39 | #include "common/linux/os_linux.h" | ||
40 | |||
38 | #include <nvgpu/hw/gk20a/hw_mc_gk20a.h> | 41 | #include <nvgpu/hw/gk20a/hw_mc_gk20a.h> |
39 | 42 | ||
40 | static inline int vgpu_comm_init(struct platform_device *pdev) | 43 | static inline int vgpu_comm_init(struct platform_device *pdev) |
@@ -628,6 +631,7 @@ static int vgpu_get_constants(struct gk20a *g) | |||
628 | 631 | ||
629 | int vgpu_probe(struct platform_device *pdev) | 632 | int vgpu_probe(struct platform_device *pdev) |
630 | { | 633 | { |
634 | struct nvgpu_os_linux *l; | ||
631 | struct gk20a *gk20a; | 635 | struct gk20a *gk20a; |
632 | int err; | 636 | int err; |
633 | struct device *dev = &pdev->dev; | 637 | struct device *dev = &pdev->dev; |
@@ -641,11 +645,12 @@ int vgpu_probe(struct platform_device *pdev) | |||
641 | 645 | ||
642 | gk20a_dbg_fn(""); | 646 | gk20a_dbg_fn(""); |
643 | 647 | ||
644 | gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); | 648 | l = kzalloc(sizeof(*l), GFP_KERNEL); |
645 | if (!gk20a) { | 649 | if (!l) { |
646 | dev_err(dev, "couldn't allocate gk20a support"); | 650 | dev_err(dev, "couldn't allocate gk20a support"); |
647 | return -ENOMEM; | 651 | return -ENOMEM; |
648 | } | 652 | } |
653 | gk20a = &l->g; | ||
649 | 654 | ||
650 | nvgpu_kmem_init(gk20a); | 655 | nvgpu_kmem_init(gk20a); |
651 | 656 | ||