diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2017-03-28 16:20:42 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-02 11:28:21 -0400 |
commit | 9adc49f94bd9df94e7d77b08eb2b6e98d7eb5758 (patch) | |
tree | 132092da9569c2556259e769e919a26befbc00f2 /drivers | |
parent | dd88aed5cc3088285c5d0b900aebf705f52178c5 (diff) |
gpu: nvgpu: Move devnode creation to Linux module
Move Linux specific code to create devnodes to Linux module.
JIRA NVGPU-16
Change-Id: I7f8f74d72f16857973da029b9f949ee8b553eb59
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1330801
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/Makefile.nvgpu | 1 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl.c | 285 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.c | 259 |
3 files changed, 286 insertions, 259 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu index 143224c8..d0eb1085 100644 --- a/drivers/gpu/nvgpu/Makefile.nvgpu +++ b/drivers/gpu/nvgpu/Makefile.nvgpu | |||
@@ -25,6 +25,7 @@ obj-$(CONFIG_GK20A) := nvgpu.o | |||
25 | nvgpu-y := \ | 25 | nvgpu-y := \ |
26 | common/linux/kmem.o \ | 26 | common/linux/kmem.o \ |
27 | common/linux/timers.o \ | 27 | common/linux/timers.o \ |
28 | common/linux/ioctl.o \ | ||
28 | common/mm/nvgpu_allocator.o \ | 29 | common/mm/nvgpu_allocator.o \ |
29 | common/mm/bitmap_allocator.o \ | 30 | common/mm/bitmap_allocator.o \ |
30 | common/mm/buddy_allocator.o \ | 31 | common/mm/buddy_allocator.o \ |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl.c b/drivers/gpu/nvgpu/common/linux/ioctl.c new file mode 100644 index 00000000..083d6102 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/ioctl.c | |||
@@ -0,0 +1,285 @@ | |||
1 | /* | ||
2 | * NVGPU IOCTLs | ||
3 | * | ||
4 | * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <linux/file.h> | ||
20 | |||
21 | #include <nvgpu/nvgpu_common.h> | ||
22 | |||
23 | #include "gk20a/gk20a.h" | ||
24 | #include "gk20a/dbg_gpu_gk20a.h" | ||
25 | #include "gk20a/ctxsw_trace_gk20a.h" | ||
26 | #include "gk20a/channel_gk20a.h" | ||
27 | #include "gk20a/ctrl_gk20a.h" | ||
28 | #include "gk20a/as_gk20a.h" | ||
29 | #include "gk20a/tsg_gk20a.h" | ||
30 | |||
31 | #define GK20A_NUM_CDEVS 7 | ||
32 | |||
33 | const struct file_operations gk20a_channel_ops = { | ||
34 | .owner = THIS_MODULE, | ||
35 | .release = gk20a_channel_release, | ||
36 | .open = gk20a_channel_open, | ||
37 | #ifdef CONFIG_COMPAT | ||
38 | .compat_ioctl = gk20a_channel_ioctl, | ||
39 | #endif | ||
40 | .unlocked_ioctl = gk20a_channel_ioctl, | ||
41 | }; | ||
42 | |||
43 | static const struct file_operations gk20a_ctrl_ops = { | ||
44 | .owner = THIS_MODULE, | ||
45 | .release = gk20a_ctrl_dev_release, | ||
46 | .open = gk20a_ctrl_dev_open, | ||
47 | .unlocked_ioctl = gk20a_ctrl_dev_ioctl, | ||
48 | #ifdef CONFIG_COMPAT | ||
49 | .compat_ioctl = gk20a_ctrl_dev_ioctl, | ||
50 | #endif | ||
51 | }; | ||
52 | |||
53 | static const struct file_operations gk20a_dbg_ops = { | ||
54 | .owner = THIS_MODULE, | ||
55 | .release = gk20a_dbg_gpu_dev_release, | ||
56 | .open = gk20a_dbg_gpu_dev_open, | ||
57 | .unlocked_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
58 | .poll = gk20a_dbg_gpu_dev_poll, | ||
59 | #ifdef CONFIG_COMPAT | ||
60 | .compat_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
61 | #endif | ||
62 | }; | ||
63 | |||
64 | static const struct file_operations gk20a_as_ops = { | ||
65 | .owner = THIS_MODULE, | ||
66 | .release = gk20a_as_dev_release, | ||
67 | .open = gk20a_as_dev_open, | ||
68 | #ifdef CONFIG_COMPAT | ||
69 | .compat_ioctl = gk20a_as_dev_ioctl, | ||
70 | #endif | ||
71 | .unlocked_ioctl = gk20a_as_dev_ioctl, | ||
72 | }; | ||
73 | |||
74 | /* | ||
75 | * Note: We use a different 'open' to trigger handling of the profiler session. | ||
76 | * Most of the code is shared between them... Though, at some point if the | ||
77 | * code does get too tangled trying to handle each in the same path we can | ||
78 | * separate them cleanly. | ||
79 | */ | ||
80 | static const struct file_operations gk20a_prof_ops = { | ||
81 | .owner = THIS_MODULE, | ||
82 | .release = gk20a_dbg_gpu_dev_release, | ||
83 | .open = gk20a_prof_gpu_dev_open, | ||
84 | .unlocked_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
85 | #ifdef CONFIG_COMPAT | ||
86 | .compat_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
87 | #endif | ||
88 | }; | ||
89 | |||
90 | static const struct file_operations gk20a_tsg_ops = { | ||
91 | .owner = THIS_MODULE, | ||
92 | .release = gk20a_tsg_dev_release, | ||
93 | .open = gk20a_tsg_dev_open, | ||
94 | #ifdef CONFIG_COMPAT | ||
95 | .compat_ioctl = gk20a_tsg_dev_ioctl, | ||
96 | #endif | ||
97 | .unlocked_ioctl = gk20a_tsg_dev_ioctl, | ||
98 | }; | ||
99 | |||
100 | static const struct file_operations gk20a_ctxsw_ops = { | ||
101 | .owner = THIS_MODULE, | ||
102 | .release = gk20a_ctxsw_dev_release, | ||
103 | .open = gk20a_ctxsw_dev_open, | ||
104 | #ifdef CONFIG_COMPAT | ||
105 | .compat_ioctl = gk20a_ctxsw_dev_ioctl, | ||
106 | #endif | ||
107 | .unlocked_ioctl = gk20a_ctxsw_dev_ioctl, | ||
108 | .poll = gk20a_ctxsw_dev_poll, | ||
109 | .read = gk20a_ctxsw_dev_read, | ||
110 | .mmap = gk20a_ctxsw_dev_mmap, | ||
111 | }; | ||
112 | |||
113 | static const struct file_operations gk20a_sched_ops = { | ||
114 | .owner = THIS_MODULE, | ||
115 | .release = gk20a_sched_dev_release, | ||
116 | .open = gk20a_sched_dev_open, | ||
117 | #ifdef CONFIG_COMPAT | ||
118 | .compat_ioctl = gk20a_sched_dev_ioctl, | ||
119 | #endif | ||
120 | .unlocked_ioctl = gk20a_sched_dev_ioctl, | ||
121 | .poll = gk20a_sched_dev_poll, | ||
122 | .read = gk20a_sched_dev_read, | ||
123 | }; | ||
124 | |||
125 | static int gk20a_create_device( | ||
126 | struct device *dev, int devno, | ||
127 | const char *interface_name, const char *cdev_name, | ||
128 | struct cdev *cdev, struct device **out, | ||
129 | const struct file_operations *ops, | ||
130 | struct class *class) | ||
131 | { | ||
132 | struct device *subdev; | ||
133 | int err; | ||
134 | |||
135 | gk20a_dbg_fn(""); | ||
136 | |||
137 | cdev_init(cdev, ops); | ||
138 | cdev->owner = THIS_MODULE; | ||
139 | |||
140 | err = cdev_add(cdev, devno, 1); | ||
141 | if (err) { | ||
142 | dev_err(dev, "failed to add %s cdev\n", cdev_name); | ||
143 | return err; | ||
144 | } | ||
145 | |||
146 | subdev = device_create(class, NULL, devno, NULL, | ||
147 | interface_name, cdev_name); | ||
148 | |||
149 | if (IS_ERR(subdev)) { | ||
150 | err = PTR_ERR(dev); | ||
151 | cdev_del(cdev); | ||
152 | dev_err(dev, "failed to create %s device for %s\n", | ||
153 | cdev_name, dev_name(dev)); | ||
154 | return err; | ||
155 | } | ||
156 | |||
157 | *out = subdev; | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | void gk20a_user_deinit(struct device *dev, struct class *class) | ||
162 | { | ||
163 | struct gk20a *g = gk20a_from_dev(dev); | ||
164 | |||
165 | if (g->channel.node) { | ||
166 | device_destroy(class, g->channel.cdev.dev); | ||
167 | cdev_del(&g->channel.cdev); | ||
168 | } | ||
169 | |||
170 | if (g->as.node) { | ||
171 | device_destroy(class, g->as.cdev.dev); | ||
172 | cdev_del(&g->as.cdev); | ||
173 | } | ||
174 | |||
175 | if (g->ctrl.node) { | ||
176 | device_destroy(class, g->ctrl.cdev.dev); | ||
177 | cdev_del(&g->ctrl.cdev); | ||
178 | } | ||
179 | |||
180 | if (g->dbg.node) { | ||
181 | device_destroy(class, g->dbg.cdev.dev); | ||
182 | cdev_del(&g->dbg.cdev); | ||
183 | } | ||
184 | |||
185 | if (g->prof.node) { | ||
186 | device_destroy(class, g->prof.cdev.dev); | ||
187 | cdev_del(&g->prof.cdev); | ||
188 | } | ||
189 | |||
190 | if (g->tsg.node) { | ||
191 | device_destroy(class, g->tsg.cdev.dev); | ||
192 | cdev_del(&g->tsg.cdev); | ||
193 | } | ||
194 | |||
195 | if (g->ctxsw.node) { | ||
196 | device_destroy(class, g->ctxsw.cdev.dev); | ||
197 | cdev_del(&g->ctxsw.cdev); | ||
198 | } | ||
199 | |||
200 | if (g->sched.node) { | ||
201 | device_destroy(class, g->sched.cdev.dev); | ||
202 | cdev_del(&g->sched.cdev); | ||
203 | } | ||
204 | |||
205 | if (g->cdev_region) | ||
206 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); | ||
207 | } | ||
208 | |||
209 | int gk20a_user_init(struct device *dev, const char *interface_name, | ||
210 | struct class *class) | ||
211 | { | ||
212 | int err; | ||
213 | dev_t devno; | ||
214 | struct gk20a *g = gk20a_from_dev(dev); | ||
215 | |||
216 | err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev)); | ||
217 | if (err) { | ||
218 | dev_err(dev, "failed to allocate devno\n"); | ||
219 | goto fail; | ||
220 | } | ||
221 | g->cdev_region = devno; | ||
222 | |||
223 | err = gk20a_create_device(dev, devno++, interface_name, "", | ||
224 | &g->channel.cdev, &g->channel.node, | ||
225 | &gk20a_channel_ops, | ||
226 | class); | ||
227 | if (err) | ||
228 | goto fail; | ||
229 | |||
230 | err = gk20a_create_device(dev, devno++, interface_name, "-as", | ||
231 | &g->as.cdev, &g->as.node, | ||
232 | &gk20a_as_ops, | ||
233 | class); | ||
234 | if (err) | ||
235 | goto fail; | ||
236 | |||
237 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", | ||
238 | &g->ctrl.cdev, &g->ctrl.node, | ||
239 | &gk20a_ctrl_ops, | ||
240 | class); | ||
241 | if (err) | ||
242 | goto fail; | ||
243 | |||
244 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", | ||
245 | &g->dbg.cdev, &g->dbg.node, | ||
246 | &gk20a_dbg_ops, | ||
247 | class); | ||
248 | if (err) | ||
249 | goto fail; | ||
250 | |||
251 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", | ||
252 | &g->prof.cdev, &g->prof.node, | ||
253 | &gk20a_prof_ops, | ||
254 | class); | ||
255 | if (err) | ||
256 | goto fail; | ||
257 | |||
258 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", | ||
259 | &g->tsg.cdev, &g->tsg.node, | ||
260 | &gk20a_tsg_ops, | ||
261 | class); | ||
262 | if (err) | ||
263 | goto fail; | ||
264 | |||
265 | #ifdef CONFIG_GK20A_CTXSW_TRACE | ||
266 | err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw", | ||
267 | &g->ctxsw.cdev, &g->ctxsw.node, | ||
268 | &gk20a_ctxsw_ops, | ||
269 | class); | ||
270 | if (err) | ||
271 | goto fail; | ||
272 | #endif | ||
273 | |||
274 | err = gk20a_create_device(dev, devno++, interface_name, "-sched", | ||
275 | &g->sched.cdev, &g->sched.node, | ||
276 | &gk20a_sched_ops, | ||
277 | class); | ||
278 | if (err) | ||
279 | goto fail; | ||
280 | |||
281 | return 0; | ||
282 | fail: | ||
283 | gk20a_user_deinit(dev, &nvgpu_class); | ||
284 | return err; | ||
285 | } | ||
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 060429d1..1c75123f 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c | |||
@@ -19,12 +19,10 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/dma-mapping.h> | 20 | #include <linux/dma-mapping.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/cdev.h> | ||
23 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
24 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
25 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
26 | #include <linux/export.h> | 25 | #include <linux/export.h> |
27 | #include <linux/file.h> | ||
28 | #include <linux/of.h> | 26 | #include <linux/of.h> |
29 | #include <linux/of_device.h> | 27 | #include <linux/of_device.h> |
30 | #include <linux/of_platform.h> | 28 | #include <linux/of_platform.h> |
@@ -48,7 +46,6 @@ | |||
48 | 46 | ||
49 | #include "gk20a.h" | 47 | #include "gk20a.h" |
50 | #include "debug_gk20a.h" | 48 | #include "debug_gk20a.h" |
51 | #include "ctrl_gk20a.h" | ||
52 | #include "channel_sync_gk20a.h" | 49 | #include "channel_sync_gk20a.h" |
53 | 50 | ||
54 | #include "gk20a_scale.h" | 51 | #include "gk20a_scale.h" |
@@ -167,100 +164,6 @@ static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a) | |||
167 | gk20a_get_platform(&pdev->dev)->g = gk20a; | 164 | gk20a_get_platform(&pdev->dev)->g = gk20a; |
168 | } | 165 | } |
169 | 166 | ||
170 | const struct file_operations gk20a_channel_ops = { | ||
171 | .owner = THIS_MODULE, | ||
172 | .release = gk20a_channel_release, | ||
173 | .open = gk20a_channel_open, | ||
174 | #ifdef CONFIG_COMPAT | ||
175 | .compat_ioctl = gk20a_channel_ioctl, | ||
176 | #endif | ||
177 | .unlocked_ioctl = gk20a_channel_ioctl, | ||
178 | }; | ||
179 | |||
180 | static const struct file_operations gk20a_ctrl_ops = { | ||
181 | .owner = THIS_MODULE, | ||
182 | .release = gk20a_ctrl_dev_release, | ||
183 | .open = gk20a_ctrl_dev_open, | ||
184 | .unlocked_ioctl = gk20a_ctrl_dev_ioctl, | ||
185 | #ifdef CONFIG_COMPAT | ||
186 | .compat_ioctl = gk20a_ctrl_dev_ioctl, | ||
187 | #endif | ||
188 | }; | ||
189 | |||
190 | static const struct file_operations gk20a_dbg_ops = { | ||
191 | .owner = THIS_MODULE, | ||
192 | .release = gk20a_dbg_gpu_dev_release, | ||
193 | .open = gk20a_dbg_gpu_dev_open, | ||
194 | .unlocked_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
195 | .poll = gk20a_dbg_gpu_dev_poll, | ||
196 | #ifdef CONFIG_COMPAT | ||
197 | .compat_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
198 | #endif | ||
199 | }; | ||
200 | |||
201 | static const struct file_operations gk20a_as_ops = { | ||
202 | .owner = THIS_MODULE, | ||
203 | .release = gk20a_as_dev_release, | ||
204 | .open = gk20a_as_dev_open, | ||
205 | #ifdef CONFIG_COMPAT | ||
206 | .compat_ioctl = gk20a_as_dev_ioctl, | ||
207 | #endif | ||
208 | .unlocked_ioctl = gk20a_as_dev_ioctl, | ||
209 | }; | ||
210 | |||
211 | /* | ||
212 | * Note: We use a different 'open' to trigger handling of the profiler session. | ||
213 | * Most of the code is shared between them... Though, at some point if the | ||
214 | * code does get too tangled trying to handle each in the same path we can | ||
215 | * separate them cleanly. | ||
216 | */ | ||
217 | static const struct file_operations gk20a_prof_ops = { | ||
218 | .owner = THIS_MODULE, | ||
219 | .release = gk20a_dbg_gpu_dev_release, | ||
220 | .open = gk20a_prof_gpu_dev_open, | ||
221 | .unlocked_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
222 | /* .mmap = gk20a_prof_gpu_dev_mmap,*/ | ||
223 | /*int (*mmap) (struct file *, struct vm_area_struct *);*/ | ||
224 | #ifdef CONFIG_COMPAT | ||
225 | .compat_ioctl = gk20a_dbg_gpu_dev_ioctl, | ||
226 | #endif | ||
227 | }; | ||
228 | |||
229 | static const struct file_operations gk20a_tsg_ops = { | ||
230 | .owner = THIS_MODULE, | ||
231 | .release = gk20a_tsg_dev_release, | ||
232 | .open = gk20a_tsg_dev_open, | ||
233 | #ifdef CONFIG_COMPAT | ||
234 | .compat_ioctl = gk20a_tsg_dev_ioctl, | ||
235 | #endif | ||
236 | .unlocked_ioctl = gk20a_tsg_dev_ioctl, | ||
237 | }; | ||
238 | |||
239 | static const struct file_operations gk20a_ctxsw_ops = { | ||
240 | .owner = THIS_MODULE, | ||
241 | .release = gk20a_ctxsw_dev_release, | ||
242 | .open = gk20a_ctxsw_dev_open, | ||
243 | #ifdef CONFIG_COMPAT | ||
244 | .compat_ioctl = gk20a_ctxsw_dev_ioctl, | ||
245 | #endif | ||
246 | .unlocked_ioctl = gk20a_ctxsw_dev_ioctl, | ||
247 | .poll = gk20a_ctxsw_dev_poll, | ||
248 | .read = gk20a_ctxsw_dev_read, | ||
249 | .mmap = gk20a_ctxsw_dev_mmap, | ||
250 | }; | ||
251 | |||
252 | static const struct file_operations gk20a_sched_ops = { | ||
253 | .owner = THIS_MODULE, | ||
254 | .release = gk20a_sched_dev_release, | ||
255 | .open = gk20a_sched_dev_open, | ||
256 | #ifdef CONFIG_COMPAT | ||
257 | .compat_ioctl = gk20a_sched_dev_ioctl, | ||
258 | #endif | ||
259 | .unlocked_ioctl = gk20a_sched_dev_ioctl, | ||
260 | .poll = gk20a_sched_dev_poll, | ||
261 | .read = gk20a_sched_dev_read, | ||
262 | }; | ||
263 | |||
264 | void __nvgpu_check_gpu_state(struct gk20a *g) | 167 | void __nvgpu_check_gpu_state(struct gk20a *g) |
265 | { | 168 | { |
266 | u32 boot_0 = g->ops.mc.boot_0(g, NULL, NULL, NULL); | 169 | u32 boot_0 = g->ops.mc.boot_0(g, NULL, NULL, NULL); |
@@ -773,168 +676,6 @@ static struct of_device_id tegra_gk20a_of_match[] = { | |||
773 | { }, | 676 | { }, |
774 | }; | 677 | }; |
775 | 678 | ||
776 | static int gk20a_create_device( | ||
777 | struct device *dev, int devno, | ||
778 | const char *interface_name, const char *cdev_name, | ||
779 | struct cdev *cdev, struct device **out, | ||
780 | const struct file_operations *ops, | ||
781 | struct class *class) | ||
782 | { | ||
783 | struct device *subdev; | ||
784 | int err; | ||
785 | |||
786 | gk20a_dbg_fn(""); | ||
787 | |||
788 | cdev_init(cdev, ops); | ||
789 | cdev->owner = THIS_MODULE; | ||
790 | |||
791 | err = cdev_add(cdev, devno, 1); | ||
792 | if (err) { | ||
793 | dev_err(dev, "failed to add %s cdev\n", cdev_name); | ||
794 | return err; | ||
795 | } | ||
796 | |||
797 | subdev = device_create(class, NULL, devno, NULL, | ||
798 | interface_name, cdev_name); | ||
799 | |||
800 | if (IS_ERR(subdev)) { | ||
801 | err = PTR_ERR(dev); | ||
802 | cdev_del(cdev); | ||
803 | dev_err(dev, "failed to create %s device\n", | ||
804 | cdev_name); | ||
805 | return err; | ||
806 | } | ||
807 | |||
808 | *out = subdev; | ||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | void gk20a_user_deinit(struct device *dev, struct class *class) | ||
813 | { | ||
814 | struct gk20a *g = gk20a_from_dev(dev); | ||
815 | |||
816 | if (g->channel.node) { | ||
817 | device_destroy(class, g->channel.cdev.dev); | ||
818 | cdev_del(&g->channel.cdev); | ||
819 | } | ||
820 | |||
821 | if (g->as.node) { | ||
822 | device_destroy(class, g->as.cdev.dev); | ||
823 | cdev_del(&g->as.cdev); | ||
824 | } | ||
825 | |||
826 | if (g->ctrl.node) { | ||
827 | device_destroy(class, g->ctrl.cdev.dev); | ||
828 | cdev_del(&g->ctrl.cdev); | ||
829 | } | ||
830 | |||
831 | if (g->dbg.node) { | ||
832 | device_destroy(class, g->dbg.cdev.dev); | ||
833 | cdev_del(&g->dbg.cdev); | ||
834 | } | ||
835 | |||
836 | if (g->prof.node) { | ||
837 | device_destroy(class, g->prof.cdev.dev); | ||
838 | cdev_del(&g->prof.cdev); | ||
839 | } | ||
840 | |||
841 | if (g->tsg.node) { | ||
842 | device_destroy(class, g->tsg.cdev.dev); | ||
843 | cdev_del(&g->tsg.cdev); | ||
844 | } | ||
845 | |||
846 | if (g->ctxsw.node) { | ||
847 | device_destroy(class, g->ctxsw.cdev.dev); | ||
848 | cdev_del(&g->ctxsw.cdev); | ||
849 | } | ||
850 | |||
851 | if (g->sched.node) { | ||
852 | device_destroy(class, g->sched.cdev.dev); | ||
853 | cdev_del(&g->sched.cdev); | ||
854 | } | ||
855 | |||
856 | if (g->cdev_region) | ||
857 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); | ||
858 | } | ||
859 | |||
860 | int gk20a_user_init(struct device *dev, const char *interface_name, | ||
861 | struct class *class) | ||
862 | { | ||
863 | int err; | ||
864 | dev_t devno; | ||
865 | struct gk20a *g = gk20a_from_dev(dev); | ||
866 | |||
867 | err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev)); | ||
868 | if (err) { | ||
869 | dev_err(dev, "failed to allocate devno\n"); | ||
870 | goto fail; | ||
871 | } | ||
872 | g->cdev_region = devno; | ||
873 | |||
874 | err = gk20a_create_device(dev, devno++, interface_name, "", | ||
875 | &g->channel.cdev, &g->channel.node, | ||
876 | &gk20a_channel_ops, | ||
877 | class); | ||
878 | if (err) | ||
879 | goto fail; | ||
880 | |||
881 | err = gk20a_create_device(dev, devno++, interface_name, "-as", | ||
882 | &g->as.cdev, &g->as.node, | ||
883 | &gk20a_as_ops, | ||
884 | class); | ||
885 | if (err) | ||
886 | goto fail; | ||
887 | |||
888 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", | ||
889 | &g->ctrl.cdev, &g->ctrl.node, | ||
890 | &gk20a_ctrl_ops, | ||
891 | class); | ||
892 | if (err) | ||
893 | goto fail; | ||
894 | |||
895 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", | ||
896 | &g->dbg.cdev, &g->dbg.node, | ||
897 | &gk20a_dbg_ops, | ||
898 | class); | ||
899 | if (err) | ||
900 | goto fail; | ||
901 | |||
902 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", | ||
903 | &g->prof.cdev, &g->prof.node, | ||
904 | &gk20a_prof_ops, | ||
905 | class); | ||
906 | if (err) | ||
907 | goto fail; | ||
908 | |||
909 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", | ||
910 | &g->tsg.cdev, &g->tsg.node, | ||
911 | &gk20a_tsg_ops, | ||
912 | class); | ||
913 | if (err) | ||
914 | goto fail; | ||
915 | |||
916 | #ifdef CONFIG_GK20A_CTXSW_TRACE | ||
917 | err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw", | ||
918 | &g->ctxsw.cdev, &g->ctxsw.node, | ||
919 | &gk20a_ctxsw_ops, | ||
920 | class); | ||
921 | if (err) | ||
922 | goto fail; | ||
923 | #endif | ||
924 | |||
925 | err = gk20a_create_device(dev, devno++, interface_name, "-sched", | ||
926 | &g->sched.cdev, &g->sched.node, | ||
927 | &gk20a_sched_ops, | ||
928 | class); | ||
929 | if (err) | ||
930 | goto fail; | ||
931 | |||
932 | return 0; | ||
933 | fail: | ||
934 | gk20a_user_deinit(dev, &nvgpu_class); | ||
935 | return err; | ||
936 | } | ||
937 | |||
938 | static int gk20a_pm_railgate(struct device *dev) | 679 | static int gk20a_pm_railgate(struct device *dev) |
939 | { | 680 | { |
940 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 681 | struct gk20a_platform *platform = dev_get_drvdata(dev); |