summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-06-21 18:56:05 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-06-30 21:34:59 -0400
commitbab823973b0630e2f4515d5aabbe4fb46cdf3195 (patch)
tree9e19ed71ed9a57b15a3f3b48ffbbbc1b196bf4d6 /drivers/gpu/nvgpu
parent6f0fcbc667ca55ed25818467069853e6d750cd7d (diff)
gpu: nvgpu: Use accessor for finding struct device
Use dev_from_gk20a() accessor whenever accessing struct device * from struct gk20a. JIRA NVGPU-38 Change-Id: Ide9fca3a56436c8f62e7872580a766c4c1e2353e Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master/r/1507930 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r--drivers/gpu/nvgpu/clk/clk_arb.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/clk.c4
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug.c14
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_allocator.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_cde.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_ce.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_clk.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_fifo.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_gr.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_kmem.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_mm.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_pmu.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_sched.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/driver_common.c28
-rw-r--r--drivers/gpu/nvgpu/common/linux/firmware.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_channel.c9
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/log.c3
-rw-r--r--drivers/gpu/nvgpu/common/linux/module.c10
-rw-r--r--drivers/gpu/nvgpu/common/linux/nvhost.c7
-rw-r--r--drivers/gpu/nvgpu/common/linux/pci.c6
-rw-r--r--drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/sysfs.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/vm.c14
-rw-r--r--drivers/gpu/nvgpu/gk20a/cde_gk20a.c12
-rw-r--r--drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c2
-rw-r--r--drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c4
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c12
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c2
-rw-r--r--drivers/gpu/nvgpu/gm206/bios_gm206.c4
-rw-r--r--drivers/gpu/nvgpu/gm20b/gr_gm20b.c3
-rw-r--r--drivers/gpu/nvgpu/gp106/clk_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp106/mclk_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp106/therm_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.c3
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgr.c2
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgrpmu.c2
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrpolicy.c2
-rw-r--r--drivers/gpu/nvgpu/vgpu/css_vgpu.c2
-rw-r--r--drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c4
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c3
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.h4
43 files changed, 105 insertions, 90 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_arb.c b/drivers/gpu/nvgpu/clk/clk_arb.c
index df62df5e..05180a38 100644
--- a/drivers/gpu/nvgpu/clk/clk_arb.c
+++ b/drivers/gpu/nvgpu/clk/clk_arb.c
@@ -2076,7 +2076,7 @@ static const struct file_operations nvgpu_clk_arb_stats_fops = {
2076 2076
2077static int nvgpu_clk_arb_debugfs_init(struct gk20a *g) 2077static int nvgpu_clk_arb_debugfs_init(struct gk20a *g)
2078{ 2078{
2079 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 2079 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
2080 2080
2081 struct dentry *gpu_root = platform->debugfs; 2081 struct dentry *gpu_root = platform->debugfs;
2082 struct dentry *d; 2082 struct dentry *d;
diff --git a/drivers/gpu/nvgpu/common/linux/clk.c b/drivers/gpu/nvgpu/common/linux/clk.c
index 775e5661..f24445b3 100644
--- a/drivers/gpu/nvgpu/common/linux/clk.c
+++ b/drivers/gpu/nvgpu/common/linux/clk.c
@@ -27,7 +27,7 @@
27 27
28static unsigned long nvgpu_linux_clk_get_rate(struct gk20a *g, u32 api_domain) 28static unsigned long nvgpu_linux_clk_get_rate(struct gk20a *g, u32 api_domain)
29{ 29{
30 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 30 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
31 unsigned long ret; 31 unsigned long ret;
32 32
33 switch (api_domain) { 33 switch (api_domain) {
@@ -52,7 +52,7 @@ static unsigned long nvgpu_linux_clk_get_rate(struct gk20a *g, u32 api_domain)
52static int nvgpu_linux_clk_set_rate(struct gk20a *g, 52static int nvgpu_linux_clk_set_rate(struct gk20a *g,
53 u32 api_domain, unsigned long rate) 53 u32 api_domain, unsigned long rate)
54{ 54{
55 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 55 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
56 int ret; 56 int ret;
57 57
58 switch (api_domain) { 58 switch (api_domain) {
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c
index 2962a467..9fd09efe 100644
--- a/drivers/gpu/nvgpu/common/linux/debug.c
+++ b/drivers/gpu/nvgpu/common/linux/debug.c
@@ -101,13 +101,13 @@ static int gk20a_gr_debug_show(struct seq_file *s, void *unused)
101 101
102void gk20a_debug_dump(struct gk20a *g) 102void gk20a_debug_dump(struct gk20a *g)
103{ 103{
104 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 104 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
105 struct gk20a_debug_output o = { 105 struct gk20a_debug_output o = {
106 .fn = gk20a_debug_write_printk 106 .fn = gk20a_debug_write_printk
107 }; 107 };
108 108
109 if (platform->dump_platform_dependencies) 109 if (platform->dump_platform_dependencies)
110 platform->dump_platform_dependencies(g->dev); 110 platform->dump_platform_dependencies(dev_from_gk20a(g));
111 111
112 /* HAL only initialized after 1st power-on */ 112 /* HAL only initialized after 1st power-on */
113 if (g->ops.debug.show_dump) 113 if (g->ops.debug.show_dump)
@@ -180,12 +180,12 @@ void gk20a_init_debug_ops(struct gpu_ops *gops)
180static int railgate_residency_show(struct seq_file *s, void *data) 180static int railgate_residency_show(struct seq_file *s, void *data)
181{ 181{
182 struct gk20a *g = s->private; 182 struct gk20a *g = s->private;
183 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 183 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
184 unsigned long time_since_last_state_transition_ms; 184 unsigned long time_since_last_state_transition_ms;
185 unsigned long total_rail_gate_time_ms; 185 unsigned long total_rail_gate_time_ms;
186 unsigned long total_rail_ungate_time_ms; 186 unsigned long total_rail_ungate_time_ms;
187 187
188 if (platform->is_railgated(g->dev)) { 188 if (platform->is_railgated(dev_from_gk20a(g))) {
189 time_since_last_state_transition_ms = 189 time_since_last_state_transition_ms =
190 jiffies_to_msecs(jiffies - 190 jiffies_to_msecs(jiffies -
191 g->pstats.last_rail_gate_complete); 191 g->pstats.last_rail_gate_complete);
@@ -227,7 +227,7 @@ static const struct file_operations railgate_residency_fops = {
227 227
228static int gk20a_railgating_debugfs_init(struct gk20a *g) 228static int gk20a_railgating_debugfs_init(struct gk20a *g)
229{ 229{
230 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 230 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
231 struct dentry *d; 231 struct dentry *d;
232 232
233 if (!g->can_railgate) 233 if (!g->can_railgate)
@@ -244,7 +244,7 @@ static int gk20a_railgating_debugfs_init(struct gk20a *g)
244 244
245void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) 245void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
246{ 246{
247 struct device *dev = g->dev; 247 struct device *dev = dev_from_gk20a(g);
248 struct gk20a_platform *platform = dev_get_drvdata(dev); 248 struct gk20a_platform *platform = dev_get_drvdata(dev);
249 249
250 platform->debugfs = debugfs_create_dir(dev_name(dev), NULL); 250 platform->debugfs = debugfs_create_dir(dev_name(dev), NULL);
@@ -364,7 +364,7 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
364 364
365void gk20a_debug_deinit(struct gk20a *g) 365void gk20a_debug_deinit(struct gk20a *g)
366{ 366{
367 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 367 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
368 368
369 if (!platform->debugfs) 369 if (!platform->debugfs)
370 return; 370 return;
diff --git a/drivers/gpu/nvgpu/common/linux/debug_allocator.c b/drivers/gpu/nvgpu/common/linux/debug_allocator.c
index 3d4a2bb2..9102b989 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_allocator.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_allocator.c
@@ -67,7 +67,7 @@ void nvgpu_fini_alloc_debug(struct nvgpu_allocator *a)
67 67
68void nvgpu_alloc_debugfs_init(struct gk20a *g) 68void nvgpu_alloc_debugfs_init(struct gk20a *g)
69{ 69{
70 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 70 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
71 71
72 g->debugfs_allocators = debugfs_create_dir("allocators", platform->debugfs); 72 g->debugfs_allocators = debugfs_create_dir("allocators", platform->debugfs);
73 if (IS_ERR_OR_NULL(g->debugfs_allocators)) { 73 if (IS_ERR_OR_NULL(g->debugfs_allocators)) {
diff --git a/drivers/gpu/nvgpu/common/linux/debug_cde.c b/drivers/gpu/nvgpu/common/linux/debug_cde.c
index eb7c33e2..d3aab3cd 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_cde.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_cde.c
@@ -33,7 +33,7 @@ static const struct file_operations gk20a_cde_reload_fops = {
33 33
34void gk20a_cde_debugfs_init(struct gk20a *g) 34void gk20a_cde_debugfs_init(struct gk20a *g)
35{ 35{
36 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 36 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
37 37
38 if (!platform->has_cde) 38 if (!platform->has_cde)
39 return; 39 return;
diff --git a/drivers/gpu/nvgpu/common/linux/debug_ce.c b/drivers/gpu/nvgpu/common/linux/debug_ce.c
index 9c50870e..95f0d2ad 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_ce.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_ce.c
@@ -19,7 +19,7 @@
19 19
20void gk20a_ce_debugfs_init(struct gk20a *g) 20void gk20a_ce_debugfs_init(struct gk20a *g)
21{ 21{
22 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 22 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
23 23
24 debugfs_create_u32("ce_app_ctx_count", S_IWUSR | S_IRUGO, 24 debugfs_create_u32("ce_app_ctx_count", S_IWUSR | S_IRUGO,
25 platform->debugfs, &g->ce_app.ctx_count); 25 platform->debugfs, &g->ce_app.ctx_count);
diff --git a/drivers/gpu/nvgpu/common/linux/debug_clk.c b/drivers/gpu/nvgpu/common/linux/debug_clk.c
index 9dfa2d77..5bbe4127 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_clk.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_clk.c
@@ -217,7 +217,7 @@ static const struct file_operations pll_param_fops = {
217int gm20b_clk_init_debugfs(struct gk20a *g) 217int gm20b_clk_init_debugfs(struct gk20a *g)
218{ 218{
219 struct dentry *d; 219 struct dentry *d;
220 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 220 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
221 221
222 if (!platform->debugfs) 222 if (!platform->debugfs)
223 return -EINVAL; 223 return -EINVAL;
diff --git a/drivers/gpu/nvgpu/common/linux/debug_fifo.c b/drivers/gpu/nvgpu/common/linux/debug_fifo.c
index 04937dbe..1fba1868 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_fifo.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_fifo.c
@@ -291,7 +291,7 @@ static const struct file_operations gk20a_fifo_profile_stats_debugfs_fops = {
291 291
292void gk20a_fifo_debugfs_init(struct gk20a *g) 292void gk20a_fifo_debugfs_init(struct gk20a *g)
293{ 293{
294 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 294 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
295 295
296 struct dentry *gpu_root = platform->debugfs; 296 struct dentry *gpu_root = platform->debugfs;
297 struct dentry *fifo_root; 297 struct dentry *fifo_root;
diff --git a/drivers/gpu/nvgpu/common/linux/debug_gr.c b/drivers/gpu/nvgpu/common/linux/debug_gr.c
index 56b8612e..1045fe0b 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_gr.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_gr.c
@@ -19,7 +19,7 @@
19 19
20int gr_gk20a_debugfs_init(struct gk20a *g) 20int gr_gk20a_debugfs_init(struct gk20a *g)
21{ 21{
22 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 22 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
23 23
24 g->debugfs_gr_default_attrib_cb_size = 24 g->debugfs_gr_default_attrib_cb_size =
25 debugfs_create_u32("gr_default_attrib_cb_size", 25 debugfs_create_u32("gr_default_attrib_cb_size",
diff --git a/drivers/gpu/nvgpu/common/linux/debug_kmem.c b/drivers/gpu/nvgpu/common/linux/debug_kmem.c
index 2ee542a8..ff8d49cd 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_kmem.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_kmem.c
@@ -295,7 +295,7 @@ static const struct file_operations __kmem_traces_fops = {
295 295
296void nvgpu_kmem_debugfs_init(struct gk20a *g) 296void nvgpu_kmem_debugfs_init(struct gk20a *g)
297{ 297{
298 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 298 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
299 struct dentry *node; 299 struct dentry *node;
300 300
301 g->debugfs_kmem = debugfs_create_dir("kmem_tracking", platform->debugfs); 301 g->debugfs_kmem = debugfs_create_dir("kmem_tracking", platform->debugfs);
diff --git a/drivers/gpu/nvgpu/common/linux/debug_mm.c b/drivers/gpu/nvgpu/common/linux/debug_mm.c
index 1e260f89..dcb83112 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_mm.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_mm.c
@@ -19,7 +19,7 @@
19 19
20void gk20a_mm_debugfs_init(struct gk20a *g) 20void gk20a_mm_debugfs_init(struct gk20a *g)
21{ 21{
22 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 22 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
23 23
24 debugfs_create_bool("force_pramin", 0664, platform->debugfs, 24 debugfs_create_bool("force_pramin", 0664, platform->debugfs,
25 &g->mm.force_pramin); 25 &g->mm.force_pramin);
diff --git a/drivers/gpu/nvgpu/common/linux/debug_pmu.c b/drivers/gpu/nvgpu/common/linux/debug_pmu.c
index 7d9f5ac3..0d364fe7 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_pmu.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_pmu.c
@@ -416,7 +416,7 @@ static const struct file_operations security_fops = {
416int gk20a_pmu_debugfs_init(struct gk20a *g) 416int gk20a_pmu_debugfs_init(struct gk20a *g)
417{ 417{
418 struct dentry *d; 418 struct dentry *d;
419 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 419 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
420 420
421 d = debugfs_create_file( 421 d = debugfs_create_file(
422 "lpwr_debug", S_IRUGO|S_IWUSR, platform->debugfs, g, 422 "lpwr_debug", S_IRUGO|S_IWUSR, platform->debugfs, g,
diff --git a/drivers/gpu/nvgpu/common/linux/debug_sched.c b/drivers/gpu/nvgpu/common/linux/debug_sched.c
index 40b93149..73fb890f 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_sched.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_sched.c
@@ -72,7 +72,7 @@ static const struct file_operations gk20a_sched_debugfs_fops = {
72 72
73void gk20a_sched_debugfs_init(struct gk20a *g) 73void gk20a_sched_debugfs_init(struct gk20a *g)
74{ 74{
75 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 75 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
76 76
77 debugfs_create_file("sched_ctrl", S_IRUGO, platform->debugfs, 77 debugfs_create_file("sched_ctrl", S_IRUGO, platform->debugfs,
78 g, &gk20a_sched_debugfs_fops); 78 g, &gk20a_sched_debugfs_fops);
diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c
index eb4f490f..c2bd9d78 100644
--- a/drivers/gpu/nvgpu/common/linux/driver_common.c
+++ b/drivers/gpu/nvgpu/common/linux/driver_common.c
@@ -35,7 +35,8 @@
35static void nvgpu_init_vars(struct gk20a *g) 35static void nvgpu_init_vars(struct gk20a *g)
36{ 36{
37 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); 37 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
38 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 38 struct device *dev = dev_from_gk20a(g);
39 struct gk20a_platform *platform = dev_get_drvdata(dev);
39 40
40 init_waitqueue_head(&g->sw_irq_stall_last_handled_wq); 41 init_waitqueue_head(&g->sw_irq_stall_last_handled_wq);
41 init_waitqueue_head(&g->sw_irq_nonstall_last_handled_wq); 42 init_waitqueue_head(&g->sw_irq_nonstall_last_handled_wq);
@@ -57,8 +58,8 @@ static void nvgpu_init_vars(struct gk20a *g)
57 g->emc3d_ratio = EMC3D_DEFAULT_RATIO; 58 g->emc3d_ratio = EMC3D_DEFAULT_RATIO;
58 59
59 /* Set DMA parameters to allow larger sgt lists */ 60 /* Set DMA parameters to allow larger sgt lists */
60 g->dev->dma_parms = &l->dma_parms; 61 dev->dma_parms = &l->dma_parms;
61 dma_set_max_seg_size(g->dev, UINT_MAX); 62 dma_set_max_seg_size(dev, UINT_MAX);
62 63
63 nvgpu_init_list_node(&g->pending_sema_waits); 64 nvgpu_init_list_node(&g->pending_sema_waits);
64 nvgpu_raw_spinlock_init(&g->pending_sema_waits_lock); 65 nvgpu_raw_spinlock_init(&g->pending_sema_waits_lock);
@@ -68,7 +69,7 @@ static void nvgpu_init_vars(struct gk20a *g)
68 69
69static void nvgpu_init_timeout(struct gk20a *g) 70static void nvgpu_init_timeout(struct gk20a *g)
70{ 71{
71 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 72 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
72 73
73 g->gr_idle_timeout_default = CONFIG_GK20A_DEFAULT_TIMEOUT; 74 g->gr_idle_timeout_default = CONFIG_GK20A_DEFAULT_TIMEOUT;
74 if (nvgpu_platform_is_silicon(g)) 75 if (nvgpu_platform_is_silicon(g))
@@ -94,7 +95,7 @@ static void nvgpu_init_timeslice(struct gk20a *g)
94 95
95static void nvgpu_init_pm_vars(struct gk20a *g) 96static void nvgpu_init_pm_vars(struct gk20a *g)
96{ 97{
97 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 98 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
98 99
99 /* 100 /*
100 * Set up initial power settings. For non-slicon platforms, disable 101 * Set up initial power settings. For non-slicon platforms, disable
@@ -119,7 +120,7 @@ static void nvgpu_init_pm_vars(struct gk20a *g)
119 g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; 120 g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh;
120 g->has_syncpoints = platform->has_syncpoints; 121 g->has_syncpoints = platform->has_syncpoints;
121 g->ptimer_src_freq = platform->ptimer_src_freq; 122 g->ptimer_src_freq = platform->ptimer_src_freq;
122 g->support_pmu = support_gk20a_pmu(g->dev); 123 g->support_pmu = support_gk20a_pmu(dev_from_gk20a(g));
123 g->can_railgate = platform->can_railgate_init; 124 g->can_railgate = platform->can_railgate_init;
124 g->railgate_delay = platform->railgate_delay_init; 125 g->railgate_delay = platform->railgate_delay_init;
125 126
@@ -133,7 +134,7 @@ static void nvgpu_init_pm_vars(struct gk20a *g)
133 134
134static void nvgpu_init_mm_vars(struct gk20a *g) 135static void nvgpu_init_mm_vars(struct gk20a *g)
135{ 136{
136 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 137 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
137 138
138 g->mm.bypass_smmu = platform->bypass_smmu; 139 g->mm.bypass_smmu = platform->bypass_smmu;
139 g->mm.disable_bigpage = platform->disable_bigpage; 140 g->mm.disable_bigpage = platform->disable_bigpage;
@@ -153,7 +154,8 @@ int nvgpu_probe(struct gk20a *g,
153 const char *interface_name, 154 const char *interface_name,
154 struct class *class) 155 struct class *class)
155{ 156{
156 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 157 struct device *dev = dev_from_gk20a(g);
158 struct gk20a_platform *platform = dev_get_drvdata(dev);
157 int err = 0; 159 int err = 0;
158 160
159 nvgpu_init_vars(g); 161 nvgpu_init_vars(g);
@@ -162,7 +164,7 @@ int nvgpu_probe(struct gk20a *g,
162 nvgpu_init_pm_vars(g); 164 nvgpu_init_pm_vars(g);
163 165
164 /* Initialize the platform interface. */ 166 /* Initialize the platform interface. */
165 err = platform->probe(g->dev); 167 err = platform->probe(dev);
166 if (err) { 168 if (err) {
167 if (err == -EPROBE_DEFER) 169 if (err == -EPROBE_DEFER)
168 nvgpu_info(g, "platform probe failed"); 170 nvgpu_info(g, "platform probe failed");
@@ -172,17 +174,17 @@ int nvgpu_probe(struct gk20a *g,
172 } 174 }
173 175
174 /* platform probe can defer do user init only if probe succeeds */ 176 /* platform probe can defer do user init only if probe succeeds */
175 err = gk20a_user_init(g->dev, interface_name, class); 177 err = gk20a_user_init(dev, interface_name, class);
176 if (err) 178 if (err)
177 return err; 179 return err;
178 180
179 181
180 /* Initialise scaling */ 182 /* Initialise scaling */
181 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) 183 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ))
182 gk20a_scale_init(g->dev); 184 gk20a_scale_init(dev);
183 185
184 if (platform->late_probe) { 186 if (platform->late_probe) {
185 err = platform->late_probe(g->dev); 187 err = platform->late_probe(dev);
186 if (err) { 188 if (err) {
187 nvgpu_err(g, "late probe failed"); 189 nvgpu_err(g, "late probe failed");
188 return err; 190 return err;
@@ -191,7 +193,7 @@ int nvgpu_probe(struct gk20a *g,
191 193
192 nvgpu_init_mm_vars(g); 194 nvgpu_init_mm_vars(g);
193 195
194 nvgpu_create_sysfs(g->dev); 196 nvgpu_create_sysfs(dev);
195 gk20a_debug_init(g, debugfs_symlink); 197 gk20a_debug_init(g, debugfs_symlink);
196 198
197 g->dbg_regops_tmp_buf = nvgpu_kzalloc(g, SZ_4K); 199 g->dbg_regops_tmp_buf = nvgpu_kzalloc(g, SZ_4K);
diff --git a/drivers/gpu/nvgpu/common/linux/firmware.c b/drivers/gpu/nvgpu/common/linux/firmware.c
index bc4e876a..549e83ae 100644
--- a/drivers/gpu/nvgpu/common/linux/firmware.c
+++ b/drivers/gpu/nvgpu/common/linux/firmware.c
@@ -65,7 +65,7 @@ struct nvgpu_firmware *nvgpu_request_firmware(struct gk20a *g,
65 const char *fw_name, 65 const char *fw_name,
66 int flags) 66 int flags)
67{ 67{
68 struct device *dev = g->dev; 68 struct device *dev = dev_from_gk20a(g);
69 struct nvgpu_firmware *fw; 69 struct nvgpu_firmware *fw;
70 const struct firmware *linux_fw; 70 const struct firmware *linux_fw;
71 71
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
index 5905e5a6..2242e19e 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
@@ -32,6 +32,7 @@
32#include "gk20a/ctxsw_trace_gk20a.h" 32#include "gk20a/ctxsw_trace_gk20a.h"
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 "gk20a/platform_gk20a.h"
35#include "ioctl_channel.h" 36#include "ioctl_channel.h"
36#include "os_linux.h" 37#include "os_linux.h"
37 38
@@ -291,7 +292,7 @@ int gk20a_channel_release(struct inode *inode, struct file *filp)
291 goto channel_release; 292 goto channel_release;
292 } 293 }
293 294
294 trace_gk20a_channel_release(dev_name(g->dev)); 295 trace_gk20a_channel_release(dev_name(dev_from_gk20a(g)));
295 296
296 gk20a_channel_close(ch); 297 gk20a_channel_close(ch);
297 gk20a_channel_free_error_notifiers(ch); 298 gk20a_channel_free_error_notifiers(ch);
@@ -319,7 +320,7 @@ static int __gk20a_channel_open(struct gk20a *g,
319 if (!g) 320 if (!g)
320 return -ENODEV; 321 return -ENODEV;
321 322
322 trace_gk20a_channel_open(dev_name(g->dev)); 323 trace_gk20a_channel_open(dev_name(dev_from_gk20a(g)));
323 324
324 priv = nvgpu_kzalloc(g, sizeof(*priv)); 325 priv = nvgpu_kzalloc(g, sizeof(*priv));
325 if (!priv) { 326 if (!priv) {
@@ -388,7 +389,7 @@ int gk20a_channel_open_ioctl(struct gk20a *g,
388 fd = err; 389 fd = err;
389 390
390 snprintf(name, sizeof(name), "nvhost-%s-fd%d", 391 snprintf(name, sizeof(name), "nvhost-%s-fd%d",
391 dev_name(g->dev), fd); 392 dev_name(dev_from_gk20a(g)), fd);
392 393
393 file = anon_inode_getfile(name, l->channel.cdev.ops, NULL, O_RDWR); 394 file = anon_inode_getfile(name, l->channel.cdev.ops, NULL, O_RDWR);
394 if (IS_ERR(file)) { 395 if (IS_ERR(file)) {
@@ -841,7 +842,7 @@ long gk20a_channel_ioctl(struct file *filp,
841{ 842{
842 struct channel_priv *priv = filp->private_data; 843 struct channel_priv *priv = filp->private_data;
843 struct channel_gk20a *ch = priv->c; 844 struct channel_gk20a *ch = priv->c;
844 struct device *dev = ch->g->dev; 845 struct device *dev = dev_from_gk20a(ch->g);
845 u8 buf[NVGPU_IOCTL_CHANNEL_MAX_ARG_SIZE] = {0}; 846 u8 buf[NVGPU_IOCTL_CHANNEL_MAX_ARG_SIZE] = {0};
846 int err = 0; 847 int err = 0;
847 848
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
index 5c5ac645..2c274f23 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
@@ -68,7 +68,7 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp)
68 goto free_ref; 68 goto free_ref;
69 } 69 }
70 filp->private_data = priv; 70 filp->private_data = priv;
71 priv->dev = g->dev; 71 priv->dev = dev_from_gk20a(g);
72 /* 72 /*
73 * We dont close the arbiter fd's after driver teardown to support 73 * We dont close the arbiter fd's after driver teardown to support
74 * GPU_LOST events, so we store g here, instead of dereferencing the 74 * GPU_LOST events, so we store g here, instead of dereferencing the
diff --git a/drivers/gpu/nvgpu/common/linux/log.c b/drivers/gpu/nvgpu/common/linux/log.c
index bb1e5f63..9883acfc 100644
--- a/drivers/gpu/nvgpu/common/linux/log.c
+++ b/drivers/gpu/nvgpu/common/linux/log.c
@@ -20,6 +20,7 @@
20#include <nvgpu/log.h> 20#include <nvgpu/log.h>
21 21
22#include "gk20a/gk20a.h" 22#include "gk20a/gk20a.h"
23#include "gk20a/platform_gk20a.h"
23 24
24/* 25/*
25 * Define a length for log buffers. This is the buffer that the 'fmt, ...' part 26 * Define a length for log buffers. This is the buffer that the 'fmt, ...' part
@@ -52,7 +53,7 @@ int nvgpu_log_mask_enabled(struct gk20a *g, u32 log_mask)
52 53
53static inline const char *nvgpu_log_name(struct gk20a *g) 54static inline const char *nvgpu_log_name(struct gk20a *g)
54{ 55{
55 return dev_name(g->dev); 56 return dev_name(dev_from_gk20a(g));
56} 57}
57 58
58#ifdef CONFIG_GK20A_TRACE_PRINTK 59#ifdef CONFIG_GK20A_TRACE_PRINTK
diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c
index bb7e260d..b107a721 100644
--- a/drivers/gpu/nvgpu/common/linux/module.c
+++ b/drivers/gpu/nvgpu/common/linux/module.c
@@ -78,7 +78,7 @@ int gk20a_busy(struct gk20a *g)
78 goto fail; 78 goto fail;
79 } 79 }
80 80
81 dev = g->dev; 81 dev = dev_from_gk20a(g);
82 82
83 if (pm_runtime_enabled(dev)) { 83 if (pm_runtime_enabled(dev)) {
84 ret = pm_runtime_get_sync(dev); 84 ret = pm_runtime_get_sync(dev);
@@ -116,7 +116,7 @@ void gk20a_idle(struct gk20a *g)
116 116
117 atomic_dec(&g->usage_count); 117 atomic_dec(&g->usage_count);
118 118
119 dev = g->dev; 119 dev = dev_from_gk20a(g);
120 120
121 if (!(dev && gk20a_can_busy(g))) 121 if (!(dev && gk20a_can_busy(g)))
122 return; 122 return;
@@ -175,7 +175,7 @@ int gk20a_pm_finalize_poweron(struct device *dev)
175 enable_irq(g->irq_nonstall); 175 enable_irq(g->irq_nonstall);
176 g->irqs_enabled = 1; 176 g->irqs_enabled = 1;
177 177
178 gk20a_scale_resume(g->dev); 178 gk20a_scale_resume(dev_from_gk20a(g));
179 179
180 if (platform->has_cde) 180 if (platform->has_cde)
181 gk20a_init_cde_support(g); 181 gk20a_init_cde_support(g);
@@ -269,7 +269,7 @@ static struct of_device_id tegra_gk20a_of_match[] = {
269 */ 269 */
270int __gk20a_do_idle(struct gk20a *g, bool force_reset) 270int __gk20a_do_idle(struct gk20a *g, bool force_reset)
271{ 271{
272 struct device *dev = g->dev; 272 struct device *dev = dev_from_gk20a(g);
273 struct gk20a_platform *platform = dev_get_drvdata(dev); 273 struct gk20a_platform *platform = dev_get_drvdata(dev);
274 struct nvgpu_timeout timeout; 274 struct nvgpu_timeout timeout;
275 int ref_cnt; 275 int ref_cnt;
@@ -410,7 +410,7 @@ static int gk20a_do_idle(void *_g)
410 */ 410 */
411int __gk20a_do_unidle(struct gk20a *g) 411int __gk20a_do_unidle(struct gk20a *g)
412{ 412{
413 struct device *dev = g->dev; 413 struct device *dev = dev_from_gk20a(g);
414 struct gk20a_platform *platform = dev_get_drvdata(dev); 414 struct gk20a_platform *platform = dev_get_drvdata(dev);
415 int err; 415 int err;
416 416
diff --git a/drivers/gpu/nvgpu/common/linux/nvhost.c b/drivers/gpu/nvgpu/common/linux/nvhost.c
index 96865f7d..8e337529 100644
--- a/drivers/gpu/nvgpu/common/linux/nvhost.c
+++ b/drivers/gpu/nvgpu/common/linux/nvhost.c
@@ -23,10 +23,11 @@
23#include "nvhost_priv.h" 23#include "nvhost_priv.h"
24 24
25#include "gk20a/gk20a.h" 25#include "gk20a/gk20a.h"
26#include "gk20a/platform_gk20a.h"
26 27
27int nvgpu_get_nvhost_dev(struct gk20a *g) 28int nvgpu_get_nvhost_dev(struct gk20a *g)
28{ 29{
29 struct device_node *np = g->dev->of_node; 30 struct device_node *np = dev_from_gk20a(g)->of_node;
30 struct platform_device *host1x_pdev = NULL; 31 struct platform_device *host1x_pdev = NULL;
31 const __be32 *host1x_ptr; 32 const __be32 *host1x_ptr;
32 33
@@ -151,7 +152,7 @@ int nvgpu_nvhost_syncpt_read_ext_check(
151 152
152int nvgpu_nvhost_create_symlink(struct gk20a *g) 153int nvgpu_nvhost_create_symlink(struct gk20a *g)
153{ 154{
154 struct device *dev = g->dev; 155 struct device *dev = dev_from_gk20a(g);
155 int err = 0; 156 int err = 0;
156 157
157 if (g->nvhost_dev && 158 if (g->nvhost_dev &&
@@ -166,7 +167,7 @@ int nvgpu_nvhost_create_symlink(struct gk20a *g)
166 167
167void nvgpu_nvhost_remove_symlink(struct gk20a *g) 168void nvgpu_nvhost_remove_symlink(struct gk20a *g)
168{ 169{
169 struct device *dev = g->dev; 170 struct device *dev = dev_from_gk20a(g);
170 171
171 if (g->nvhost_dev && 172 if (g->nvhost_dev &&
172 (dev->parent != &g->nvhost_dev->host1x_pdev->dev)) { 173 (dev->parent != &g->nvhost_dev->host1x_pdev->dev)) {
diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c
index 5fcf717c..15435934 100644
--- a/drivers/gpu/nvgpu/common/linux/pci.c
+++ b/drivers/gpu/nvgpu/common/linux/pci.c
@@ -469,7 +469,7 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
469 nvgpu_clk_arb_cleanup_arbiter(g); 469 nvgpu_clk_arb_cleanup_arbiter(g);
470#endif 470#endif
471 471
472 gk20a_user_deinit(g->dev, &nvgpu_pci_class); 472 gk20a_user_deinit(dev_from_gk20a(g), &nvgpu_pci_class);
473 gk20a_dbg(gpu_dbg_shutdown, "User de-init done.\b"); 473 gk20a_dbg(gpu_dbg_shutdown, "User de-init done.\b");
474 474
475#ifdef CONFIG_DEBUG_FS 475#ifdef CONFIG_DEBUG_FS
@@ -477,10 +477,10 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
477 debugfs_remove_recursive(platform->debugfs_alias); 477 debugfs_remove_recursive(platform->debugfs_alias);
478#endif 478#endif
479 479
480 nvgpu_remove_sysfs(g->dev); 480 nvgpu_remove_sysfs(dev_from_gk20a(g));
481 481
482 if (platform->remove) 482 if (platform->remove)
483 platform->remove(g->dev); 483 platform->remove(dev_from_gk20a(g));
484 gk20a_dbg(gpu_dbg_shutdown, "Platform remove done.\b"); 484 gk20a_dbg(gpu_dbg_shutdown, "Platform remove done.\b");
485 485
486 enable_irq(g->irq_stall); 486 enable_irq(g->irq_stall);
diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c
index 9652c1da..19a05c90 100644
--- a/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c
+++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c
@@ -760,7 +760,7 @@ static int gm20b_register_gpcclk(struct gk20a *g)
760 760
761 /* Data in .init is copied by clk_register(), so stack variable OK */ 761 /* Data in .init is copied by clk_register(), so stack variable OK */
762 clk->hw.init = &init; 762 clk->hw.init = &init;
763 c = clk_register(g->dev, &clk->hw); 763 c = clk_register(dev_from_gk20a(g), &clk->hw);
764 if (IS_ERR(c)) { 764 if (IS_ERR(c)) {
765 nvgpu_err(g, "Failed to register GPCPLL clock"); 765 nvgpu_err(g, "Failed to register GPCPLL clock");
766 return -EINVAL; 766 return -EINVAL;
diff --git a/drivers/gpu/nvgpu/common/linux/sysfs.c b/drivers/gpu/nvgpu/common/linux/sysfs.c
index e0da4661..28ebb21d 100644
--- a/drivers/gpu/nvgpu/common/linux/sysfs.c
+++ b/drivers/gpu/nvgpu/common/linux/sysfs.c
@@ -388,7 +388,7 @@ static ssize_t is_railgated_show(struct device *dev,
388 bool is_railgated = 0; 388 bool is_railgated = 0;
389 389
390 if (platform->is_railgated) 390 if (platform->is_railgated)
391 is_railgated = platform->is_railgated(platform->g->dev); 391 is_railgated = platform->is_railgated(dev);
392 392
393 return snprintf(buf, PAGE_SIZE, "%s\n", is_railgated ? "yes" : "no"); 393 return snprintf(buf, PAGE_SIZE, "%s\n", is_railgated ? "yes" : "no");
394} 394}
diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c
index f356fee2..cbacbdc0 100644
--- a/drivers/gpu/nvgpu/common/linux/vm.c
+++ b/drivers/gpu/nvgpu/common/linux/vm.c
@@ -26,6 +26,7 @@
26#include "gk20a/gk20a.h" 26#include "gk20a/gk20a.h"
27#include "gk20a/mm_gk20a.h" 27#include "gk20a/mm_gk20a.h"
28#include "gk20a/kind_gk20a.h" 28#include "gk20a/kind_gk20a.h"
29#include "gk20a/platform_gk20a.h"
29 30
30#include "vm_priv.h" 31#include "vm_priv.h"
31 32
@@ -187,6 +188,7 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm,
187 struct vm_gk20a_mapping_batch *batch) 188 struct vm_gk20a_mapping_batch *batch)
188{ 189{
189 struct gk20a *g = gk20a_from_vm(vm); 190 struct gk20a *g = gk20a_from_vm(vm);
191 struct device *dev = dev_from_gk20a(g);
190 struct gk20a_comptag_allocator *ctag_allocator = &g->gr.comp_tags; 192 struct gk20a_comptag_allocator *ctag_allocator = &g->gr.comp_tags;
191 struct nvgpu_mapped_buf *mapped_buffer = NULL; 193 struct nvgpu_mapped_buf *mapped_buffer = NULL;
192 bool va_allocated = false; 194 bool va_allocated = false;
@@ -224,7 +226,7 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm,
224 } 226 }
225 227
226 /* pin buffer to get phys/iovmm addr */ 228 /* pin buffer to get phys/iovmm addr */
227 bfr.sgt = gk20a_mm_pin(g->dev, dmabuf); 229 bfr.sgt = gk20a_mm_pin(dev, dmabuf);
228 if (IS_ERR(bfr.sgt)) { 230 if (IS_ERR(bfr.sgt)) {
229 /* Falling back to physical is actually possible 231 /* Falling back to physical is actually possible
230 * here in many cases if we use 4K phys pages in the 232 * here in many cases if we use 4K phys pages in the
@@ -283,7 +285,7 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm,
283 if (!vm->enable_ctag) 285 if (!vm->enable_ctag)
284 bfr.ctag_lines = 0; 286 bfr.ctag_lines = 0;
285 287
286 gk20a_get_comptags(g->dev, dmabuf, &comptags); 288 gk20a_get_comptags(dev, dmabuf, &comptags);
287 289
288 /* ensure alignment to compression page size if compression enabled */ 290 /* ensure alignment to compression page size if compression enabled */
289 if (bfr.ctag_offset) 291 if (bfr.ctag_offset)
@@ -295,7 +297,8 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm,
295 !!(flags & NVGPU_AS_MAP_BUFFER_FLAGS_MAPPABLE_COMPBITS); 297 !!(flags & NVGPU_AS_MAP_BUFFER_FLAGS_MAPPABLE_COMPBITS);
296 298
297 /* allocate compression resources if needed */ 299 /* allocate compression resources if needed */
298 err = gk20a_alloc_comptags(g, g->dev, dmabuf, ctag_allocator, 300 err = gk20a_alloc_comptags(g, dev, dmabuf,
301 ctag_allocator,
299 bfr.ctag_lines, user_mappable, 302 bfr.ctag_lines, user_mappable,
300 &ctag_map_win_size, 303 &ctag_map_win_size,
301 &ctag_map_win_ctagline); 304 &ctag_map_win_ctagline);
@@ -304,7 +307,8 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm,
304 /* TBD: we can partially alloc ctags as well... */ 307 /* TBD: we can partially alloc ctags as well... */
305 bfr.kind_v = bfr.uc_kind_v; 308 bfr.kind_v = bfr.uc_kind_v;
306 } else { 309 } else {
307 gk20a_get_comptags(g->dev, dmabuf, &comptags); 310 gk20a_get_comptags(dev,
311 dmabuf, &comptags);
308 312
309 if (g->ops.ltc.cbc_ctrl) 313 if (g->ops.ltc.cbc_ctrl)
310 g->ops.ltc.cbc_ctrl(g, gk20a_cbc_op_clear, 314 g->ops.ltc.cbc_ctrl(g, gk20a_cbc_op_clear,
@@ -396,7 +400,7 @@ clean_up:
396 if (va_allocated) 400 if (va_allocated)
397 __nvgpu_vm_free_va(vm, map_offset, bfr.pgsz_idx); 401 __nvgpu_vm_free_va(vm, map_offset, bfr.pgsz_idx);
398 if (!IS_ERR(bfr.sgt)) 402 if (!IS_ERR(bfr.sgt))
399 gk20a_mm_unpin(g->dev, dmabuf, bfr.sgt); 403 gk20a_mm_unpin(dev, dmabuf, bfr.sgt);
400 404
401 nvgpu_mutex_release(&vm->update_gmmu_lock); 405 nvgpu_mutex_release(&vm->update_gmmu_lock);
402 nvgpu_log_info(g, "err=%d", err); 406 nvgpu_log_info(g, "err=%d", err);
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
index 730ffe5c..0413ae6a 100644
--- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
@@ -37,6 +37,7 @@
37#include "cde_gk20a.h" 37#include "cde_gk20a.h"
38#include "fence_gk20a.h" 38#include "fence_gk20a.h"
39#include "gr_gk20a.h" 39#include "gr_gk20a.h"
40#include "platform_gk20a.h"
40 41
41#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h> 42#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h>
42#include <nvgpu/hw/gk20a/hw_pbdma_gk20a.h> 43#include <nvgpu/hw/gk20a/hw_pbdma_gk20a.h>
@@ -915,7 +916,7 @@ static struct gk20a_cde_ctx *gk20a_cde_allocate_context(struct gk20a *g)
915 return ERR_PTR(-ENOMEM); 916 return ERR_PTR(-ENOMEM);
916 917
917 cde_ctx->g = g; 918 cde_ctx->g = g;
918 cde_ctx->dev = g->dev; 919 cde_ctx->dev = dev_from_gk20a(g);
919 920
920 ret = gk20a_cde_load(cde_ctx); 921 ret = gk20a_cde_load(cde_ctx);
921 if (ret) { 922 if (ret) {
@@ -982,7 +983,8 @@ __releases(&cde_app->mutex)
982 /* First, map the buffer to local va */ 983 /* First, map the buffer to local va */
983 984
984 /* ensure that the compbits buffer has drvdata */ 985 /* ensure that the compbits buffer has drvdata */
985 err = gk20a_dmabuf_alloc_drvdata(compbits_scatter_buf, g->dev); 986 err = gk20a_dmabuf_alloc_drvdata(compbits_scatter_buf,
987 dev_from_gk20a(g));
986 if (err) 988 if (err)
987 goto exit_idle; 989 goto exit_idle;
988 990
@@ -1048,7 +1050,7 @@ __releases(&cde_app->mutex)
1048 1050
1049 gk20a_dbg(gpu_dbg_cde, "surface=0x%p scatterBuffer=0x%p", 1051 gk20a_dbg(gpu_dbg_cde, "surface=0x%p scatterBuffer=0x%p",
1050 surface, scatter_buffer); 1052 surface, scatter_buffer);
1051 sgt = gk20a_mm_pin(g->dev, compbits_scatter_buf); 1053 sgt = gk20a_mm_pin(dev_from_gk20a(g), compbits_scatter_buf);
1052 if (IS_ERR(sgt)) { 1054 if (IS_ERR(sgt)) {
1053 nvgpu_warn(g, 1055 nvgpu_warn(g,
1054 "mm_pin failed"); 1056 "mm_pin failed");
@@ -1060,7 +1062,7 @@ __releases(&cde_app->mutex)
1060 scatterbuffer_size); 1062 scatterbuffer_size);
1061 WARN_ON(err); 1063 WARN_ON(err);
1062 1064
1063 gk20a_mm_unpin(g->dev, compbits_scatter_buf, 1065 gk20a_mm_unpin(dev_from_gk20a(g), compbits_scatter_buf,
1064 sgt); 1066 sgt);
1065 if (err) 1067 if (err)
1066 goto exit_unmap_surface; 1068 goto exit_unmap_surface;
@@ -1072,7 +1074,7 @@ __releases(&cde_app->mutex)
1072 } 1074 }
1073 1075
1074 /* store source buffer compression tags */ 1076 /* store source buffer compression tags */
1075 gk20a_get_comptags(g->dev, compbits_scatter_buf, &comptags); 1077 gk20a_get_comptags(dev_from_gk20a(g), compbits_scatter_buf, &comptags);
1076 cde_ctx->surf_param_offset = comptags.offset; 1078 cde_ctx->surf_param_offset = comptags.offset;
1077 cde_ctx->surf_param_lines = comptags.lines; 1079 cde_ctx->surf_param_lines = comptags.lines;
1078 1080
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
index 546d2eb1..54986e6c 100644
--- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
@@ -134,7 +134,7 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode,
134 if (!g) 134 if (!g)
135 return -ENODEV; 135 return -ENODEV;
136 136
137 dev = g->dev; 137 dev = dev_from_gk20a(g);
138 138
139 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "dbg session: %s", g->name); 139 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "dbg session: %s", g->name);
140 140
diff --git a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c
index 4235788b..aca9df75 100644
--- a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c
@@ -536,7 +536,7 @@ DEFINE_SIMPLE_ATTRIBUTE(gk20a_fecs_trace_debugfs_write_fops,
536 536
537static void gk20a_fecs_trace_debugfs_init(struct gk20a *g) 537static void gk20a_fecs_trace_debugfs_init(struct gk20a *g)
538{ 538{
539 struct gk20a_platform *plat = dev_get_drvdata(g->dev); 539 struct gk20a_platform *plat = dev_get_drvdata(dev_from_gk20a(g));
540 540
541 debugfs_create_file("ctxsw_trace_read", 0600, plat->debugfs, g, 541 debugfs_create_file("ctxsw_trace_read", 0600, plat->debugfs, g,
542 &gk20a_fecs_trace_debugfs_read_fops); 542 &gk20a_fecs_trace_debugfs_read_fops);
@@ -548,7 +548,7 @@ static void gk20a_fecs_trace_debugfs_init(struct gk20a *g)
548 548
549static void gk20a_fecs_trace_debugfs_cleanup(struct gk20a *g) 549static void gk20a_fecs_trace_debugfs_cleanup(struct gk20a *g)
550{ 550{
551 struct gk20a_platform *plat = dev_get_drvdata(g->dev); 551 struct gk20a_platform *plat = dev_get_drvdata(dev_from_gk20a(g));
552 552
553 debugfs_remove_recursive(plat->debugfs); 553 debugfs_remove_recursive(plat->debugfs);
554} 554}
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index a87d34f9..9452e153 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -42,7 +42,6 @@
42#include "pstate/pstate.h" 42#include "pstate/pstate.h"
43#endif 43#endif
44 44
45
46#ifdef CONFIG_TEGRA_19x_GPU 45#ifdef CONFIG_TEGRA_19x_GPU
47#include "nvgpu_gpuid_t19x.h" 46#include "nvgpu_gpuid_t19x.h"
48#endif 47#endif
@@ -152,7 +151,7 @@ int gk20a_prepare_poweroff(struct gk20a *g)
152 151
153int gk20a_finalize_poweron(struct gk20a *g) 152int gk20a_finalize_poweron(struct gk20a *g)
154{ 153{
155 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 154 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
156 int err; 155 int err;
157 156
158 gk20a_dbg_fn(""); 157 gk20a_dbg_fn("");
@@ -323,7 +322,7 @@ int gk20a_finalize_poweron(struct gk20a *g)
323 if (platform->disable_aspm && g->ops.xve.disable_aspm) 322 if (platform->disable_aspm && g->ops.xve.disable_aspm)
324 g->ops.xve.disable_aspm(g); 323 g->ops.xve.disable_aspm(g);
325 324
326 g->ops.xve.sw_init(g->dev); 325 g->ops.xve.sw_init(dev_from_gk20a(g));
327 g->ops.xve.available_speeds(g, &speed); 326 g->ops.xve.available_speeds(g, &speed);
328 327
329 /* Set to max speed */ 328 /* Set to max speed */
@@ -367,7 +366,7 @@ void gk20a_driver_start_unload(struct gk20a *g)
367 if (g->is_virtual) 366 if (g->is_virtual)
368 return; 367 return;
369 368
370 gk20a_wait_for_idle(g->dev); 369 gk20a_wait_for_idle(dev_from_gk20a(g));
371 370
372 nvgpu_wait_for_deferred_interrupts(g); 371 nvgpu_wait_for_deferred_interrupts(g);
373 gk20a_channel_cancel_pending_sema_waits(g); 372 gk20a_channel_cancel_pending_sema_waits(g);
@@ -407,7 +406,7 @@ int gk20a_wait_for_idle(struct device *dev)
407int gk20a_init_gpu_characteristics(struct gk20a *g) 406int gk20a_init_gpu_characteristics(struct gk20a *g)
408{ 407{
409 struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics; 408 struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics;
410 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 409 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
411 410
412 gpu->L2_cache_size = g->ops.ltc.determine_L2_size_bytes(g); 411 gpu->L2_cache_size = g->ops.ltc.determine_L2_size_bytes(g);
413 gpu->on_board_video_memory_size = 0; /* integrated GPU */ 412 gpu->on_board_video_memory_size = 0; /* integrated GPU */
@@ -499,7 +498,8 @@ int gk20a_init_gpu_characteristics(struct gk20a *g)
499 gpu->map_buffer_batch_limit = 256; 498 gpu->map_buffer_batch_limit = 256;
500 499
501 if (platform->clk_round_rate) 500 if (platform->clk_round_rate)
502 gpu->max_freq = platform->clk_round_rate(g->dev, UINT_MAX); 501 gpu->max_freq = platform->clk_round_rate(dev_from_gk20a(g),
502 UINT_MAX);
503 503
504 g->ops.gr.get_preemption_mode_flags(g, &g->gr.preemption_mode_rec); 504 g->ops.gr.get_preemption_mode_flags(g, &g->gr.preemption_mode_rec);
505 gpu->graphics_preemption_mode_flags = 505 gpu->graphics_preemption_mode_flags =
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index 3ac4e397..570aad18 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -39,6 +39,7 @@
39#include "regops_gk20a.h" 39#include "regops_gk20a.h"
40#include "dbg_gpu_gk20a.h" 40#include "dbg_gpu_gk20a.h"
41#include "ctxsw_trace_gk20a.h" 41#include "ctxsw_trace_gk20a.h"
42#include "platform_gk20a.h"
42 43
43#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h> 44#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h>
44#include <nvgpu/hw/gk20a/hw_ctxsw_prog_gk20a.h> 45#include <nvgpu/hw/gk20a/hw_ctxsw_prog_gk20a.h>
@@ -4826,7 +4827,7 @@ static int gk20a_init_gr_setup_sw(struct gk20a *g)
4826 gr->sw_ready = true; 4827 gr->sw_ready = true;
4827 4828
4828 if (g->ops.gr.create_gr_sysfs) 4829 if (g->ops.gr.create_gr_sysfs)
4829 g->ops.gr.create_gr_sysfs(g->dev); 4830 g->ops.gr.create_gr_sysfs(dev_from_gk20a(g));
4830 4831
4831 gk20a_dbg_fn("done"); 4832 gk20a_dbg_fn("done");
4832 return 0; 4833 return 0;
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 9cc4f58e..b7b68575 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -1992,7 +1992,7 @@ int gk20a_dmabuf_get_state(struct dma_buf *dmabuf, struct gk20a *g,
1992 int err = 0; 1992 int err = 0;
1993 struct gk20a_dmabuf_priv *priv; 1993 struct gk20a_dmabuf_priv *priv;
1994 struct gk20a_buffer_state *s; 1994 struct gk20a_buffer_state *s;
1995 struct device *dev = g->dev; 1995 struct device *dev = dev_from_gk20a(g);
1996 1996
1997 if (WARN_ON(offset >= (u64)dmabuf->size)) 1997 if (WARN_ON(offset >= (u64)dmabuf->size))
1998 return -EINVAL; 1998 return -EINVAL;
diff --git a/drivers/gpu/nvgpu/gm206/bios_gm206.c b/drivers/gpu/nvgpu/gm206/bios_gm206.c
index 5304e079..3002c9c7 100644
--- a/drivers/gpu/nvgpu/gm206/bios_gm206.c
+++ b/drivers/gpu/nvgpu/gm206/bios_gm206.c
@@ -257,13 +257,13 @@ out:
257int gm206_bios_init(struct gk20a *g) 257int gm206_bios_init(struct gk20a *g)
258{ 258{
259 unsigned int i; 259 unsigned int i;
260 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 260 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
261#ifdef CONFIG_DEBUG_FS 261#ifdef CONFIG_DEBUG_FS
262 struct dentry *d; 262 struct dentry *d;
263#endif 263#endif
264 struct nvgpu_firmware *bios_fw; 264 struct nvgpu_firmware *bios_fw;
265 int err; 265 int err;
266 struct pci_dev *pdev = to_pci_dev(g->dev); 266 struct pci_dev *pdev = to_pci_dev(dev_from_gk20a(g));
267 char rom_name[sizeof(BIOS_OVERLAY_NAME_FORMATTED)]; 267 char rom_name[sizeof(BIOS_OVERLAY_NAME_FORMATTED)];
268 268
269 gk20a_dbg_fn(""); 269 gk20a_dbg_fn("");
diff --git a/drivers/gpu/nvgpu/gm20b/gr_gm20b.c b/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
index c84d2109..d4cccf3b 100644
--- a/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
@@ -23,6 +23,7 @@
23 23
24#include "gk20a/gk20a.h" 24#include "gk20a/gk20a.h"
25#include "gk20a/gr_gk20a.h" 25#include "gk20a/gr_gk20a.h"
26#include "gk20a/platform_gk20a.h"
26 27
27#include "gr_gm20b.h" 28#include "gr_gm20b.h"
28#include "pmu_gm20b.h" 29#include "pmu_gm20b.h"
@@ -1422,7 +1423,7 @@ int gm20b_gr_tpc_disable_override(struct gk20a *g, u32 mask)
1422 1423
1423static int gm20b_gr_fuse_override(struct gk20a *g) 1424static int gm20b_gr_fuse_override(struct gk20a *g)
1424{ 1425{
1425 struct device_node *np = g->dev->of_node; 1426 struct device_node *np = dev_from_gk20a(g)->of_node;
1426 u32 *fuses; 1427 u32 *fuses;
1427 int count, i; 1428 int count, i;
1428 1429
diff --git a/drivers/gpu/nvgpu/gp106/clk_gp106.c b/drivers/gpu/nvgpu/gp106/clk_gp106.c
index f8353296..332ad413 100644
--- a/drivers/gpu/nvgpu/gp106/clk_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/clk_gp106.c
@@ -239,7 +239,7 @@ DEFINE_SIMPLE_ATTRIBUTE(get_rate_fops, gp106_get_rate_show, NULL, "%llu\n");
239 239
240 240
241static int clk_gp106_debugfs_init(struct gk20a *g) { 241static int clk_gp106_debugfs_init(struct gk20a *g) {
242 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 242 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
243 243
244 struct dentry *gpu_root = platform->debugfs; 244 struct dentry *gpu_root = platform->debugfs;
245 struct dentry *clocks_root; 245 struct dentry *clocks_root;
diff --git a/drivers/gpu/nvgpu/gp106/mclk_gp106.c b/drivers/gpu/nvgpu/gp106/mclk_gp106.c
index 3558b501..c4ecdb1d 100644
--- a/drivers/gpu/nvgpu/gp106/mclk_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/mclk_gp106.c
@@ -3494,7 +3494,7 @@ static const struct file_operations mclk_switch_stats_fops = {
3494 3494
3495static int mclk_debugfs_init(struct gk20a *g) 3495static int mclk_debugfs_init(struct gk20a *g)
3496{ 3496{
3497 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 3497 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
3498 3498
3499 struct dentry *gpu_root = platform->debugfs; 3499 struct dentry *gpu_root = platform->debugfs;
3500 struct dentry *d; 3500 struct dentry *d;
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.c b/drivers/gpu/nvgpu/gp106/therm_gp106.c
index d473da96..1781a17f 100644
--- a/drivers/gpu/nvgpu/gp106/therm_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/therm_gp106.c
@@ -68,7 +68,7 @@ static int therm_get_internal_sensor_curr_temp(void *data, u64 *val)
68DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n"); 68DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n");
69 69
70static void gp106_therm_debugfs_init(struct gk20a *g) { 70static void gp106_therm_debugfs_init(struct gk20a *g) {
71 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 71 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
72 struct dentry *dbgentry; 72 struct dentry *dbgentry;
73 73
74 dbgentry = debugfs_create_file( 74 dbgentry = debugfs_create_file(
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
index 9ff34325..2a3ecd31 100644
--- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
@@ -28,6 +28,7 @@
28#include "gk20a/gr_gk20a.h" 28#include "gk20a/gr_gk20a.h"
29#include "gk20a/dbg_gpu_gk20a.h" 29#include "gk20a/dbg_gpu_gk20a.h"
30#include "gk20a/regops_gk20a.h" 30#include "gk20a/regops_gk20a.h"
31#include "gk20a/platform_gk20a.h"
31 32
32#include "gm20b/gr_gm20b.h" 33#include "gm20b/gr_gm20b.h"
33#include "gp10b/gr_gp10b.h" 34#include "gp10b/gr_gp10b.h"
@@ -2245,7 +2246,7 @@ static int gr_gp10b_get_preemption_mode_flags(struct gk20a *g,
2245} 2246}
2246static int gp10b_gr_fuse_override(struct gk20a *g) 2247static int gp10b_gr_fuse_override(struct gk20a *g)
2247{ 2248{
2248 struct device_node *np = g->dev->of_node; 2249 struct device_node *np = dev_from_gk20a(g)->of_node;
2249 u32 *fuses; 2250 u32 *fuses;
2250 int count, i; 2251 int count, i;
2251 2252
diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.c b/drivers/gpu/nvgpu/pmgr/pmgr.c
index 46787724..1b004832 100644
--- a/drivers/gpu/nvgpu/pmgr/pmgr.c
+++ b/drivers/gpu/nvgpu/pmgr/pmgr.c
@@ -112,7 +112,7 @@ DEFINE_SIMPLE_ATTRIBUTE(
112 pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n"); 112 pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n");
113 113
114static void pmgr_debugfs_init(struct gk20a *g) { 114static void pmgr_debugfs_init(struct gk20a *g) {
115 struct gk20a_platform *platform = dev_get_drvdata(g->dev); 115 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
116 struct dentry *dbgentry; 116 struct dentry *dbgentry;
117 117
118 dbgentry = debugfs_create_file( 118 dbgentry = debugfs_create_file(
diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
index 7abe4976..771a8b8d 100644
--- a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
+++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
@@ -138,7 +138,7 @@ exit:
138static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g) 138static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g)
139{ 139{
140 struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table; 140 struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table;
141 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 141 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
142 u32 idx = platform->ina3221_dcb_index; 142 u32 idx = platform->ina3221_dcb_index;
143 u32 status = 0; 143 u32 status = 0;
144 144
diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
index 74dc7a6a..3c3c7a96 100644
--- a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
+++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
@@ -507,7 +507,7 @@ static inline void devinit_unpack_pwr_policy_entry(
507static u32 devinit_get_pwr_policy_table(struct gk20a *g, 507static u32 devinit_get_pwr_policy_table(struct gk20a *g,
508 struct pmgr_pwr_policy *ppwrpolicyobjs) 508 struct pmgr_pwr_policy *ppwrpolicyobjs)
509{ 509{
510 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 510 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
511 u32 status = 0; 511 u32 status = 0;
512 u8 *ptr = NULL; 512 u8 *ptr = NULL;
513 struct boardobj *boardobj; 513 struct boardobj *boardobj;
diff --git a/drivers/gpu/nvgpu/vgpu/css_vgpu.c b/drivers/gpu/nvgpu/vgpu/css_vgpu.c
index d18ed100..a06ca037 100644
--- a/drivers/gpu/nvgpu/vgpu/css_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/css_vgpu.c
@@ -29,7 +29,7 @@ static struct tegra_hv_ivm_cookie *css_cookie;
29static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) 29static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr)
30{ 30{
31 struct gk20a *g = gr->g; 31 struct gk20a *g = gr->g;
32 struct device *dev = g->dev; 32 struct device *dev = dev_from_gk20a(g);
33 struct gk20a_cs_snapshot *data = gr->cs_data; 33 struct gk20a_cs_snapshot *data = gr->cs_data;
34 struct device_node *np = dev->of_node; 34 struct device_node *np = dev->of_node;
35 struct of_phandle_args args; 35 struct of_phandle_args args;
diff --git a/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c b/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c
index af1631d8..7cab4d1e 100644
--- a/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 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, 5 * under the terms and conditions of the GNU General Public License,
@@ -35,7 +35,7 @@ struct vgpu_fecs_trace {
35 35
36static int vgpu_fecs_trace_init(struct gk20a *g) 36static int vgpu_fecs_trace_init(struct gk20a *g)
37{ 37{
38 struct device *dev = g->dev; 38 struct device *dev = dev_from_gk20a(g);
39 struct device_node *np = dev->of_node; 39 struct device_node *np = dev->of_node;
40 struct of_phandle_args args; 40 struct of_phandle_args args;
41 struct device_node *hv_np; 41 struct device_node *hv_np;
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index da77dc19..f02acad0 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -206,7 +206,8 @@ static int vgpu_intr_thread(void *dev_id)
206 206
207static void vgpu_remove_support(struct gk20a *g) 207static void vgpu_remove_support(struct gk20a *g)
208{ 208{
209 struct vgpu_priv_data *priv = vgpu_get_priv_data_from_dev(g->dev); 209 struct vgpu_priv_data *priv =
210 vgpu_get_priv_data_from_dev(dev_from_gk20a(g));
210 struct tegra_vgpu_intr_msg msg; 211 struct tegra_vgpu_intr_msg msg;
211 int err; 212 int err;
212 213
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.h b/drivers/gpu/nvgpu/vgpu/vgpu.h
index 31ecb737..92b82ac4 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.h
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.h
@@ -41,7 +41,7 @@ struct vgpu_priv_data *vgpu_get_priv_data_from_dev(struct device *dev)
41 41
42static inline struct vgpu_priv_data *vgpu_get_priv_data(struct gk20a *g) 42static inline struct vgpu_priv_data *vgpu_get_priv_data(struct gk20a *g)
43{ 43{
44 return vgpu_get_priv_data_from_dev(g->dev); 44 return vgpu_get_priv_data_from_dev(dev_from_gk20a(g));
45} 45}
46 46
47static inline u64 vgpu_get_handle_from_dev(struct device *dev) 47static inline u64 vgpu_get_handle_from_dev(struct device *dev)
@@ -58,7 +58,7 @@ static inline u64 vgpu_get_handle_from_dev(struct device *dev)
58 58
59static inline u64 vgpu_get_handle(struct gk20a *g) 59static inline u64 vgpu_get_handle(struct gk20a *g)
60{ 60{
61 return vgpu_get_handle_from_dev(g->dev); 61 return vgpu_get_handle_from_dev(dev_from_gk20a(g));
62} 62}
63 63
64int vgpu_pm_prepare_poweroff(struct device *dev); 64int vgpu_pm_prepare_poweroff(struct device *dev);