diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2016-05-12 02:31:30 -0400 |
---|---|---|
committer | Deepak Nibade <dnibade@nvidia.com> | 2016-12-27 04:56:15 -0500 |
commit | 18a017865946617fd63256858a0d2300160643f4 (patch) | |
tree | 310822095e53bb0bb377f4955df7e2cc0f62fc7d /drivers/gpu/nvgpu/gp10b/gr_gp10b.c | |
parent | e746a16f7abbaacba89e390c692620941fc1b34c (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.
JIRA DNVGPU-23
Change-Id: I21d4a54827b0e2741012dfde7952c0555a583435
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1121914
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ken Adams <kadams@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp10b/gr_gp10b.c')
-rw-r--r-- | drivers/gpu/nvgpu/gp10b/gr_gp10b.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c index b36eff8f..07f1014f 100644 --- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c | |||
@@ -958,52 +958,51 @@ fail_free_gk20a_ctx: | |||
958 | } | 958 | } |
959 | 959 | ||
960 | static void dump_ctx_switch_stats(struct gk20a *g, struct vm_gk20a *vm, | 960 | static void dump_ctx_switch_stats(struct gk20a *g, struct vm_gk20a *vm, |
961 | struct gr_ctx_desc *gr_ctx) { | 961 | struct gr_ctx_desc *gr_ctx) |
962 | void *ctx_ptr = vmap(gr_ctx->mem.pages, | 962 | { |
963 | PAGE_ALIGN(gr_ctx->mem.size) >> PAGE_SHIFT, | 963 | struct mem_desc *mem = &gr_ctx->mem; |
964 | 0, pgprot_writecombine(PAGE_KERNEL)); | 964 | |
965 | if (!ctx_ptr) { | 965 | if (gk20a_mem_begin(g, mem)) { |
966 | WARN_ON("Cannot map context"); | 966 | WARN_ON("Cannot map context"); |
967 | return; | 967 | return; |
968 | } | 968 | } |
969 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_magic_value_o : %x (expect %x)\n", | 969 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_magic_value_o : %x (expect %x)\n", |
970 | gk20a_mem_rd32(ctx_ptr + | 970 | gk20a_mem_rd(g, mem, |
971 | ctxsw_prog_main_image_magic_value_o(), 0), | 971 | ctxsw_prog_main_image_magic_value_o()), |
972 | ctxsw_prog_main_image_magic_value_v_value_v()); | 972 | ctxsw_prog_main_image_magic_value_v_value_v()); |
973 | 973 | ||
974 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi : %x\n", | 974 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi : %x\n", |
975 | gk20a_mem_rd32(ctx_ptr + | 975 | gk20a_mem_rd(g, mem, |
976 | ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_o(), 0)); | 976 | ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_o())); |
977 | 977 | ||
978 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_ptr : %x\n", | 978 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_ptr : %x\n", |
979 | gk20a_mem_rd32(ctx_ptr + | 979 | gk20a_mem_rd(g, mem, |
980 | ctxsw_prog_main_image_context_timestamp_buffer_ptr_o(), 0)); | 980 | ctxsw_prog_main_image_context_timestamp_buffer_ptr_o())); |
981 | 981 | ||
982 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_control : %x\n", | 982 | gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_control : %x\n", |
983 | gk20a_mem_rd32(ctx_ptr + | 983 | gk20a_mem_rd(g, mem, |
984 | ctxsw_prog_main_image_context_timestamp_buffer_control_o(), 0)); | 984 | ctxsw_prog_main_image_context_timestamp_buffer_control_o())); |
985 | 985 | ||
986 | gk20a_err(dev_from_gk20a(g), "NUM_SAVE_OPERATIONS : %d\n", | 986 | gk20a_err(dev_from_gk20a(g), "NUM_SAVE_OPERATIONS : %d\n", |
987 | gk20a_mem_rd32(ctx_ptr + | 987 | gk20a_mem_rd(g, mem, |
988 | ctxsw_prog_main_image_num_save_ops_o(), 0)); | 988 | ctxsw_prog_main_image_num_save_ops_o())); |
989 | gk20a_err(dev_from_gk20a(g), "WFI_SAVE_OPERATIONS : %d\n", | 989 | gk20a_err(dev_from_gk20a(g), "WFI_SAVE_OPERATIONS : %d\n", |
990 | gk20a_mem_rd32(ctx_ptr + | 990 | gk20a_mem_rd(g, mem, |
991 | ctxsw_prog_main_image_num_wfi_save_ops_o(), 0)); | 991 | ctxsw_prog_main_image_num_wfi_save_ops_o())); |
992 | gk20a_err(dev_from_gk20a(g), "CTA_SAVE_OPERATIONS : %d\n", | 992 | gk20a_err(dev_from_gk20a(g), "CTA_SAVE_OPERATIONS : %d\n", |
993 | gk20a_mem_rd32(ctx_ptr + | 993 | gk20a_mem_rd(g, mem, |
994 | ctxsw_prog_main_image_num_cta_save_ops_o(), 0)); | 994 | ctxsw_prog_main_image_num_cta_save_ops_o())); |
995 | gk20a_err(dev_from_gk20a(g), "GFXP_SAVE_OPERATIONS : %d\n", | 995 | gk20a_err(dev_from_gk20a(g), "GFXP_SAVE_OPERATIONS : %d\n", |
996 | gk20a_mem_rd32(ctx_ptr + | 996 | gk20a_mem_rd(g, mem, |
997 | ctxsw_prog_main_image_num_gfxp_save_ops_o(), 0)); | 997 | ctxsw_prog_main_image_num_gfxp_save_ops_o())); |
998 | gk20a_err(dev_from_gk20a(g), "CILP_SAVE_OPERATIONS : %d\n", | 998 | gk20a_err(dev_from_gk20a(g), "CILP_SAVE_OPERATIONS : %d\n", |
999 | gk20a_mem_rd32(ctx_ptr + | 999 | gk20a_mem_rd(g, mem, |
1000 | ctxsw_prog_main_image_num_cilp_save_ops_o(), 0)); | 1000 | ctxsw_prog_main_image_num_cilp_save_ops_o())); |
1001 | gk20a_err(dev_from_gk20a(g), | 1001 | gk20a_err(dev_from_gk20a(g), |
1002 | "image gfx preemption option (GFXP is 1) %x\n", | 1002 | "image gfx preemption option (GFXP is 1) %x\n", |
1003 | gk20a_mem_rd32(ctx_ptr + | 1003 | gk20a_mem_rd(g, mem, |
1004 | ctxsw_prog_main_image_graphics_preemption_options_o(), | 1004 | ctxsw_prog_main_image_graphics_preemption_options_o())); |
1005 | 0)); | 1005 | gk20a_mem_end(g, mem); |
1006 | vunmap(ctx_ptr); | ||
1007 | } | 1006 | } |
1008 | 1007 | ||
1009 | static void gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, | 1008 | static void gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, |
@@ -1028,7 +1027,7 @@ static void gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, | |||
1028 | 1027 | ||
1029 | static void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g, | 1028 | static void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g, |
1030 | struct channel_ctx_gk20a *ch_ctx, | 1029 | struct channel_ctx_gk20a *ch_ctx, |
1031 | void *ctx_ptr) | 1030 | struct mem_desc *mem) |
1032 | { | 1031 | { |
1033 | struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx; | 1032 | struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx; |
1034 | u32 gfxp_preempt_option = | 1033 | u32 gfxp_preempt_option = |
@@ -1043,19 +1042,22 @@ static void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g, | |||
1043 | 1042 | ||
1044 | if (gr_ctx->graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) { | 1043 | if (gr_ctx->graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) { |
1045 | gk20a_dbg_info("GfxP: %x", gfxp_preempt_option); | 1044 | gk20a_dbg_info("GfxP: %x", gfxp_preempt_option); |
1046 | gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_graphics_preemption_options_o(), 0, | 1045 | gk20a_mem_wr(g, mem, |
1046 | ctxsw_prog_main_image_graphics_preemption_options_o(), | ||
1047 | gfxp_preempt_option); | 1047 | gfxp_preempt_option); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP) { | 1050 | if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP) { |
1051 | gk20a_dbg_info("CILP: %x", cilp_preempt_option); | 1051 | gk20a_dbg_info("CILP: %x", cilp_preempt_option); |
1052 | gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_compute_preemption_options_o(), 0, | 1052 | gk20a_mem_wr(g, mem, |
1053 | ctxsw_prog_main_image_compute_preemption_options_o(), | ||
1053 | cilp_preempt_option); | 1054 | cilp_preempt_option); |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CTA) { | 1057 | if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CTA) { |
1057 | gk20a_dbg_info("CTA: %x", cta_preempt_option); | 1058 | gk20a_dbg_info("CTA: %x", cta_preempt_option); |
1058 | gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_compute_preemption_options_o(), 0, | 1059 | gk20a_mem_wr(g, mem, |
1060 | ctxsw_prog_main_image_compute_preemption_options_o(), | ||
1059 | cta_preempt_option); | 1061 | cta_preempt_option); |
1060 | } | 1062 | } |
1061 | 1063 | ||
@@ -1064,7 +1066,8 @@ static void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g, | |||
1064 | u32 size; | 1066 | u32 size; |
1065 | u32 cbes_reserve; | 1067 | u32 cbes_reserve; |
1066 | 1068 | ||
1067 | gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_full_preemption_ptr_o(), 0, | 1069 | gk20a_mem_wr(g, mem, |
1070 | ctxsw_prog_main_image_full_preemption_ptr_o(), | ||
1068 | gr_ctx->t18x.preempt_ctxsw_buffer.gpu_va >> 8); | 1071 | gr_ctx->t18x.preempt_ctxsw_buffer.gpu_va >> 8); |
1069 | 1072 | ||
1070 | err = gr_gk20a_ctx_patch_write_begin(g, ch_ctx); | 1073 | err = gr_gk20a_ctx_patch_write_begin(g, ch_ctx); |
@@ -1931,7 +1934,7 @@ static int gr_gp10b_set_preemption_mode(struct channel_gk20a *ch, | |||
1931 | struct gk20a *g = ch->g; | 1934 | struct gk20a *g = ch->g; |
1932 | struct tsg_gk20a *tsg; | 1935 | struct tsg_gk20a *tsg; |
1933 | struct vm_gk20a *vm; | 1936 | struct vm_gk20a *vm; |
1934 | void *ctx_ptr; | 1937 | struct mem_desc *mem = &gr_ctx->mem; |
1935 | u32 class; | 1938 | u32 class; |
1936 | int err = 0; | 1939 | int err = 0; |
1937 | 1940 | ||
@@ -1955,10 +1958,7 @@ static int gr_gp10b_set_preemption_mode(struct channel_gk20a *ch, | |||
1955 | if (err) | 1958 | if (err) |
1956 | return err; | 1959 | return err; |
1957 | 1960 | ||
1958 | ctx_ptr = vmap(gr_ctx->mem.pages, | 1961 | if (gk20a_mem_begin(g, mem)) |
1959 | PAGE_ALIGN(ch_ctx->gr_ctx->mem.size) >> PAGE_SHIFT, | ||
1960 | 0, pgprot_writecombine(PAGE_KERNEL)); | ||
1961 | if (!ctx_ptr) | ||
1962 | return -ENOMEM; | 1962 | return -ENOMEM; |
1963 | 1963 | ||
1964 | g->ops.fifo.disable_channel(ch); | 1964 | g->ops.fifo.disable_channel(ch); |
@@ -1967,14 +1967,14 @@ static int gr_gp10b_set_preemption_mode(struct channel_gk20a *ch, | |||
1967 | goto unmap_ctx; | 1967 | goto unmap_ctx; |
1968 | 1968 | ||
1969 | if (g->ops.gr.update_ctxsw_preemption_mode) { | 1969 | if (g->ops.gr.update_ctxsw_preemption_mode) { |
1970 | g->ops.gr.update_ctxsw_preemption_mode(ch->g, ch_ctx, ctx_ptr); | 1970 | g->ops.gr.update_ctxsw_preemption_mode(ch->g, ch_ctx, mem); |
1971 | g->ops.gr.commit_global_cb_manager(g, ch, true); | 1971 | g->ops.gr.commit_global_cb_manager(g, ch, true); |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | g->ops.fifo.enable_channel(ch); | 1974 | g->ops.fifo.enable_channel(ch); |
1975 | 1975 | ||
1976 | unmap_ctx: | 1976 | unmap_ctx: |
1977 | vunmap(ctx_ptr); | 1977 | gk20a_mem_end(g, mem); |
1978 | 1978 | ||
1979 | return err; | 1979 | return err; |
1980 | } | 1980 | } |