summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-03-29 18:00:24 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-04-11 13:56:06 -0400
commit19fdb429c2b04d13faecad8b2e5466e9f3c7b8c7 (patch)
treee92f6d93ae2593286546f983b9a1fff8638aa9a6 /drivers
parent1a4647272f4fe50137c79583b698c1ef6f5def12 (diff)
gpu: nvgpu: Wrappers for checking platform type
Add nvgpu_* wrappers for determining if we're running in simulation or silicon, and if we're running in hypervisor. The new wrappers require struct gk20a pointer, and gk20a_fence_wait() did not have access to one. Add struct gk20a pointer as the first parameter. JIRA NVGPU-16 Change-Id: I73b2b8f091ca29fb1827054abd2adaf583710331 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1331565 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/Makefile.nvgpu1
-rw-r--r--drivers/gpu/nvgpu/common/linux/soc.c31
-rw-r--r--drivers/gpu/nvgpu/common/linux/timers.c5
-rw-r--r--drivers/gpu/nvgpu/common/nvgpu_common.c15
-rw-r--r--drivers/gpu/nvgpu/gk20a/bus_gk20a.c7
-rw-r--r--drivers/gpu/nvgpu/gk20a/ce2_gk20a.c6
-rw-r--r--drivers/gpu/nvgpu/gk20a/clk_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.c5
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.h3
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c11
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c4
-rw-r--r--drivers/gpu/nvgpu/gk20a/pmu_gk20a.c17
-rw-r--r--drivers/gpu/nvgpu/gm20b/clk_gm20b.c4
-rw-r--r--drivers/gpu/nvgpu/gp106/pmu_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp106/therm_gp106.c8
-rw-r--r--drivers/gpu/nvgpu/gp10b/therm_gp10b.c8
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/soc.h22
-rw-r--r--drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c1
20 files changed, 103 insertions, 54 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu
index d994ac1d..658f8b7f 100644
--- a/drivers/gpu/nvgpu/Makefile.nvgpu
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu
@@ -33,6 +33,7 @@ nvgpu-y := \
33 common/linux/log.o \ 33 common/linux/log.o \
34 common/linux/nvgpu_mem.o \ 34 common/linux/nvgpu_mem.o \
35 common/linux/dma.o \ 35 common/linux/dma.o \
36 common/linux/soc.o \
36 common/mm/nvgpu_allocator.o \ 37 common/mm/nvgpu_allocator.o \
37 common/mm/bitmap_allocator.o \ 38 common/mm/bitmap_allocator.o \
38 common/mm/buddy_allocator.o \ 39 common/mm/buddy_allocator.o \
diff --git a/drivers/gpu/nvgpu/common/linux/soc.c b/drivers/gpu/nvgpu/common/linux/soc.c
new file mode 100644
index 00000000..d2bb5275
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/soc.c
@@ -0,0 +1,31 @@
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
14#include <soc/tegra/chip-id.h>
15
16#include <nvgpu/soc.h>
17
18bool nvgpu_platform_is_silicon(struct gk20a *g)
19{
20 return tegra_platform_is_silicon();
21}
22
23bool nvgpu_platform_is_simulation(struct gk20a *g)
24{
25 return tegra_platform_is_linsim() || tegra_platform_is_vdk();
26}
27
28bool nvgpu_is_hypervisor_mode(struct gk20a *g)
29{
30 return is_tegra_hypervisor_mode();
31}
diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c
index 07eb357a..9fe84b50 100644
--- a/drivers/gpu/nvgpu/common/linux/timers.c
+++ b/drivers/gpu/nvgpu/common/linux/timers.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,
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19 19
20#include <nvgpu/timers.h> 20#include <nvgpu/timers.h>
21#include <nvgpu/soc.h>
21 22
22#include "gk20a/gk20a.h" 23#include "gk20a/gk20a.h"
23 24
@@ -31,7 +32,7 @@ static int nvgpu_timeout_is_pre_silicon(struct nvgpu_timeout *timeout)
31 if (timeout->flags & NVGPU_TIMER_NO_PRE_SI) 32 if (timeout->flags & NVGPU_TIMER_NO_PRE_SI)
32 return 0; 33 return 0;
33 34
34 return !tegra_platform_is_silicon(); 35 return !nvgpu_platform_is_silicon(timeout->g);
35} 36}
36 37
37/** 38/**
diff --git a/drivers/gpu/nvgpu/common/nvgpu_common.c b/drivers/gpu/nvgpu/common/nvgpu_common.c
index a07a8f7d..f8f4a636 100644
--- a/drivers/gpu/nvgpu/common/nvgpu_common.c
+++ b/drivers/gpu/nvgpu/common/nvgpu_common.c
@@ -19,6 +19,7 @@
19 19
20#include <nvgpu/kmem.h> 20#include <nvgpu/kmem.h>
21#include <nvgpu/nvgpu_common.h> 21#include <nvgpu/nvgpu_common.h>
22#include <nvgpu/soc.h>
22 23
23#include "gk20a/gk20a_scale.h" 24#include "gk20a/gk20a_scale.h"
24#include "gk20a/gk20a.h" 25#include "gk20a/gk20a.h"
@@ -60,7 +61,7 @@ static void nvgpu_init_vars(struct gk20a *g)
60static void nvgpu_init_timeout(struct gk20a *g) 61static void nvgpu_init_timeout(struct gk20a *g)
61{ 62{
62 g->gr_idle_timeout_default = CONFIG_GK20A_DEFAULT_TIMEOUT; 63 g->gr_idle_timeout_default = CONFIG_GK20A_DEFAULT_TIMEOUT;
63 if (tegra_platform_is_silicon()) 64 if (nvgpu_platform_is_silicon(g))
64 g->timeouts_enabled = true; 65 g->timeouts_enabled = true;
65} 66}
66 67
@@ -85,17 +86,17 @@ static void nvgpu_init_pm_vars(struct gk20a *g)
85 * power features and for silicon platforms, read from platform data 86 * power features and for silicon platforms, read from platform data
86 */ 87 */
87 g->slcg_enabled = 88 g->slcg_enabled =
88 tegra_platform_is_silicon() ? platform->enable_slcg : false; 89 nvgpu_platform_is_silicon(g) ? platform->enable_slcg : false;
89 g->blcg_enabled = 90 g->blcg_enabled =
90 tegra_platform_is_silicon() ? platform->enable_blcg : false; 91 nvgpu_platform_is_silicon(g) ? platform->enable_blcg : false;
91 g->elcg_enabled = 92 g->elcg_enabled =
92 tegra_platform_is_silicon() ? platform->enable_elcg : false; 93 nvgpu_platform_is_silicon(g) ? platform->enable_elcg : false;
93 g->elpg_enabled = 94 g->elpg_enabled =
94 tegra_platform_is_silicon() ? platform->enable_elpg : false; 95 nvgpu_platform_is_silicon(g) ? platform->enable_elpg : false;
95 g->aelpg_enabled = 96 g->aelpg_enabled =
96 tegra_platform_is_silicon() ? platform->enable_aelpg : false; 97 nvgpu_platform_is_silicon(g) ? platform->enable_aelpg : false;
97 g->mscg_enabled = 98 g->mscg_enabled =
98 tegra_platform_is_silicon() ? platform->enable_mscg : false; 99 nvgpu_platform_is_silicon(g) ? platform->enable_mscg : false;
99 100
100 /* set default values to aelpg parameters */ 101 /* set default values to aelpg parameters */
101 g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US; 102 g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US;
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
index 3119e373..e81a5b2a 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
@@ -14,10 +14,9 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include <soc/tegra/chip-id.h>
18
19#include <nvgpu/page_allocator.h> 17#include <nvgpu/page_allocator.h>
20#include <nvgpu/log.h> 18#include <nvgpu/log.h>
19#include <nvgpu/soc.h>
21 20
22#include "gk20a.h" 21#include "gk20a.h"
23 22
@@ -31,7 +30,7 @@ void gk20a_bus_init_hw(struct gk20a *g)
31 struct gk20a_platform *platform = gk20a_get_platform(g->dev); 30 struct gk20a_platform *platform = gk20a_get_platform(g->dev);
32 31
33 /* enable pri timeout only on silicon */ 32 /* enable pri timeout only on silicon */
34 if (tegra_platform_is_silicon()) { 33 if (nvgpu_platform_is_silicon(g)) {
35 gk20a_writel(g, 34 gk20a_writel(g,
36 timer_pri_timeout_r(), 35 timer_pri_timeout_r(),
37 timer_pri_timeout_period_f( 36 timer_pri_timeout_period_f(
@@ -46,7 +45,7 @@ void gk20a_bus_init_hw(struct gk20a *g)
46 timer_pri_timeout_en_en_disabled_f()); 45 timer_pri_timeout_en_en_disabled_f());
47 } 46 }
48 47
49 if (!tegra_platform_is_silicon()) 48 if (!nvgpu_platform_is_silicon(g))
50 gk20a_writel(g, bus_intr_en_0_r(), 0x0); 49 gk20a_writel(g, bus_intr_en_0_r(), 0x0);
51 else 50 else
52 gk20a_writel(g, bus_intr_en_0_r(), 51 gk20a_writel(g, bus_intr_en_0_r(),
diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c
index c502add5..5b27953e 100644
--- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c
@@ -618,7 +618,8 @@ int gk20a_ce_execute_ops(struct device *dev,
618 memcpy((void *)&ce_cmd_buf_fence_in, 618 memcpy((void *)&ce_cmd_buf_fence_in,
619 (void *)(cmd_buf_cpu_va + fence_index), 619 (void *)(cmd_buf_cpu_va + fence_index),
620 sizeof(struct gk20a_fence *)); 620 sizeof(struct gk20a_fence *));
621 ret = gk20a_fence_wait(ce_cmd_buf_fence_in, gk20a_get_gr_idle_timeout(g)); 621 ret = gk20a_fence_wait(g, ce_cmd_buf_fence_in,
622 gk20a_get_gr_idle_timeout(g));
622 623
623 gk20a_fence_put(ce_cmd_buf_fence_in); 624 gk20a_fence_put(ce_cmd_buf_fence_in);
624 /* Reset the stored last pre-sync */ 625 /* Reset the stored last pre-sync */
@@ -645,7 +646,8 @@ int gk20a_ce_execute_ops(struct device *dev,
645 if (methodSize) { 646 if (methodSize) {
646 /* TODO: Remove CPU pre-fence wait */ 647 /* TODO: Remove CPU pre-fence wait */
647 if (gk20a_fence_in) { 648 if (gk20a_fence_in) {
648 ret = gk20a_fence_wait(gk20a_fence_in, gk20a_get_gr_idle_timeout(g)); 649 ret = gk20a_fence_wait(g, gk20a_fence_in,
650 gk20a_get_gr_idle_timeout(g));
649 gk20a_fence_put(gk20a_fence_in); 651 gk20a_fence_put(gk20a_fence_in);
650 if (ret) 652 if (ret)
651 goto noop; 653 goto noop;
diff --git a/drivers/gpu/nvgpu/gk20a/clk_gk20a.c b/drivers/gpu/nvgpu/gk20a/clk_gk20a.c
index 443cd5e1..baffed46 100644
--- a/drivers/gpu/nvgpu/gk20a/clk_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/clk_gk20a.c
@@ -25,6 +25,7 @@
25#include "gk20a.h" 25#include "gk20a.h"
26 26
27#include <nvgpu/log.h> 27#include <nvgpu/log.h>
28#include <nvgpu/soc.h>
28 29
29#include <nvgpu/hw/gk20a/hw_trim_gk20a.h> 30#include <nvgpu/hw/gk20a/hw_trim_gk20a.h>
30#include <nvgpu/hw/gk20a/hw_timer_gk20a.h> 31#include <nvgpu/hw/gk20a/hw_timer_gk20a.h>
@@ -268,7 +269,7 @@ static int clk_program_gpc_pll(struct gk20a *g, struct clk_gk20a *clk,
268 269
269 gk20a_dbg_fn(""); 270 gk20a_dbg_fn("");
270 271
271 if (!tegra_platform_is_silicon()) 272 if (!nvgpu_platform_is_silicon(g))
272 return 0; 273 return 0;
273 274
274 /* get old coefficients */ 275 /* get old coefficients */
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
index a5aeae08..c886101c 100644
--- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
@@ -19,6 +19,7 @@
19 19
20#include <nvgpu/semaphore.h> 20#include <nvgpu/semaphore.h>
21#include <nvgpu/kmem.h> 21#include <nvgpu/kmem.h>
22#include <nvgpu/soc.h>
22 23
23#include "gk20a.h" 24#include "gk20a.h"
24#include "channel_gk20a.h" 25#include "channel_gk20a.h"
@@ -80,10 +81,10 @@ static inline bool gk20a_fence_is_valid(struct gk20a_fence *f)
80 return valid; 81 return valid;
81} 82}
82 83
83int gk20a_fence_wait(struct gk20a_fence *f, int timeout) 84int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f, int timeout)
84{ 85{
85 if (f && gk20a_fence_is_valid(f)) { 86 if (f && gk20a_fence_is_valid(f)) {
86 if (!tegra_platform_is_silicon()) 87 if (!nvgpu_platform_is_silicon(g))
87 timeout = (u32)MAX_SCHEDULE_TIMEOUT; 88 timeout = (u32)MAX_SCHEDULE_TIMEOUT;
88 return f->ops->wait(f, timeout); 89 return f->ops->wait(f, timeout);
89 } 90 }
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
index 426556cc..77dae9a7 100644
--- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
@@ -25,6 +25,7 @@ struct sync_timeline;
25struct sync_fence; 25struct sync_fence;
26struct nvgpu_semaphore; 26struct nvgpu_semaphore;
27struct channel_gk20a; 27struct channel_gk20a;
28struct gk20a;
28 29
29struct gk20a_fence_ops; 30struct gk20a_fence_ops;
30 31
@@ -83,7 +84,7 @@ void gk20a_init_fence(struct gk20a_fence *f,
83/* Fence operations */ 84/* Fence operations */
84void gk20a_fence_put(struct gk20a_fence *f); 85void gk20a_fence_put(struct gk20a_fence *f);
85struct gk20a_fence *gk20a_fence_get(struct gk20a_fence *f); 86struct gk20a_fence *gk20a_fence_get(struct gk20a_fence *f);
86int gk20a_fence_wait(struct gk20a_fence *f, int timeout); 87int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f, int timeout);
87bool gk20a_fence_is_expired(struct gk20a_fence *f); 88bool gk20a_fence_is_expired(struct gk20a_fence *f);
88int gk20a_fence_install_fd(struct gk20a_fence *f); 89int gk20a_fence_install_fd(struct gk20a_fence *f);
89 90
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
index c7db67fe..bdd068fe 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
@@ -31,6 +31,7 @@
31#include <nvgpu/semaphore.h> 31#include <nvgpu/semaphore.h>
32#include <nvgpu/kmem.h> 32#include <nvgpu/kmem.h>
33#include <nvgpu/log.h> 33#include <nvgpu/log.h>
34#include <nvgpu/soc.h>
34 35
35#include "gk20a.h" 36#include "gk20a.h"
36#include "debug_gk20a.h" 37#include "debug_gk20a.h"
@@ -3349,7 +3350,7 @@ static void gk20a_fifo_apply_pb_timeout(struct gk20a *g)
3349{ 3350{
3350 u32 timeout; 3351 u32 timeout;
3351 3352
3352 if (tegra_platform_is_silicon()) { 3353 if (nvgpu_platform_is_silicon(g)) {
3353 timeout = gk20a_readl(g, fifo_pb_timeout_r()); 3354 timeout = gk20a_readl(g, fifo_pb_timeout_r());
3354 timeout &= ~fifo_pb_timeout_detection_enabled_f(); 3355 timeout &= ~fifo_pb_timeout_detection_enabled_f();
3355 gk20a_writel(g, fifo_pb_timeout_r(), timeout); 3356 gk20a_writel(g, fifo_pb_timeout_r(), timeout);
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 5fc57494..339656c7 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -43,6 +43,7 @@
43#include <nvgpu/kmem.h> 43#include <nvgpu/kmem.h>
44#include <nvgpu/allocator.h> 44#include <nvgpu/allocator.h>
45#include <nvgpu/timers.h> 45#include <nvgpu/timers.h>
46#include <nvgpu/soc.h>
46 47
47#include "gk20a.h" 48#include "gk20a.h"
48#include "debug_gk20a.h" 49#include "debug_gk20a.h"
@@ -295,7 +296,7 @@ static int gk20a_init_support(struct platform_device *dev)
295 goto fail; 296 goto fail;
296 } 297 }
297 298
298 if (tegra_cpu_is_asim()) { 299 if (nvgpu_platform_is_simulation(g)) {
299 err = gk20a_init_sim_support(dev); 300 err = gk20a_init_sim_support(dev);
300 if (err) 301 if (err)
301 goto fail; 302 goto fail;
@@ -954,9 +955,6 @@ static int gk20a_probe(struct platform_device *dev)
954 return -ENODATA; 955 return -ENODATA;
955 } 956 }
956 957
957 if (tegra_platform_is_linsim() || tegra_platform_is_vdk())
958 platform->is_fmodel = true;
959
960 gk20a_dbg_fn(""); 958 gk20a_dbg_fn("");
961 959
962 platform_set_drvdata(dev, platform); 960 platform_set_drvdata(dev, platform);
@@ -973,6 +971,9 @@ static int gk20a_probe(struct platform_device *dev)
973 set_gk20a(dev, gk20a); 971 set_gk20a(dev, gk20a);
974 gk20a->dev = &dev->dev; 972 gk20a->dev = &dev->dev;
975 973
974 if (nvgpu_platform_is_simulation(gk20a))
975 platform->is_fmodel = true;
976
976 nvgpu_kmem_init(gk20a); 977 nvgpu_kmem_init(gk20a);
977 978
978 gk20a->irq_stall = platform_get_irq(dev, 0); 979 gk20a->irq_stall = platform_get_irq(dev, 0);
@@ -1030,7 +1031,7 @@ static int gk20a_probe(struct platform_device *dev)
1030 return err; 1031 return err;
1031 } 1032 }
1032 1033
1033 gk20a->mm.has_physical_mode = !is_tegra_hypervisor_mode(); 1034 gk20a->mm.has_physical_mode = !nvgpu_is_hypervisor_mode(gk20a);
1034 1035
1035 return 0; 1036 return 0;
1036} 1037}
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 9d931520..1cff8dd5 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -34,7 +34,6 @@ struct dbg_profiler_object_data;
34#include <nvgpu/lock.h> 34#include <nvgpu/lock.h>
35#include <linux/nvgpu.h> 35#include <linux/nvgpu.h>
36#include <linux/irqreturn.h> 36#include <linux/irqreturn.h>
37#include <soc/tegra/chip-id.h>
38#include <linux/version.h> 37#include <linux/version.h>
39#include <linux/atomic.h> 38#include <linux/atomic.h>
40#include <linux/cdev.h> 39#include <linux/cdev.h>
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 78332ee7..7472c7cd 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -569,7 +569,7 @@ static int gk20a_vidmem_clear_all(struct gk20a *g)
569 NVGPU_TIMER_CPU_TIMER); 569 NVGPU_TIMER_CPU_TIMER);
570 570
571 do { 571 do {
572 err = gk20a_fence_wait(gk20a_fence_out, 572 err = gk20a_fence_wait(g, gk20a_fence_out,
573 gk20a_get_gr_idle_timeout(g)); 573 gk20a_get_gr_idle_timeout(g));
574 } while (err == -ERESTARTSYS && 574 } while (err == -ERESTARTSYS &&
575 !nvgpu_timeout_expired(&timeout)); 575 !nvgpu_timeout_expired(&timeout));
@@ -2560,7 +2560,7 @@ static int gk20a_gmmu_clear_vidmem_mem(struct gk20a *g, struct nvgpu_mem *mem)
2560 NVGPU_TIMER_CPU_TIMER); 2560 NVGPU_TIMER_CPU_TIMER);
2561 2561
2562 do { 2562 do {
2563 err = gk20a_fence_wait(gk20a_last_fence, 2563 err = gk20a_fence_wait(g, gk20a_last_fence,
2564 gk20a_get_gr_idle_timeout(g)); 2564 gk20a_get_gr_idle_timeout(g));
2565 } while (err == -ERESTARTSYS && 2565 } while (err == -ERESTARTSYS &&
2566 !nvgpu_timeout_expired(&timeout)); 2566 !nvgpu_timeout_expired(&timeout));
diff --git a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c
index 38b8da9c..7df0c71c 100644
--- a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c
@@ -3642,19 +3642,10 @@ static int pmu_pg_init_send(struct gk20a *g, u32 pg_engine_id)
3642 3642
3643 gk20a_dbg_fn(""); 3643 gk20a_dbg_fn("");
3644 3644
3645 if (tegra_cpu_is_asim()) { 3645 gk20a_writel(g, pwr_pmu_pg_idlefilth_r(pg_engine_id),
3646 /* TBD: calculate threshold for silicon */ 3646 PMU_PG_IDLE_THRESHOLD);
3647 gk20a_writel(g, pwr_pmu_pg_idlefilth_r(pg_engine_id), 3647 gk20a_writel(g, pwr_pmu_pg_ppuidlefilth_r(pg_engine_id),
3648 PMU_PG_IDLE_THRESHOLD_SIM); 3648 PMU_PG_POST_POWERUP_IDLE_THRESHOLD);
3649 gk20a_writel(g, pwr_pmu_pg_ppuidlefilth_r(pg_engine_id),
3650 PMU_PG_POST_POWERUP_IDLE_THRESHOLD_SIM);
3651 } else {
3652 /* TBD: calculate threshold for silicon */
3653 gk20a_writel(g, pwr_pmu_pg_idlefilth_r(pg_engine_id),
3654 PMU_PG_IDLE_THRESHOLD);
3655 gk20a_writel(g, pwr_pmu_pg_ppuidlefilth_r(pg_engine_id),
3656 PMU_PG_POST_POWERUP_IDLE_THRESHOLD);
3657 }
3658 3649
3659 if (g->ops.pmu.pmu_pg_init_param) 3650 if (g->ops.pmu.pmu_pg_init_param)
3660 g->ops.pmu.pmu_pg_init_param(g, pg_engine_id); 3651 g->ops.pmu.pmu_pg_init_param(g, pg_engine_id);
diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
index 644140d8..20c2e997 100644
--- a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
@@ -31,6 +31,8 @@
31#include "gk20a/gk20a.h" 31#include "gk20a/gk20a.h"
32#include "clk_gm20b.h" 32#include "clk_gm20b.h"
33 33
34#include <nvgpu/soc.h>
35
34#include <nvgpu/hw/gm20b/hw_trim_gm20b.h> 36#include <nvgpu/hw/gm20b/hw_trim_gm20b.h>
35#include <nvgpu/hw/gm20b/hw_timer_gm20b.h> 37#include <nvgpu/hw/gm20b/hw_timer_gm20b.h>
36#include <nvgpu/hw/gm20b/hw_therm_gm20b.h> 38#include <nvgpu/hw/gm20b/hw_therm_gm20b.h>
@@ -835,7 +837,7 @@ static int clk_program_gpc_pll(struct gk20a *g, struct pll *gpll_new,
835 837
836 gk20a_dbg_fn(""); 838 gk20a_dbg_fn("");
837 839
838 if (!tegra_platform_is_silicon()) 840 if (!nvgpu_platform_is_silicon(g))
839 return 0; 841 return 0;
840 842
841 /* get old coefficients */ 843 /* get old coefficients */
diff --git a/drivers/gpu/nvgpu/gp106/pmu_gp106.c b/drivers/gpu/nvgpu/gp106/pmu_gp106.c
index cadbd308..308bcf04 100644
--- a/drivers/gpu/nvgpu/gp106/pmu_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/pmu_gp106.c
@@ -71,7 +71,7 @@ static int gp106_pmu_enable_hw(struct pmu_gk20a *pmu, bool enable)
71 return 0; 71 return 0;
72 } 72 }
73 udelay(PMU_MEM_SCRUBBING_TIMEOUT_DEFAULT); 73 udelay(PMU_MEM_SCRUBBING_TIMEOUT_DEFAULT);
74 } while (--retries || !tegra_platform_is_silicon()); 74 } while (--retries);
75 75
76 /* If scrubbing timeout, keep PMU in reset state */ 76 /* If scrubbing timeout, keep PMU in reset state */
77 gk20a_writel(g, pwr_falcon_engine_r(), 77 gk20a_writel(g, pwr_falcon_engine_r(),
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.c b/drivers/gpu/nvgpu/gp106/therm_gp106.c
index bf8fbfe7..761d1b89 100644
--- a/drivers/gpu/nvgpu/gp106/therm_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/therm_gp106.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,
@@ -87,12 +87,6 @@ static int gp106_elcg_init_idle_filters(struct gk20a *g)
87 active_engine_id = f->active_engines_list[engine_id]; 87 active_engine_id = f->active_engines_list[engine_id];
88 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id)); 88 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id));
89 89
90 if (tegra_platform_is_linsim()) {
91 gate_ctrl = set_field(gate_ctrl,
92 therm_gate_ctrl_eng_delay_after_m(),
93 therm_gate_ctrl_eng_delay_after_f(4));
94 }
95
96 gate_ctrl = set_field(gate_ctrl, 90 gate_ctrl = set_field(gate_ctrl,
97 therm_gate_ctrl_eng_idle_filt_exp_m(), 91 therm_gate_ctrl_eng_idle_filt_exp_m(),
98 therm_gate_ctrl_eng_idle_filt_exp_f(2)); 92 therm_gate_ctrl_eng_idle_filt_exp_f(2));
diff --git a/drivers/gpu/nvgpu/gp10b/therm_gp10b.c b/drivers/gpu/nvgpu/gp10b/therm_gp10b.c
index 4b346313..3656cef3 100644
--- a/drivers/gpu/nvgpu/gp10b/therm_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/therm_gp10b.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * drivers/gpu/nvgpu/gm20b/therm_gk20a.c
3 *
4 * GP10B Therm 2 * GP10B Therm
5 * 3 *
6 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
7 * 5 *
8 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -17,6 +15,8 @@
17 15
18#include "gk20a/gk20a.h" 16#include "gk20a/gk20a.h"
19 17
18#include <nvgpu/soc.h>
19
20#include <nvgpu/hw/gp10b/hw_therm_gp10b.h> 20#include <nvgpu/hw/gp10b/hw_therm_gp10b.h>
21 21
22static int gp10b_init_therm_setup_hw(struct gk20a *g) 22static int gp10b_init_therm_setup_hw(struct gk20a *g)
@@ -92,7 +92,7 @@ static int gp10b_elcg_init_idle_filters(struct gk20a *g)
92 active_engine_id = f->active_engines_list[engine_id]; 92 active_engine_id = f->active_engines_list[engine_id];
93 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id)); 93 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id));
94 94
95 if (tegra_platform_is_linsim()) { 95 if (nvgpu_platform_is_simulation(g)) {
96 gate_ctrl = set_field(gate_ctrl, 96 gate_ctrl = set_field(gate_ctrl,
97 therm_gate_ctrl_eng_delay_after_m(), 97 therm_gate_ctrl_eng_delay_after_m(),
98 therm_gate_ctrl_eng_delay_after_f(4)); 98 therm_gate_ctrl_eng_delay_after_f(4));
diff --git a/drivers/gpu/nvgpu/include/nvgpu/soc.h b/drivers/gpu/nvgpu/include/nvgpu/soc.h
new file mode 100644
index 00000000..739d5eb0
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/soc.h
@@ -0,0 +1,22 @@
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#ifndef __NVGPU_SOC_H__
14#define __NVGPU_SOC_H__
15
16struct gk20a;
17
18bool nvgpu_platform_is_silicon(struct gk20a *g);
19bool nvgpu_platform_is_simulation(struct gk20a *g);
20bool nvgpu_is_hypervisor_mode(struct gk20a *g);
21
22#endif
diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c
index 4f8faf5a..e318e822 100644
--- a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c
+++ b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c
@@ -46,6 +46,7 @@
46#endif 46#endif
47 47
48#include <linux/platform/tegra/tegra_emc.h> 48#include <linux/platform/tegra/tegra_emc.h>
49#include <soc/tegra/chip-id.h>
49 50
50#include <nvgpu/kmem.h> 51#include <nvgpu/kmem.h>
51 52