summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2016-03-31 14:13:42 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-04-15 11:50:34 -0400
commit7d8e2193893454bc8e05543c956fab32b8eed54b (patch)
treeafb73b81611136fd0411e17995532d6d22b0499f /drivers/gpu/nvgpu/gk20a
parent6839341bf8ffafa115cfc0427bba694ee1d131f3 (diff)
gpu: nvgpu: Use sysmem aperture for SoC memory
In Tegra GPU, SoC memory has to be accessed as vidmem. In discrete GPU, it has to be accessed as sysmem. Change-Id: I4efe71b54a9a32f0bf1f02ec4016ed74405a14c5 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1120468
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c14
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.c4
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c24
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_bus_gk20a.h18
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_ccsr_gk20a.h10
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_fb_gk20a.h22
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_fifo_gk20a.h10
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_gmmu_gk20a.h26
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_gr_gk20a.h8
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_pbdma_gk20a.h8
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_pwr_gk20a.h6
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_ram_gk20a.h10
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c32
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.h2
14 files changed, 165 insertions, 29 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index e8d82e0e..b7bccd07 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -130,6 +130,7 @@ static int channel_gk20a_commit_userd(struct channel_gk20a *c)
130 u32 addr_lo; 130 u32 addr_lo;
131 u32 addr_hi; 131 u32 addr_hi;
132 void *inst_ptr; 132 void *inst_ptr;
133 struct gk20a *g = c->g;
133 134
134 gk20a_dbg_fn(""); 135 gk20a_dbg_fn("");
135 136
@@ -144,12 +145,13 @@ static int channel_gk20a_commit_userd(struct channel_gk20a *c)
144 c->hw_chid, (u64)c->userd_iova); 145 c->hw_chid, (u64)c->userd_iova);
145 146
146 gk20a_mem_wr32(inst_ptr, ram_in_ramfc_w() + ram_fc_userd_w(), 147 gk20a_mem_wr32(inst_ptr, ram_in_ramfc_w() + ram_fc_userd_w(),
147 pbdma_userd_target_vid_mem_f() | 148 (g->mm.vidmem_is_vidmem ?
148 pbdma_userd_addr_f(addr_lo)); 149 pbdma_userd_target_sys_mem_ncoh_f() :
150 pbdma_userd_target_vid_mem_f()) |
151 pbdma_userd_addr_f(addr_lo));
149 152
150 gk20a_mem_wr32(inst_ptr, ram_in_ramfc_w() + ram_fc_userd_hi_w(), 153 gk20a_mem_wr32(inst_ptr, ram_in_ramfc_w() + ram_fc_userd_hi_w(),
151 pbdma_userd_target_vid_mem_f() | 154 pbdma_userd_hi_addr_f(addr_hi));
152 pbdma_userd_hi_addr_f(addr_hi));
153 155
154 return 0; 156 return 0;
155} 157}
@@ -354,7 +356,9 @@ static void channel_gk20a_bind(struct channel_gk20a *c)
354 356
355 gk20a_writel(g, ccsr_channel_inst_r(c->hw_chid), 357 gk20a_writel(g, ccsr_channel_inst_r(c->hw_chid),
356 ccsr_channel_inst_ptr_f(inst_ptr) | 358 ccsr_channel_inst_ptr_f(inst_ptr) |
357 ccsr_channel_inst_target_vid_mem_f() | 359 (g->mm.vidmem_is_vidmem ?
360 ccsr_channel_inst_target_sys_mem_ncoh_f() :
361 ccsr_channel_inst_target_vid_mem_f()) |
358 ccsr_channel_inst_bind_true_f()); 362 ccsr_channel_inst_bind_true_f());
359 363
360 gk20a_writel(g, ccsr_channel_r(c->hw_chid), 364 gk20a_writel(g, ccsr_channel_r(c->hw_chid),
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
index 33ed9a04..d8c07c89 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
@@ -2405,7 +2405,9 @@ static int gk20a_fifo_update_runlist_locked(struct gk20a *g, u32 runlist_id,
2405 if (count != 0) { 2405 if (count != 0) {
2406 gk20a_writel(g, fifo_runlist_base_r(), 2406 gk20a_writel(g, fifo_runlist_base_r(),
2407 fifo_runlist_base_ptr_f(u64_lo32(runlist_iova >> 12)) | 2407 fifo_runlist_base_ptr_f(u64_lo32(runlist_iova >> 12)) |
2408 fifo_runlist_base_target_vid_mem_f()); 2408 (g->mm.vidmem_is_vidmem ?
2409 fifo_runlist_base_target_sys_mem_ncoh_f() :
2410 fifo_runlist_base_target_vid_mem_f()));
2409 } 2411 }
2410 2412
2411 gk20a_writel(g, fifo_runlist_r(), 2413 gk20a_writel(g, fifo_runlist_r(),
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index 51a61de3..734552a1 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -739,7 +739,9 @@ static int gr_gk20a_fecs_ctx_bind_channel(struct gk20a *g,
739 (struct fecs_method_op_gk20a) { 739 (struct fecs_method_op_gk20a) {
740 .method.addr = gr_fecs_method_push_adr_bind_pointer_v(), 740 .method.addr = gr_fecs_method_push_adr_bind_pointer_v(),
741 .method.data = (gr_fecs_current_ctx_ptr_f(inst_base_ptr) | 741 .method.data = (gr_fecs_current_ctx_ptr_f(inst_base_ptr) |
742 gr_fecs_current_ctx_target_vid_mem_f() | 742 (g->mm.vidmem_is_vidmem ?
743 gr_fecs_current_ctx_target_sys_mem_ncoh_f() :
744 gr_fecs_current_ctx_target_vid_mem_f()) |
743 gr_fecs_current_ctx_valid_f(1)), 745 gr_fecs_current_ctx_valid_f(1)),
744 .mailbox = { .id = 0, .data = 0, 746 .mailbox = { .id = 0, .data = 0,
745 .clr = 0x30, 747 .clr = 0x30,
@@ -1421,7 +1423,9 @@ static int gr_gk20a_fecs_ctx_image_save(struct channel_gk20a *c, u32 save_type)
1421 (struct fecs_method_op_gk20a) { 1423 (struct fecs_method_op_gk20a) {
1422 .method.addr = save_type, 1424 .method.addr = save_type,
1423 .method.data = (gr_fecs_current_ctx_ptr_f(inst_base_ptr) | 1425 .method.data = (gr_fecs_current_ctx_ptr_f(inst_base_ptr) |
1424 gr_fecs_current_ctx_target_vid_mem_f() | 1426 (g->mm.vidmem_is_vidmem ?
1427 gr_fecs_current_ctx_target_sys_mem_ncoh_f() :
1428 gr_fecs_current_ctx_target_vid_mem_f()) |
1425 gr_fecs_current_ctx_valid_f(1)), 1429 gr_fecs_current_ctx_valid_f(1)),
1426 .mailbox = {.id = 0, .data = 0, .clr = 3, .ret = NULL, 1430 .mailbox = {.id = 0, .data = 0, .clr = 3, .ret = NULL,
1427 .ok = 1, .fail = 2, 1431 .ok = 1, .fail = 2,
@@ -1885,7 +1889,9 @@ int gr_gk20a_load_golden_ctx_image(struct gk20a *g,
1885 (struct fecs_method_op_gk20a) { 1889 (struct fecs_method_op_gk20a) {
1886 .method.data = 1890 .method.data =
1887 (gr_fecs_current_ctx_ptr_f(inst_base_ptr) | 1891 (gr_fecs_current_ctx_ptr_f(inst_base_ptr) |
1888 gr_fecs_current_ctx_target_vid_mem_f() | 1892 (g->mm.vidmem_is_vidmem ?
1893 gr_fecs_current_ctx_target_sys_mem_ncoh_f() :
1894 gr_fecs_current_ctx_target_vid_mem_f()) |
1889 gr_fecs_current_ctx_valid_f(1)), 1895 gr_fecs_current_ctx_valid_f(1)),
1890 .method.addr = 1896 .method.addr =
1891 gr_fecs_method_push_adr_restore_golden_v(), 1897 gr_fecs_method_push_adr_restore_golden_v(),
@@ -4291,7 +4297,9 @@ static int gk20a_init_gr_setup_hw(struct gk20a *g)
4291 addr >>= fb_mmu_debug_wr_addr_alignment_v(); 4297 addr >>= fb_mmu_debug_wr_addr_alignment_v();
4292 4298
4293 gk20a_writel(g, fb_mmu_debug_wr_r(), 4299 gk20a_writel(g, fb_mmu_debug_wr_r(),
4294 fb_mmu_debug_wr_aperture_vid_mem_f() | 4300 (g->mm.vidmem_is_vidmem ?
4301 fb_mmu_debug_wr_aperture_sys_mem_ncoh_f() :
4302 fb_mmu_debug_wr_aperture_vid_mem_f()) |
4295 fb_mmu_debug_wr_vol_false_f() | 4303 fb_mmu_debug_wr_vol_false_f() |
4296 fb_mmu_debug_wr_addr_f(addr)); 4304 fb_mmu_debug_wr_addr_f(addr));
4297 4305
@@ -4299,7 +4307,9 @@ static int gk20a_init_gr_setup_hw(struct gk20a *g)
4299 addr >>= fb_mmu_debug_rd_addr_alignment_v(); 4307 addr >>= fb_mmu_debug_rd_addr_alignment_v();
4300 4308
4301 gk20a_writel(g, fb_mmu_debug_rd_r(), 4309 gk20a_writel(g, fb_mmu_debug_rd_r(),
4302 fb_mmu_debug_rd_aperture_vid_mem_f() | 4310 (g->mm.vidmem_is_vidmem ?
4311 fb_mmu_debug_wr_aperture_sys_mem_ncoh_f() :
4312 fb_mmu_debug_rd_aperture_vid_mem_f()) |
4303 fb_mmu_debug_rd_vol_false_f() | 4313 fb_mmu_debug_rd_vol_false_f() |
4304 fb_mmu_debug_rd_addr_f(addr)); 4314 fb_mmu_debug_rd_addr_f(addr));
4305 4315
@@ -5967,7 +5977,9 @@ int gr_gk20a_fecs_set_reglist_bind_inst(struct gk20a *g, phys_addr_t addr)
5967 .mailbox.id = 4, 5977 .mailbox.id = 4,
5968 .mailbox.data = (gr_fecs_current_ctx_ptr_f(addr >> 12) | 5978 .mailbox.data = (gr_fecs_current_ctx_ptr_f(addr >> 12) |
5969 gr_fecs_current_ctx_valid_f(1) | 5979 gr_fecs_current_ctx_valid_f(1) |
5970 gr_fecs_current_ctx_target_vid_mem_f()), 5980 (g->mm.vidmem_is_vidmem ?
5981 gr_fecs_current_ctx_target_sys_mem_ncoh_f() :
5982 gr_fecs_current_ctx_target_vid_mem_f())),
5971 .mailbox.clr = ~0, 5983 .mailbox.clr = ~0,
5972 .method.data = 1, 5984 .method.data = 1,
5973 .method.addr = gr_fecs_method_push_adr_set_reglist_bind_instance_v(), 5985 .method.addr = gr_fecs_method_push_adr_set_reglist_bind_instance_v(),
diff --git a/drivers/gpu/nvgpu/gk20a/hw_bus_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_bus_gk20a.h
index 44ef9424..8a69c573 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_bus_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_bus_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -62,6 +62,14 @@ static inline u32 bus_bar1_block_target_vid_mem_f(void)
62{ 62{
63 return 0x0; 63 return 0x0;
64} 64}
65static inline u32 bus_bar1_block_target_sys_mem_coh_f(void)
66{
67 return 0x20000000;
68}
69static inline u32 bus_bar1_block_target_sys_mem_ncoh_f(void)
70{
71 return 0x30000000;
72}
65static inline u32 bus_bar1_block_mode_virtual_f(void) 73static inline u32 bus_bar1_block_mode_virtual_f(void)
66{ 74{
67 return 0x80000000; 75 return 0x80000000;
@@ -78,6 +86,14 @@ static inline u32 bus_bar2_block_target_vid_mem_f(void)
78{ 86{
79 return 0x0; 87 return 0x0;
80} 88}
89static inline u32 bus_bar2_block_target_sys_mem_coh_f(void)
90{
91 return 0x20000000;
92}
93static inline u32 bus_bar2_block_target_sys_mem_ncoh_f(void)
94{
95 return 0x30000000;
96}
81static inline u32 bus_bar2_block_mode_virtual_f(void) 97static inline u32 bus_bar2_block_mode_virtual_f(void)
82{ 98{
83 return 0x80000000; 99 return 0x80000000;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_ccsr_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_ccsr_gk20a.h
index 573329f1..4877e4a8 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_ccsr_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_ccsr_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -66,6 +66,14 @@ static inline u32 ccsr_channel_inst_target_vid_mem_f(void)
66{ 66{
67 return 0x0; 67 return 0x0;
68} 68}
69static inline u32 ccsr_channel_inst_target_sys_mem_coh_f(void)
70{
71 return 0x20000000;
72}
73static inline u32 ccsr_channel_inst_target_sys_mem_ncoh_f(void)
74{
75 return 0x30000000;
76}
69static inline u32 ccsr_channel_inst_bind_false_f(void) 77static inline u32 ccsr_channel_inst_bind_false_f(void)
70{ 78{
71 return 0x0; 79 return 0x0;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_fb_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_fb_gk20a.h
index 0234265a..46846b21 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_fb_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_fb_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -86,6 +86,10 @@ static inline u32 fb_mmu_invalidate_pdb_aperture_vid_mem_f(void)
86{ 86{
87 return 0x0; 87 return 0x0;
88} 88}
89static inline u32 fb_mmu_invalidate_pdb_aperture_sys_mem_f(void)
90{
91 return 0x2;
92}
89static inline u32 fb_mmu_invalidate_pdb_addr_f(u32 v) 93static inline u32 fb_mmu_invalidate_pdb_addr_f(u32 v)
90{ 94{
91 return (v & 0xfffffff) << 4; 95 return (v & 0xfffffff) << 4;
@@ -146,6 +150,14 @@ static inline u32 fb_mmu_debug_wr_aperture_vid_mem_f(void)
146{ 150{
147 return 0x0; 151 return 0x0;
148} 152}
153static inline u32 fb_mmu_debug_wr_aperture_sys_mem_coh_f(void)
154{
155 return 0x2;
156}
157static inline u32 fb_mmu_debug_wr_aperture_sys_mem_ncoh_f(void)
158{
159 return 0x3;
160}
149static inline u32 fb_mmu_debug_wr_vol_false_f(void) 161static inline u32 fb_mmu_debug_wr_vol_false_f(void)
150{ 162{
151 return 0x0; 163 return 0x0;
@@ -174,6 +186,14 @@ static inline u32 fb_mmu_debug_rd_aperture_vid_mem_f(void)
174{ 186{
175 return 0x0; 187 return 0x0;
176} 188}
189static inline u32 fb_mmu_debug_rd_aperture_sys_mem_coh_f(void)
190{
191 return 0x2;
192}
193static inline u32 fb_mmu_debug_rd_aperture_sys_mem_ncoh_f(void)
194{
195 return 0x3;
196}
177static inline u32 fb_mmu_debug_rd_vol_false_f(void) 197static inline u32 fb_mmu_debug_rd_vol_false_f(void)
178{ 198{
179 return 0x0; 199 return 0x0;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_fifo_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_fifo_gk20a.h
index 99d92782..07e2b4f8 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_fifo_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_fifo_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -82,6 +82,14 @@ static inline u32 fifo_runlist_base_target_vid_mem_f(void)
82{ 82{
83 return 0x0; 83 return 0x0;
84} 84}
85static inline u32 fifo_runlist_base_target_sys_mem_coh_f(void)
86{
87 return 0x20000000;
88}
89static inline u32 fifo_runlist_base_target_sys_mem_ncoh_f(void)
90{
91 return 0x30000000;
92}
85static inline u32 fifo_runlist_r(void) 93static inline u32 fifo_runlist_r(void)
86{ 94{
87 return 0x00002274; 95 return 0x00002274;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_gmmu_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_gmmu_gk20a.h
index d92f0d58..9b444036 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_gmmu_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_gmmu_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -62,6 +62,14 @@ static inline u32 gmmu_pde_aperture_big_video_memory_f(void)
62{ 62{
63 return 0x1; 63 return 0x1;
64} 64}
65static inline u32 gmmu_pde_aperture_big_sys_mem_coh_f(void)
66{
67 return 0x2;
68}
69static inline u32 gmmu_pde_aperture_big_sys_mem_ncoh_f(void)
70{
71 return 0x3;
72}
65static inline u32 gmmu_pde_size_w(void) 73static inline u32 gmmu_pde_size_w(void)
66{ 74{
67 return 0; 75 return 0;
@@ -90,6 +98,14 @@ static inline u32 gmmu_pde_aperture_small_video_memory_f(void)
90{ 98{
91 return 0x1; 99 return 0x1;
92} 100}
101static inline u32 gmmu_pde_aperture_small_sys_mem_coh_f(void)
102{
103 return 0x2;
104}
105static inline u32 gmmu_pde_aperture_small_sys_mem_ncoh_f(void)
106{
107 return 0x3;
108}
93static inline u32 gmmu_pde_vol_small_w(void) 109static inline u32 gmmu_pde_vol_small_w(void)
94{ 110{
95 return 1; 111 return 1;
@@ -186,6 +202,14 @@ static inline u32 gmmu_pte_aperture_video_memory_f(void)
186{ 202{
187 return 0x0; 203 return 0x0;
188} 204}
205static inline u32 gmmu_pte_aperture_sys_mem_coh_f(void)
206{
207 return 0x4;
208}
209static inline u32 gmmu_pte_aperture_sys_mem_ncoh_f(void)
210{
211 return 0x6;
212}
189static inline u32 gmmu_pte_read_only_w(void) 213static inline u32 gmmu_pte_read_only_w(void)
190{ 214{
191 return 0; 215 return 0;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_gr_gk20a.h
index a3ae664f..48aa1524 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_gr_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_gr_gk20a.h
@@ -826,6 +826,14 @@ static inline u32 gr_fecs_current_ctx_target_vid_mem_f(void)
826{ 826{
827 return 0x0; 827 return 0x0;
828} 828}
829static inline u32 gr_fecs_current_ctx_target_sys_mem_coh_f(void)
830{
831 return 0x20000000;
832}
833static inline u32 gr_fecs_current_ctx_target_sys_mem_ncoh_f(void)
834{
835 return 0x30000000;
836}
829static inline u32 gr_fecs_current_ctx_valid_s(void) 837static inline u32 gr_fecs_current_ctx_valid_s(void)
830{ 838{
831 return 1; 839 return 1;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_pbdma_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_pbdma_gk20a.h
index 79a4ef96..09cfc084 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_pbdma_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_pbdma_gk20a.h
@@ -334,6 +334,14 @@ static inline u32 pbdma_userd_target_vid_mem_f(void)
334{ 334{
335 return 0x0; 335 return 0x0;
336} 336}
337static inline u32 pbdma_userd_target_sys_mem_coh_f(void)
338{
339 return 0x2;
340}
341static inline u32 pbdma_userd_target_sys_mem_ncoh_f(void)
342{
343 return 0x3;
344}
337static inline u32 pbdma_userd_addr_f(u32 v) 345static inline u32 pbdma_userd_addr_f(u32 v)
338{ 346{
339 return (v & 0x7fffff) << 9; 347 return (v & 0x7fffff) << 9;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_pwr_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_pwr_gk20a.h
index 35312bd4..ab1eb184 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_pwr_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_pwr_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -494,6 +494,10 @@ static inline u32 pwr_pmu_new_instblk_target_sys_coh_f(void)
494{ 494{
495 return 0x20000000; 495 return 0x20000000;
496} 496}
497static inline u32 pwr_pmu_new_instblk_target_sys_ncoh_f(void)
498{
499 return 0x30000000;
500}
497static inline u32 pwr_pmu_new_instblk_valid_f(u32 v) 501static inline u32 pwr_pmu_new_instblk_valid_f(u32 v)
498{ 502{
499 return (v & 0x1) << 30; 503 return (v & 0x1) << 30;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_ram_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_ram_gk20a.h
index 0f4f6726..0009be33 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_ram_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_ram_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2012-2016, 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,
@@ -70,6 +70,14 @@ static inline u32 ram_in_page_dir_base_target_vid_mem_f(void)
70{ 70{
71 return 0x0; 71 return 0x0;
72} 72}
73static inline u32 ram_in_page_dir_base_target_sys_mem_coh_f(void)
74{
75 return 0x2;
76}
77static inline u32 ram_in_page_dir_base_target_sys_mem_ncoh_f(void)
78{
79 return 0x3;
80}
73static inline u32 ram_in_page_dir_base_vol_w(void) 81static inline u32 ram_in_page_dir_base_vol_w(void)
74{ 82{
75 return 128; 83 return 128;
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 519faeeb..5c3f83a6 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -497,7 +497,9 @@ int gk20a_init_mm_setup_hw(struct gk20a *g)
497 gk20a_dbg_info("bar1 inst block ptr: 0x%08x", (u32)inst_pa); 497 gk20a_dbg_info("bar1 inst block ptr: 0x%08x", (u32)inst_pa);
498 498
499 gk20a_writel(g, bus_bar1_block_r(), 499 gk20a_writel(g, bus_bar1_block_r(),
500 bus_bar1_block_target_vid_mem_f() | 500 (g->mm.vidmem_is_vidmem ?
501 bus_bar1_block_target_sys_mem_ncoh_f() :
502 bus_bar1_block_target_vid_mem_f()) |
501 bus_bar1_block_mode_virtual_f() | 503 bus_bar1_block_mode_virtual_f() |
502 bus_bar1_block_ptr_f(inst_pa)); 504 bus_bar1_block_ptr_f(inst_pa));
503 505
@@ -2271,19 +2273,23 @@ u64 gk20a_mm_iova_addr(struct gk20a *g, struct scatterlist *sgl,
2271} 2273}
2272 2274
2273/* for gk20a the "video memory" apertures here are misnomers. */ 2275/* for gk20a the "video memory" apertures here are misnomers. */
2274static inline u32 big_valid_pde0_bits(u64 pte_addr) 2276static inline u32 big_valid_pde0_bits(struct gk20a *g, u64 pte_addr)
2275{ 2277{
2276 u32 pde0_bits = 2278 u32 pde0_bits =
2277 gmmu_pde_aperture_big_video_memory_f() | 2279 (g->mm.vidmem_is_vidmem ?
2280 gmmu_pde_aperture_big_sys_mem_ncoh_f() :
2281 gmmu_pde_aperture_big_video_memory_f()) |
2278 gmmu_pde_address_big_sys_f( 2282 gmmu_pde_address_big_sys_f(
2279 (u32)(pte_addr >> gmmu_pde_address_shift_v())); 2283 (u32)(pte_addr >> gmmu_pde_address_shift_v()));
2280 return pde0_bits; 2284 return pde0_bits;
2281} 2285}
2282 2286
2283static inline u32 small_valid_pde1_bits(u64 pte_addr) 2287static inline u32 small_valid_pde1_bits(struct gk20a *g, u64 pte_addr)
2284{ 2288{
2285 u32 pde1_bits = 2289 u32 pde1_bits =
2286 gmmu_pde_aperture_small_video_memory_f() | 2290 (g->mm.vidmem_is_vidmem ?
2291 gmmu_pde_aperture_small_sys_mem_ncoh_f() :
2292 gmmu_pde_aperture_small_video_memory_f()) |
2287 gmmu_pde_vol_small_true_f() | /* tbd: why? */ 2293 gmmu_pde_vol_small_true_f() | /* tbd: why? */
2288 gmmu_pde_address_small_sys_f( 2294 gmmu_pde_address_small_sys_f(
2289 (u32)(pte_addr >> gmmu_pde_address_shift_v())); 2295 (u32)(pte_addr >> gmmu_pde_address_shift_v()));
@@ -2325,11 +2331,11 @@ static int update_gmmu_pde_locked(struct vm_gk20a *vm,
2325 pte_addr_big = g->ops.mm.get_iova_addr(g, entry->sgt->sgl, 0); 2331 pte_addr_big = g->ops.mm.get_iova_addr(g, entry->sgt->sgl, 0);
2326 2332
2327 pde_v[0] = gmmu_pde_size_full_f(); 2333 pde_v[0] = gmmu_pde_size_full_f();
2328 pde_v[0] |= big_valid ? big_valid_pde0_bits(pte_addr_big) : 2334 pde_v[0] |= big_valid ? big_valid_pde0_bits(g, pte_addr_big) :
2329 (gmmu_pde_aperture_big_invalid_f()); 2335 (gmmu_pde_aperture_big_invalid_f());
2330 2336
2331 pde_v[1] |= (small_valid ? 2337 pde_v[1] |= (small_valid ?
2332 small_valid_pde1_bits(pte_addr_small) : 2338 small_valid_pde1_bits(g, pte_addr_small) :
2333 (gmmu_pde_aperture_small_invalid_f() | 2339 (gmmu_pde_aperture_small_invalid_f() |
2334 gmmu_pde_vol_small_false_f())) 2340 gmmu_pde_vol_small_false_f()))
2335 | 2341 |
@@ -2374,7 +2380,9 @@ static int update_gmmu_pte_locked(struct vm_gk20a *vm,
2374 if (priv) 2380 if (priv)
2375 pte_w[0] |= gmmu_pte_privilege_true_f(); 2381 pte_w[0] |= gmmu_pte_privilege_true_f();
2376 2382
2377 pte_w[1] = gmmu_pte_aperture_video_memory_f() | 2383 pte_w[1] = (g->mm.vidmem_is_vidmem ?
2384 gmmu_pte_aperture_sys_mem_ncoh_f() :
2385 gmmu_pte_aperture_video_memory_f()) |
2378 gmmu_pte_kind_f(kind_v) | 2386 gmmu_pte_kind_f(kind_v) |
2379 gmmu_pte_comptagline_f((u32)(*ctag >> ctag_shift)); 2387 gmmu_pte_comptagline_f((u32)(*ctag >> ctag_shift));
2380 2388
@@ -3482,7 +3490,9 @@ void gk20a_mm_init_pdb(struct gk20a *g, void *inst_ptr, u64 pdb_addr)
3482 u32 pdb_addr_hi = u64_hi32(pdb_addr); 3490 u32 pdb_addr_hi = u64_hi32(pdb_addr);
3483 3491
3484 gk20a_mem_wr32(inst_ptr, ram_in_page_dir_base_lo_w(), 3492 gk20a_mem_wr32(inst_ptr, ram_in_page_dir_base_lo_w(),
3485 ram_in_page_dir_base_target_vid_mem_f() | 3493 (g->mm.vidmem_is_vidmem ?
3494 ram_in_page_dir_base_target_sys_mem_ncoh_f() :
3495 ram_in_page_dir_base_target_vid_mem_f()) |
3486 ram_in_page_dir_base_vol_true_f() | 3496 ram_in_page_dir_base_vol_true_f() |
3487 ram_in_page_dir_base_lo_f(pdb_addr_lo)); 3497 ram_in_page_dir_base_lo_f(pdb_addr_lo));
3488 3498
@@ -3774,7 +3784,9 @@ void gk20a_mm_tlb_invalidate(struct vm_gk20a *vm)
3774 3784
3775 gk20a_writel(g, fb_mmu_invalidate_pdb_r(), 3785 gk20a_writel(g, fb_mmu_invalidate_pdb_r(),
3776 fb_mmu_invalidate_pdb_addr_f(addr_lo) | 3786 fb_mmu_invalidate_pdb_addr_f(addr_lo) |
3777 fb_mmu_invalidate_pdb_aperture_vid_mem_f()); 3787 (g->mm.vidmem_is_vidmem ?
3788 fb_mmu_invalidate_pdb_aperture_sys_mem_f() :
3789 fb_mmu_invalidate_pdb_aperture_vid_mem_f()));
3778 3790
3779 gk20a_writel(g, fb_mmu_invalidate_r(), 3791 gk20a_writel(g, fb_mmu_invalidate_r(),
3780 fb_mmu_invalidate_all_va_true_f() | 3792 fb_mmu_invalidate_all_va_true_f() |
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
index 567369bc..2d137bbe 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
@@ -357,6 +357,8 @@ struct mm_gk20a {
357 bool disable_bigpage; 357 bool disable_bigpage;
358#endif 358#endif
359 bool has_physical_mode; 359 bool has_physical_mode;
360 /* false if vidmem aperture actually points to sysmem */
361 bool vidmem_is_vidmem;
360}; 362};
361 363
362int gk20a_mm_init(struct mm_gk20a *mm); 364int gk20a_mm_init(struct mm_gk20a *mm);