summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-06-20 15:18:47 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-06-21 20:34:49 -0400
commit92c43deefca150854193c6720717d56b61989c23 (patch)
tree2dbfdcdb3a0809b80d4fc50e1d882326e54c7d17 /drivers/gpu/nvgpu/common
parent2ffbdc50d884215ba043e8afd3c3bcbefd1e66f8 (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/gpu/nvgpu/common')
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl.c74
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_as.c5
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_channel.c9
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c14
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_tsg.c9
-rw-r--r--drivers/gpu/nvgpu/common/linux/module.c7
-rw-r--r--drivers/gpu/nvgpu/common/linux/module.h2
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_linux.h76
-rw-r--r--drivers/gpu/nvgpu/common/linux/pci.c11
9 files changed, 154 insertions, 53 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(
162void gk20a_user_deinit(struct device *dev, struct class *class) 164void 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
210int gk20a_user_init(struct device *dev, const char *interface_name, 213int 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
34static int gk20a_as_ioctl_bind_channel( 35static 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
254int gk20a_as_dev_open(struct inode *inode, struct file *filp) 255int 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
37static void gk20a_channel_trace_sched_param( 38static 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
360int gk20a_channel_open(struct inode *inode, struct file *filp) 361int 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
49int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) 50int 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:
239static int gk20a_ctrl_open_tsg(struct gk20a *g, 242static 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
33struct tsg_private { 34struct tsg_private {
34 struct gk20a *g; 35 struct gk20a *g;
@@ -240,13 +241,13 @@ free_ref:
240 241
241int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp) 242int 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
850static int gk20a_probe(struct platform_device *dev) 851static 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;
19int gk20a_pm_finalize_poweron(struct device *dev); 19int gk20a_pm_finalize_poweron(struct device *dev);
20void gk20a_remove_support(struct gk20a *g); 20void gk20a_remove_support(struct gk20a *g);
21 21
22extern 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
23struct 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
69static 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
37static int nvgpu_pci_tegra_probe(struct device *dev) 39static 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);