summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2015-01-14 07:02:23 -0500
committerDan Willemsen <dwillemsen@nvidia.com>2015-04-04 21:04:35 -0400
commit2dda8077ec7d88ac689b57448031a3bac269fdfa (patch)
tree9513c040114e286ddb0fed68a667d13eaf3a4491 /drivers/gpu/nvgpu/gk20a/mm_gk20a.c
parentd29be09f6f4fa9aa4a41ecbb45eaa906b43319e9 (diff)
gpu: nvgpu: unify instance block initialization
Create gk20a_init_inst_block() to reduce reg write clutter when initializing instance blocks, which is done in several places. Change-Id: Idcb8b604851a849e0bb6abce5743c9f4cbf98033 Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/672434 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c81
1 files changed, 23 insertions, 58 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 71b14d5b..8cd8e18c 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -2716,13 +2716,8 @@ void gk20a_free_inst_block(struct gk20a *g, struct inst_desc *inst_block)
2716static int gk20a_init_bar1_vm(struct mm_gk20a *mm) 2716static int gk20a_init_bar1_vm(struct mm_gk20a *mm)
2717{ 2717{
2718 int err; 2718 int err;
2719 phys_addr_t inst_pa;
2720 void *inst_ptr;
2721 struct vm_gk20a *vm = &mm->bar1.vm; 2719 struct vm_gk20a *vm = &mm->bar1.vm;
2722 struct gk20a *g = gk20a_from_mm(mm); 2720 struct gk20a *g = gk20a_from_mm(mm);
2723 u64 pde_addr;
2724 u32 pde_addr_lo;
2725 u32 pde_addr_hi;
2726 struct inst_desc *inst_block = &mm->bar1.inst_block; 2721 struct inst_desc *inst_block = &mm->bar1.inst_block;
2727 u32 big_page_size = gk20a_get_platform(g->dev)->default_big_page_size; 2722 u32 big_page_size = gk20a_get_platform(g->dev)->default_big_page_size;
2728 2723
@@ -2731,41 +2726,11 @@ static int gk20a_init_bar1_vm(struct mm_gk20a *mm)
2731 gk20a_init_vm(mm, vm, big_page_size, SZ_4K, 2726 gk20a_init_vm(mm, vm, big_page_size, SZ_4K,
2732 mm->bar1.aperture_size, false, "bar1"); 2727 mm->bar1.aperture_size, false, "bar1");
2733 2728
2734 gk20a_dbg_info("pde pa=0x%llx",
2735 (u64)gk20a_mm_iova_addr(g, vm->pdes.sgt->sgl));
2736
2737 pde_addr = gk20a_mm_iova_addr(g, vm->pdes.sgt->sgl);
2738 pde_addr_lo = u64_lo32(pde_addr >> ram_in_base_shift_v());
2739 pde_addr_hi = u64_hi32(pde_addr);
2740
2741 err = gk20a_alloc_inst_block(g, inst_block); 2729 err = gk20a_alloc_inst_block(g, inst_block);
2742 if (err) 2730 if (err)
2743 goto clean_up_va; 2731 goto clean_up_va;
2732 gk20a_init_inst_block(inst_block, vm, big_page_size);
2744 2733
2745 inst_pa = inst_block->cpu_pa;
2746 inst_ptr = inst_block->cpuva;
2747
2748 gk20a_dbg_info("bar1 inst block physical phys = 0x%llx, kv = 0x%p",
2749 (u64)inst_pa, inst_ptr);
2750
2751 gk20a_mem_wr32(inst_ptr, ram_in_page_dir_base_lo_w(),
2752 ram_in_page_dir_base_target_vid_mem_f() |
2753 ram_in_page_dir_base_vol_true_f() |
2754 ram_in_page_dir_base_lo_f(pde_addr_lo));
2755
2756 gk20a_mem_wr32(inst_ptr, ram_in_page_dir_base_hi_w(),
2757 ram_in_page_dir_base_hi_f(pde_addr_hi));
2758
2759 gk20a_mem_wr32(inst_ptr, ram_in_adr_limit_lo_w(),
2760 u64_lo32(vm->va_limit) | 0xFFF);
2761
2762 gk20a_mem_wr32(inst_ptr, ram_in_adr_limit_hi_w(),
2763 ram_in_adr_limit_hi_f(u64_hi32(vm->va_limit)));
2764
2765 if (g->ops.mm.set_big_page_size)
2766 g->ops.mm.set_big_page_size(g, inst_ptr, big_page_size);
2767
2768 gk20a_dbg_info("bar1 inst block ptr: %08llx", (u64)inst_pa);
2769 return 0; 2734 return 0;
2770 2735
2771clean_up_va: 2736clean_up_va:
@@ -2777,13 +2742,8 @@ clean_up_va:
2777static int gk20a_init_system_vm(struct mm_gk20a *mm) 2742static int gk20a_init_system_vm(struct mm_gk20a *mm)
2778{ 2743{
2779 int err; 2744 int err;
2780 phys_addr_t inst_pa;
2781 void *inst_ptr;
2782 struct vm_gk20a *vm = &mm->pmu.vm; 2745 struct vm_gk20a *vm = &mm->pmu.vm;
2783 struct gk20a *g = gk20a_from_mm(mm); 2746 struct gk20a *g = gk20a_from_mm(mm);
2784 u64 pde_addr;
2785 u32 pde_addr_lo;
2786 u32 pde_addr_hi;
2787 struct inst_desc *inst_block = &mm->pmu.inst_block; 2747 struct inst_desc *inst_block = &mm->pmu.inst_block;
2788 u32 big_page_size = gk20a_get_platform(g->dev)->default_big_page_size; 2748 u32 big_page_size = gk20a_get_platform(g->dev)->default_big_page_size;
2789 2749
@@ -2793,21 +2753,32 @@ static int gk20a_init_system_vm(struct mm_gk20a *mm)
2793 gk20a_init_vm(mm, vm, big_page_size, 2753 gk20a_init_vm(mm, vm, big_page_size,
2794 SZ_128K << 10, GK20A_PMU_VA_SIZE, false, "system"); 2754 SZ_128K << 10, GK20A_PMU_VA_SIZE, false, "system");
2795 2755
2796 gk20a_dbg_info("pde pa=0x%llx",
2797 (u64)gk20a_mm_iova_addr(g, vm->pdes.sgt->sgl));
2798
2799 pde_addr = gk20a_mm_iova_addr(g, vm->pdes.sgt->sgl);
2800 pde_addr_lo = u64_lo32(pde_addr >> ram_in_base_shift_v());
2801 pde_addr_hi = u64_hi32(pde_addr);
2802
2803 err = gk20a_alloc_inst_block(g, inst_block); 2756 err = gk20a_alloc_inst_block(g, inst_block);
2804 if (err) 2757 if (err)
2805 goto clean_up_va; 2758 goto clean_up_va;
2759 gk20a_init_inst_block(inst_block, vm, big_page_size);
2760
2761 return 0;
2762
2763clean_up_va:
2764 gk20a_deinit_vm(vm);
2765 return err;
2766}
2767
2768void gk20a_init_inst_block(struct inst_desc *inst_block, struct vm_gk20a *vm,
2769 u32 big_page_size)
2770{
2771 struct gk20a *g = gk20a_from_vm(vm);
2772 u64 pde_addr = gk20a_mm_iova_addr(g, vm->pdes.sgt->sgl);
2773 u32 pde_addr_lo = u64_lo32(pde_addr >> ram_in_base_shift_v());
2774 u32 pde_addr_hi = u64_hi32(pde_addr);
2775 phys_addr_t inst_pa = inst_block->cpu_pa;
2776 void *inst_ptr = inst_block->cpuva;
2806 2777
2807 inst_pa = inst_block->cpu_pa; 2778 gk20a_dbg_info("inst block phys = 0x%llx, kv = 0x%p",
2808 inst_ptr = inst_block->cpuva; 2779 (u64)inst_pa, inst_ptr);
2809 2780
2810 gk20a_dbg_info("pmu inst block physical addr: 0x%llx", (u64)inst_pa); 2781 gk20a_dbg_info("pde pa=0x%llx", (u64)pde_addr);
2811 2782
2812 gk20a_mem_wr32(inst_ptr, ram_in_page_dir_base_lo_w(), 2783 gk20a_mem_wr32(inst_ptr, ram_in_page_dir_base_lo_w(),
2813 ram_in_page_dir_base_target_vid_mem_f() | 2784 ram_in_page_dir_base_target_vid_mem_f() |
@@ -2823,14 +2794,8 @@ static int gk20a_init_system_vm(struct mm_gk20a *mm)
2823 gk20a_mem_wr32(inst_ptr, ram_in_adr_limit_hi_w(), 2794 gk20a_mem_wr32(inst_ptr, ram_in_adr_limit_hi_w(),
2824 ram_in_adr_limit_hi_f(u64_hi32(vm->va_limit))); 2795 ram_in_adr_limit_hi_f(u64_hi32(vm->va_limit)));
2825 2796
2826 if (g->ops.mm.set_big_page_size) 2797 if (big_page_size && g->ops.mm.set_big_page_size)
2827 g->ops.mm.set_big_page_size(g, inst_ptr, big_page_size); 2798 g->ops.mm.set_big_page_size(g, inst_ptr, big_page_size);
2828
2829 return 0;
2830
2831clean_up_va:
2832 gk20a_deinit_vm(vm);
2833 return err;
2834} 2799}
2835 2800
2836int gk20a_mm_fb_flush(struct gk20a *g) 2801int gk20a_mm_fb_flush(struct gk20a *g)