summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.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/gk20a/fecs_trace_gk20a.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/gk20a/fecs_trace_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c
index f9cddc41..edddcdc1 100644
--- a/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fecs_trace_gk20a.c
@@ -619,7 +619,7 @@ static int gk20a_fecs_trace_bind_channel(struct gk20a *g,
619 phys_addr_t pa; 619 phys_addr_t pa;
620 struct channel_ctx_gk20a *ch_ctx = &ch->ch_ctx; 620 struct channel_ctx_gk20a *ch_ctx = &ch->ch_ctx;
621 struct gk20a_fecs_trace *trace = g->fecs_trace; 621 struct gk20a_fecs_trace *trace = g->fecs_trace;
622 void *ctx_ptr; 622 struct mem_desc *mem = &ch_ctx->gr_ctx->mem;
623 u32 context_ptr = gk20a_fecs_trace_fecs_context_ptr(ch); 623 u32 context_ptr = gk20a_fecs_trace_fecs_context_ptr(ch);
624 624
625 gk20a_dbg(gpu_dbg_fn|gpu_dbg_ctxsw, 625 gk20a_dbg(gpu_dbg_fn|gpu_dbg_ctxsw,
@@ -634,10 +634,7 @@ static int gk20a_fecs_trace_bind_channel(struct gk20a *g,
634 if (!pa) 634 if (!pa)
635 return -ENOMEM; 635 return -ENOMEM;
636 636
637 ctx_ptr = vmap(ch_ctx->gr_ctx->mem.pages, 637 if (gk20a_mem_begin(g, mem))
638 PAGE_ALIGN(ch_ctx->gr_ctx->mem.size) >> PAGE_SHIFT, 0,
639 pgprot_writecombine(PAGE_KERNEL));
640 if (!ctx_ptr)
641 return -ENOMEM; 638 return -ENOMEM;
642 639
643 lo = u64_lo32(pa); 640 lo = u64_lo32(pa);
@@ -646,18 +643,18 @@ static int gk20a_fecs_trace_bind_channel(struct gk20a *g,
646 gk20a_dbg(gpu_dbg_ctxsw, "addr_hi=%x addr_lo=%x count=%d", hi, 643 gk20a_dbg(gpu_dbg_ctxsw, "addr_hi=%x addr_lo=%x count=%d", hi,
647 lo, GK20A_FECS_TRACE_NUM_RECORDS); 644 lo, GK20A_FECS_TRACE_NUM_RECORDS);
648 645
649 gk20a_mem_wr32(ctx_ptr 646 gk20a_mem_wr(g, mem,
650 + ctxsw_prog_main_image_context_timestamp_buffer_ptr_o(), 647 ctxsw_prog_main_image_context_timestamp_buffer_ptr_o(),
651 0, lo); 648 lo);
652 gk20a_mem_wr32(ctx_ptr 649 gk20a_mem_wr(g, mem,
653 + ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_o(), 650 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_o(),
654 0, ctxsw_prog_main_image_context_timestamp_buffer_ptr_v_f(hi)); 651 ctxsw_prog_main_image_context_timestamp_buffer_ptr_v_f(hi));
655 gk20a_mem_wr32(ctx_ptr 652 gk20a_mem_wr(g, mem,
656 + ctxsw_prog_main_image_context_timestamp_buffer_control_o(), 653 ctxsw_prog_main_image_context_timestamp_buffer_control_o(),
657 0, ctxsw_prog_main_image_context_timestamp_buffer_control_num_records_f( 654 ctxsw_prog_main_image_context_timestamp_buffer_control_num_records_f(
658 GK20A_FECS_TRACE_NUM_RECORDS)); 655 GK20A_FECS_TRACE_NUM_RECORDS));
659 656
660 vunmap(ctx_ptr); 657 gk20a_mem_end(g, mem);
661 gk20a_fecs_trace_hash_add(g, context_ptr, ch->pid); 658 gk20a_fecs_trace_hash_add(g, context_ptr, ch->pid);
662 659
663 return 0; 660 return 0;