summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2016-05-12 02:32:05 -0400
committerKen Adams <kadams@nvidia.com>2016-05-13 10:11:33 -0400
commit6eebc87d99f9f04b2b68e0bc0142c161ab3e669d (patch)
tree08e437890869d76072f291ea66f709f05ea07c8a /drivers/gpu/nvgpu/gm20b/gr_gm20b.c
parent14ef0dacc94077bc3dae4c942ff8c279cc4c92ba (diff)
gpu: nvgpu: refactor gk20a_mem_{wr,rd} for vidmem
To support vidmem, pass g and mem_desc to the buffer memory accessor functions. This allows the functions to select the memory access method based on the buffer aperture instead of using the cpu pointer directly (like until now). The selection and aperture support will be in another patch; this patch only refactors these accessors, but keeps the underlying functionality as-is. gk20a_mem_{rd,wr}32() work as previously; add also gk20a_mem_{rd,wr}() for byte-indexed accesses, gk20a_mem_{rd,wr}_n() for memcpy()-like functionality, and gk20a_memset() for filling buffers with a constant. The 8 and 16 bit accessor functions are removed. vmap()/vunmap() pairs are abstracted to gk20a_mem_{begin,end}() to support other types of mappings or conditions where mapping the buffer is unnecessary or different. Several function arguments that would access these buffers are also changed to take a mem_desc instead of a plain cpu pointer. Some relevant occasions are changed to use the accessor functions instead of cpu pointers without them (e.g., memcpying to and from), but the majority of direct accesses will be adjusted later, when the buffers are moved to support vidmem. JIRA DNVGPU-23 Change-Id: I3dd22e14290c4ab742d42e2dd327ebeb5cd3f25a Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/1121143 Reviewed-by: Ken Adams <kadams@nvidia.com> Tested-by: Ken Adams <kadams@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gm20b/gr_gm20b.c')
-rw-r--r--drivers/gpu/nvgpu/gm20b/gr_gm20b.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/gm20b/gr_gm20b.c b/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
index b9a1e685..2197bae5 100644
--- a/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
@@ -849,7 +849,7 @@ static int gr_gm20b_alloc_gr_ctx(struct gk20a *g,
849 849
850static void gr_gm20b_update_ctxsw_preemption_mode(struct gk20a *g, 850static void gr_gm20b_update_ctxsw_preemption_mode(struct gk20a *g,
851 struct channel_ctx_gk20a *ch_ctx, 851 struct channel_ctx_gk20a *ch_ctx,
852 void *ctx_ptr) 852 struct mem_desc *mem)
853{ 853{
854 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx; 854 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx;
855 u32 cta_preempt_option = 855 u32 cta_preempt_option =
@@ -859,7 +859,8 @@ static void gr_gm20b_update_ctxsw_preemption_mode(struct gk20a *g,
859 859
860 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CTA) { 860 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CTA) {
861 gk20a_dbg_info("CTA: %x", cta_preempt_option); 861 gk20a_dbg_info("CTA: %x", cta_preempt_option);
862 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_preemption_options_o(), 0, 862 gk20a_mem_wr(g, mem,
863 ctxsw_prog_main_image_preemption_options_o(),
863 cta_preempt_option); 864 cta_preempt_option);
864 } 865 }
865 866
@@ -1005,7 +1006,7 @@ static int gr_gm20b_update_pc_sampling(struct channel_gk20a *c,
1005 bool enable) 1006 bool enable)
1006{ 1007{
1007 struct channel_ctx_gk20a *ch_ctx = &c->ch_ctx; 1008 struct channel_ctx_gk20a *ch_ctx = &c->ch_ctx;
1008 void *ctx_ptr = NULL; 1009 struct mem_desc *mem;
1009 u32 v; 1010 u32 v;
1010 1011
1011 gk20a_dbg_fn(""); 1012 gk20a_dbg_fn("");
@@ -1013,18 +1014,17 @@ static int gr_gm20b_update_pc_sampling(struct channel_gk20a *c,
1013 if (!ch_ctx || !ch_ctx->gr_ctx || c->vpr) 1014 if (!ch_ctx || !ch_ctx->gr_ctx || c->vpr)
1014 return -EINVAL; 1015 return -EINVAL;
1015 1016
1016 ctx_ptr = vmap(ch_ctx->gr_ctx->mem.pages, 1017 mem = &ch_ctx->gr_ctx->mem;
1017 PAGE_ALIGN(ch_ctx->gr_ctx->mem.size) >> PAGE_SHIFT, 1018
1018 0, pgprot_writecombine(PAGE_KERNEL)); 1019 if (gk20a_mem_begin(c->g, mem))
1019 if (!ctx_ptr)
1020 return -ENOMEM; 1020 return -ENOMEM;
1021 1021
1022 v = gk20a_mem_rd32(ctx_ptr + ctxsw_prog_main_image_pm_o(), 0); 1022 v = gk20a_mem_rd(c->g, mem, ctxsw_prog_main_image_pm_o());
1023 v &= ~ctxsw_prog_main_image_pm_pc_sampling_m(); 1023 v &= ~ctxsw_prog_main_image_pm_pc_sampling_m();
1024 v |= ctxsw_prog_main_image_pm_pc_sampling_f(enable); 1024 v |= ctxsw_prog_main_image_pm_pc_sampling_f(enable);
1025 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_pm_o(), 0, v); 1025 gk20a_mem_wr(c->g, mem, ctxsw_prog_main_image_pm_o(), v);
1026 1026
1027 vunmap(ctx_ptr); 1027 gk20a_mem_end(c->g, mem);
1028 1028
1029 gk20a_dbg_fn("done"); 1029 gk20a_dbg_fn("done");
1030 1030
@@ -1089,13 +1089,13 @@ static void gr_gm20b_init_cyclestats(struct gk20a *g)
1089#endif 1089#endif
1090} 1090}
1091 1091
1092static void gr_gm20b_enable_cde_in_fecs(void *ctx_ptr) 1092static void gr_gm20b_enable_cde_in_fecs(struct gk20a *g, struct mem_desc *mem)
1093{ 1093{
1094 u32 cde_v; 1094 u32 cde_v;
1095 1095
1096 cde_v = gk20a_mem_rd32(ctx_ptr + ctxsw_prog_main_image_ctl_o(), 0); 1096 cde_v = gk20a_mem_rd(g, mem, ctxsw_prog_main_image_ctl_o());
1097 cde_v |= ctxsw_prog_main_image_ctl_cde_enabled_f(); 1097 cde_v |= ctxsw_prog_main_image_ctl_cde_enabled_f();
1098 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_ctl_o(), 0, cde_v); 1098 gk20a_mem_wr(g, mem, ctxsw_prog_main_image_ctl_o(), cde_v);
1099} 1099}
1100 1100
1101static void gr_gm20b_bpt_reg_info(struct gk20a *g, struct warpstate *w_state) 1101static void gr_gm20b_bpt_reg_info(struct gk20a *g, struct warpstate *w_state)