summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
diff options
context:
space:
mode:
authorseshendra Gadagottu <sgadagottu@nvidia.com>2016-07-27 20:06:36 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-10-11 12:16:03 -0400
commitfda4ddfa79f3a78becfe44fd558974bd274c03a9 (patch)
tree55d7999d7af7040ed50121fa6fa70fddc11b0887 /drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
parentbb5fd16c67287e53db5165a974ea15ec3be09fe9 (diff)
gpu: nvgpu: userd allocation from sysmem
When bar1 memory is not supported then userd will be allocated from sysmem. Functions gp_get and gp_put are updated accordingly. JIRA GV11B-1 Change-Id: Ia895712a110f6cca26474228141488f5f8ace756 Signed-off-by: seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-on: http://git-master/r/1225384 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/fifo_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
index 835ef062..1dce435c 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
@@ -491,7 +491,10 @@ static void gk20a_remove_fifo_support(struct fifo_gk20a *f)
491 491
492 vfree(f->channel); 492 vfree(f->channel);
493 vfree(f->tsg); 493 vfree(f->tsg);
494 gk20a_gmmu_unmap_free(&g->mm.bar1.vm, &f->userd); 494 if (g->ops.mm.is_bar1_supported(g))
495 gk20a_gmmu_unmap_free(&g->mm.bar1.vm, &f->userd);
496 else
497 gk20a_gmmu_free(g, &f->userd);
495 498
496 gk20a_fifo_delete_runlist(f); 499 gk20a_fifo_delete_runlist(f);
497 500
@@ -797,16 +800,6 @@ static int gk20a_init_fifo_setup_sw(struct gk20a *g)
797 800
798 f->userd_entry_size = 1 << ram_userd_base_shift_v(); 801 f->userd_entry_size = 1 << ram_userd_base_shift_v();
799 802
800 err = gk20a_gmmu_alloc_map_sys(&g->mm.bar1.vm,
801 f->userd_entry_size * f->num_channels,
802 &f->userd);
803 if (err) {
804 dev_err(d, "memory allocation failed\n");
805 goto clean_up;
806 }
807
808 gk20a_dbg(gpu_dbg_map_v, "userd bar1 va = 0x%llx", f->userd.gpu_va);
809
810 f->channel = vzalloc(f->num_channels * sizeof(*f->channel)); 803 f->channel = vzalloc(f->num_channels * sizeof(*f->channel));
811 f->tsg = vzalloc(f->num_channels * sizeof(*f->tsg)); 804 f->tsg = vzalloc(f->num_channels * sizeof(*f->tsg));
812 f->pbdma_map = kzalloc(f->num_pbdma * sizeof(*f->pbdma_map), 805 f->pbdma_map = kzalloc(f->num_pbdma * sizeof(*f->pbdma_map),
@@ -834,13 +827,26 @@ static int gk20a_init_fifo_setup_sw(struct gk20a *g)
834 INIT_LIST_HEAD(&f->free_chs); 827 INIT_LIST_HEAD(&f->free_chs);
835 mutex_init(&f->free_chs_mutex); 828 mutex_init(&f->free_chs_mutex);
836 829
830 if (g->ops.mm.is_bar1_supported(g))
831 err = gk20a_gmmu_alloc_map_sys(&g->mm.bar1.vm,
832 f->userd_entry_size * f->num_channels,
833 &f->userd);
834
835 else
836 err = gk20a_gmmu_alloc_sys(g, f->userd_entry_size *
837 f->num_channels, &f->userd);
838 if (err) {
839 dev_err(d, "userd memory allocation failed\n");
840 goto clean_up;
841 }
842 gk20a_dbg(gpu_dbg_map, "userd gpu va = 0x%llx", f->userd.gpu_va);
843
837 for (chid = 0; chid < f->num_channels; chid++) { 844 for (chid = 0; chid < f->num_channels; chid++) {
838 f->channel[chid].userd_iova = 845 f->channel[chid].userd_iova =
839 g->ops.mm.get_iova_addr(g, f->userd.sgt->sgl, 0) 846 g->ops.mm.get_iova_addr(g, f->userd.sgt->sgl, 0)
840 + chid * f->userd_entry_size; 847 + chid * f->userd_entry_size;
841 f->channel[chid].userd_gpu_va = 848 f->channel[chid].userd_gpu_va =
842 f->userd.gpu_va + chid * f->userd_entry_size; 849 f->userd.gpu_va + chid * f->userd_entry_size;
843
844 gk20a_init_channel_support(g, chid); 850 gk20a_init_channel_support(g, chid);
845 gk20a_init_tsg_support(g, chid); 851 gk20a_init_tsg_support(g, chid);
846 } 852 }
@@ -858,7 +864,10 @@ static int gk20a_init_fifo_setup_sw(struct gk20a *g)
858 864
859clean_up: 865clean_up:
860 gk20a_dbg_fn("fail"); 866 gk20a_dbg_fn("fail");
861 gk20a_gmmu_unmap_free(&g->mm.bar1.vm, &f->userd); 867 if (g->ops.mm.is_bar1_supported(g))
868 gk20a_gmmu_unmap_free(&g->mm.bar1.vm, &f->userd);
869 else
870 gk20a_gmmu_free(g, &f->userd);
862 871
863 vfree(f->channel); 872 vfree(f->channel);
864 f->channel = NULL; 873 f->channel = NULL;
@@ -884,7 +893,7 @@ static void gk20a_fifo_handle_runlist_event(struct gk20a *g)
884 gk20a_writel(g, fifo_intr_runlist_r(), runlist_event); 893 gk20a_writel(g, fifo_intr_runlist_r(), runlist_event);
885} 894}
886 895
887static int gk20a_init_fifo_setup_hw(struct gk20a *g) 896int gk20a_init_fifo_setup_hw(struct gk20a *g)
888{ 897{
889 struct fifo_gk20a *f = &g->fifo; 898 struct fifo_gk20a *f = &g->fifo;
890 899
@@ -952,7 +961,8 @@ int gk20a_init_fifo_support(struct gk20a *g)
952 if (err) 961 if (err)
953 return err; 962 return err;
954 963
955 err = gk20a_init_fifo_setup_hw(g); 964 if (g->ops.fifo.init_fifo_setup_hw)
965 err = g->ops.fifo.init_fifo_setup_hw(g);
956 if (err) 966 if (err)
957 return err; 967 return err;
958 968
@@ -3015,7 +3025,8 @@ int gk20a_fifo_suspend(struct gk20a *g)
3015 gk20a_dbg_fn(""); 3025 gk20a_dbg_fn("");
3016 3026
3017 /* stop bar1 snooping */ 3027 /* stop bar1 snooping */
3018 gk20a_writel(g, fifo_bar1_base_r(), 3028 if (g->ops.mm.is_bar1_supported(g))
3029 gk20a_writel(g, fifo_bar1_base_r(),
3019 fifo_bar1_base_valid_false_f()); 3030 fifo_bar1_base_valid_false_f());
3020 3031
3021 /* disable fifo intr */ 3032 /* disable fifo intr */
@@ -3246,6 +3257,7 @@ void gk20a_fifo_debugfs_init(struct device *dev)
3246void gk20a_init_fifo(struct gpu_ops *gops) 3257void gk20a_init_fifo(struct gpu_ops *gops)
3247{ 3258{
3248 gk20a_init_channel(gops); 3259 gk20a_init_channel(gops);
3260 gops->fifo.init_fifo_setup_hw = gk20a_init_fifo_setup_hw;
3249 gops->fifo.preempt_channel = gk20a_fifo_preempt_channel; 3261 gops->fifo.preempt_channel = gk20a_fifo_preempt_channel;
3250 gops->fifo.preempt_tsg = gk20a_fifo_preempt_tsg; 3262 gops->fifo.preempt_tsg = gk20a_fifo_preempt_tsg;
3251 gops->fifo.update_runlist = gk20a_fifo_update_runlist; 3263 gops->fifo.update_runlist = gk20a_fifo_update_runlist;