summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gv11b/mm_gv11b.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2018-05-25 13:27:10 -0400
committerTejal Kudav <tkudav@nvidia.com>2018-06-14 09:44:07 -0400
commit27694ca572c4d7698b107c6713f0f0604b41c186 (patch)
tree60dc8a1a8518797fd95f82d1e02892a984911667 /drivers/gpu/nvgpu/gv11b/mm_gv11b.c
parent5c8f1619ce5ab1cf46484c8914fa29bcc208b9a0 (diff)
gpu: nvgpu: Implement bus HAL for bar2 bind
Implement BAR2 bind as a bus HAL and remove the corresponding MM HAL. BAR2 bind HW API is in bus. JIRA NVGPU-588 Change-Id: I3a8391b00f1ba65f9ed28b633f1d52bf7c984230 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1730896 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gv11b/mm_gv11b.c')
-rw-r--r--drivers/gpu/nvgpu/gv11b/mm_gv11b.c54
1 files changed, 1 insertions, 53 deletions
diff --git a/drivers/gpu/nvgpu/gv11b/mm_gv11b.c b/drivers/gpu/nvgpu/gv11b/mm_gv11b.c
index 357b15d7..6c38365c 100644
--- a/drivers/gpu/nvgpu/gv11b/mm_gv11b.c
+++ b/drivers/gpu/nvgpu/gv11b/mm_gv11b.c
@@ -40,7 +40,6 @@
40 40
41#include <nvgpu/hw/gv11b/hw_fb_gv11b.h> 41#include <nvgpu/hw/gv11b/hw_fb_gv11b.h>
42#include <nvgpu/hw/gv11b/hw_gmmu_gv11b.h> 42#include <nvgpu/hw/gv11b/hw_gmmu_gv11b.h>
43#include <nvgpu/hw/gv11b/hw_bus_gv11b.h>
44 43
45#define NVGPU_L3_ALLOC_BIT BIT(36) 44#define NVGPU_L3_ALLOC_BIT BIT(36)
46 45
@@ -236,7 +235,7 @@ int gv11b_init_mm_setup_hw(struct gk20a *g)
236 g->ops.fb.set_mmu_page_size(g); 235 g->ops.fb.set_mmu_page_size(g);
237 g->ops.fb.init_hw(g); 236 g->ops.fb.init_hw(g);
238 237
239 err = g->ops.mm.init_bar2_mm_hw_setup(g); 238 err = g->ops.bus.bar2_bind(g, &g->mm.bar2.inst_block);
240 if (err) 239 if (err)
241 return err; 240 return err;
242 241
@@ -274,54 +273,3 @@ u64 gv11b_gpu_phys_addr(struct gk20a *g,
274 273
275 return phys; 274 return phys;
276} 275}
277
278int gv11b_init_bar2_mm_hw_setup(struct gk20a *g)
279{
280 struct mm_gk20a *mm = &g->mm;
281 struct nvgpu_mem *inst_block = &mm->bar2.inst_block;
282 u64 inst_pa = nvgpu_inst_block_addr(g, inst_block);
283 u32 reg_val;
284 struct nvgpu_timeout timeout;
285 u32 delay = GR_IDLE_CHECK_DEFAULT;
286
287 nvgpu_log_fn(g, " ");
288
289 g->ops.fb.set_mmu_page_size(g);
290
291 inst_pa = (u32)(inst_pa >> bus_bar2_block_ptr_shift_v());
292 nvgpu_log_info(g, "bar2 inst block ptr: 0x%08x", (u32)inst_pa);
293
294 gk20a_writel(g, bus_bar2_block_r(),
295 nvgpu_aperture_mask(g, inst_block,
296 bus_bar2_block_target_sys_mem_ncoh_f(),
297 bus_bar2_block_target_sys_mem_coh_f(),
298 bus_bar2_block_target_vid_mem_f()) |
299 bus_bar2_block_mode_virtual_f() |
300 bus_bar2_block_ptr_f(inst_pa));
301
302 /* This is needed as BAR1 support is removed and there is no way
303 * to know if gpu successfully accessed memory.
304 * To avoid deadlocks and non-deterministic virtual address translation
305 * behavior, after writing BAR2_BLOCK to bind BAR2 to a virtual address
306 * space, SW must ensure that the bind has completed prior to issuing
307 * any further BAR2 requests by polling for both
308 * BUS_BIND_STATUS_BAR2_PENDING to return to EMPTY and
309 * BUS_BIND_STATUS_BAR2_OUTSTANDING to return to FALSE
310 */
311 nvgpu_timeout_init(g, &timeout, gk20a_get_gr_idle_timeout(g),
312 NVGPU_TIMER_CPU_TIMER);
313 nvgpu_log_info(g, "check bar2 bind status");
314 do {
315 reg_val = gk20a_readl(g, bus_bind_status_r());
316
317 if (!((reg_val & bus_bind_status_bar2_pending_busy_f()) ||
318 (reg_val & bus_bind_status_bar2_outstanding_true_f())))
319 return 0;
320
321 nvgpu_usleep_range(delay, delay * 2);
322 delay = min_t(u32, delay << 1, GR_IDLE_CHECK_MAX);
323 } while (!nvgpu_timeout_expired_msg(&timeout, "bar2 bind timedout"));
324
325 nvgpu_err(g, "bar2 bind failed. gpu unable to access memory");
326 return -EBUSY;
327}