summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2017-11-10 08:02:37 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-11-14 07:58:39 -0500
commit90aeab9dee07a63e4bac6d92646dfd80e65d2edd (patch)
treea175a1724590dc14c599db9c23f04d79a8f3ac79 /drivers/gpu/nvgpu/gp10b/gr_gp10b.c
parentfd2cac59f3491cb5b4f5d1f3fc97df94734bd682 (diff)
gpu: nvgpu: define preemption modes in common code
We use linux specific graphics/compute preemption modes defined in uapi header (and of below form) in all over common code NVGPU_GRAPHICS_PREEMPTION_MODE_* NVGPU_COMPUTE_PREEMPTION_MODE_* Since common code should be independent of linux specific code, define new modes of the form in common code and used them everywhere NVGPU_PREEMPTION_MODE_GRAPHICS_* NVGPU_PREEMPTION_MODE_COMPUTE_* Add required parser functions to convert both the modes into each other For linux IOCTL NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE, we need to convert linux specific modes into common modes first before passing them to common code And to pass gpu characteristics to user space we need to first convert common modes into linux specific modes and then pass them to user space Jira NVGPU-392 Change-Id: I8c62c6859bdc1baa5b44eb31c7020e42d2462c8c Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1596930 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp10b/gr_gp10b.c')
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
index 559ea159..08988ac8 100644
--- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
@@ -408,7 +408,7 @@ int gr_gp10b_commit_global_cb_manager(struct gk20a *g,
408 408
409 gk20a_dbg_fn(""); 409 gk20a_dbg_fn("");
410 410
411 if (gr_ctx->graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) { 411 if (gr_ctx->graphics_preempt_mode == NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP) {
412 attrib_size_in_chunk = gr->attrib_cb_default_size + 412 attrib_size_in_chunk = gr->attrib_cb_default_size +
413 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() - 413 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
414 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v()); 414 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
@@ -941,18 +941,18 @@ int gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g,
941 941
942 if (g->ops.gr.is_valid_gfx_class(g, class) && 942 if (g->ops.gr.is_valid_gfx_class(g, class) &&
943 g->gr.t18x.ctx_vars.force_preemption_gfxp) 943 g->gr.t18x.ctx_vars.force_preemption_gfxp)
944 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP; 944 graphics_preempt_mode = NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP;
945 945
946 if (g->ops.gr.is_valid_compute_class(g, class) && 946 if (g->ops.gr.is_valid_compute_class(g, class) &&
947 g->gr.t18x.ctx_vars.force_preemption_cilp) 947 g->gr.t18x.ctx_vars.force_preemption_cilp)
948 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP; 948 compute_preempt_mode = NVGPU_PREEMPTION_MODE_COMPUTE_CILP;
949 949
950 /* check for invalid combinations */ 950 /* check for invalid combinations */
951 if ((graphics_preempt_mode == 0) && (compute_preempt_mode == 0)) 951 if ((graphics_preempt_mode == 0) && (compute_preempt_mode == 0))
952 return -EINVAL; 952 return -EINVAL;
953 953
954 if ((graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) && 954 if ((graphics_preempt_mode == NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP) &&
955 (compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP)) 955 (compute_preempt_mode == NVGPU_PREEMPTION_MODE_COMPUTE_CILP))
956 return -EINVAL; 956 return -EINVAL;
957 957
958 /* Do not allow lower preemption modes than current ones */ 958 /* Do not allow lower preemption modes than current ones */
@@ -966,7 +966,7 @@ int gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g,
966 966
967 /* set preemption modes */ 967 /* set preemption modes */
968 switch (graphics_preempt_mode) { 968 switch (graphics_preempt_mode) {
969 case NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP: 969 case NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP:
970 { 970 {
971 u32 spill_size = 971 u32 spill_size =
972 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v() * 972 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v() *
@@ -1022,7 +1022,7 @@ int gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g,
1022 break; 1022 break;
1023 } 1023 }
1024 1024
1025 case NVGPU_GRAPHICS_PREEMPTION_MODE_WFI: 1025 case NVGPU_PREEMPTION_MODE_GRAPHICS_WFI:
1026 gr_ctx->graphics_preempt_mode = graphics_preempt_mode; 1026 gr_ctx->graphics_preempt_mode = graphics_preempt_mode;
1027 break; 1027 break;
1028 1028
@@ -1033,9 +1033,9 @@ int gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g,
1033 if (g->ops.gr.is_valid_compute_class(g, class) || 1033 if (g->ops.gr.is_valid_compute_class(g, class) ||
1034 g->ops.gr.is_valid_gfx_class(g, class)) { 1034 g->ops.gr.is_valid_gfx_class(g, class)) {
1035 switch (compute_preempt_mode) { 1035 switch (compute_preempt_mode) {
1036 case NVGPU_COMPUTE_PREEMPTION_MODE_WFI: 1036 case NVGPU_PREEMPTION_MODE_COMPUTE_WFI:
1037 case NVGPU_COMPUTE_PREEMPTION_MODE_CTA: 1037 case NVGPU_PREEMPTION_MODE_COMPUTE_CTA:
1038 case NVGPU_COMPUTE_PREEMPTION_MODE_CILP: 1038 case NVGPU_PREEMPTION_MODE_COMPUTE_CILP:
1039 gr_ctx->compute_preempt_mode = compute_preempt_mode; 1039 gr_ctx->compute_preempt_mode = compute_preempt_mode;
1040 break; 1040 break;
1041 default: 1041 default:
@@ -1073,9 +1073,9 @@ int gr_gp10b_alloc_gr_ctx(struct gk20a *g,
1073 (*gr_ctx)->t18x.ctx_id_valid = false; 1073 (*gr_ctx)->t18x.ctx_id_valid = false;
1074 1074
1075 if (flags & NVGPU_OBJ_CTX_FLAGS_SUPPORT_GFXP) 1075 if (flags & NVGPU_OBJ_CTX_FLAGS_SUPPORT_GFXP)
1076 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP; 1076 graphics_preempt_mode = NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP;
1077 if (flags & NVGPU_OBJ_CTX_FLAGS_SUPPORT_CILP) 1077 if (flags & NVGPU_OBJ_CTX_FLAGS_SUPPORT_CILP)
1078 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP; 1078 compute_preempt_mode = NVGPU_PREEMPTION_MODE_COMPUTE_CILP;
1079 1079
1080 if (graphics_preempt_mode || compute_preempt_mode) { 1080 if (graphics_preempt_mode || compute_preempt_mode) {
1081 if (g->ops.gr.set_ctxsw_preemption_mode) { 1081 if (g->ops.gr.set_ctxsw_preemption_mode) {
@@ -1190,21 +1190,21 @@ void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g,
1190 1190
1191 gk20a_dbg_fn(""); 1191 gk20a_dbg_fn("");
1192 1192
1193 if (gr_ctx->graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) { 1193 if (gr_ctx->graphics_preempt_mode == NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP) {
1194 gk20a_dbg_info("GfxP: %x", gfxp_preempt_option); 1194 gk20a_dbg_info("GfxP: %x", gfxp_preempt_option);
1195 nvgpu_mem_wr(g, mem, 1195 nvgpu_mem_wr(g, mem,
1196 ctxsw_prog_main_image_graphics_preemption_options_o(), 1196 ctxsw_prog_main_image_graphics_preemption_options_o(),
1197 gfxp_preempt_option); 1197 gfxp_preempt_option);
1198 } 1198 }
1199 1199
1200 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP) { 1200 if (gr_ctx->compute_preempt_mode == NVGPU_PREEMPTION_MODE_COMPUTE_CILP) {
1201 gk20a_dbg_info("CILP: %x", cilp_preempt_option); 1201 gk20a_dbg_info("CILP: %x", cilp_preempt_option);
1202 nvgpu_mem_wr(g, mem, 1202 nvgpu_mem_wr(g, mem,
1203 ctxsw_prog_main_image_compute_preemption_options_o(), 1203 ctxsw_prog_main_image_compute_preemption_options_o(),
1204 cilp_preempt_option); 1204 cilp_preempt_option);
1205 } 1205 }
1206 1206
1207 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CTA) { 1207 if (gr_ctx->compute_preempt_mode == NVGPU_PREEMPTION_MODE_COMPUTE_CTA) {
1208 gk20a_dbg_info("CTA: %x", cta_preempt_option); 1208 gk20a_dbg_info("CTA: %x", cta_preempt_option);
1209 nvgpu_mem_wr(g, mem, 1209 nvgpu_mem_wr(g, mem,
1210 ctxsw_prog_main_image_compute_preemption_options_o(), 1210 ctxsw_prog_main_image_compute_preemption_options_o(),
@@ -1835,7 +1835,7 @@ int gr_gp10b_pre_process_sm_exception(struct gk20a *g,
1835 1835
1836 if (fault_ch) 1836 if (fault_ch)
1837 cilp_enabled = (fault_ch->ch_ctx.gr_ctx->compute_preempt_mode == 1837 cilp_enabled = (fault_ch->ch_ctx.gr_ctx->compute_preempt_mode ==
1838 NVGPU_COMPUTE_PREEMPTION_MODE_CILP); 1838 NVGPU_PREEMPTION_MODE_COMPUTE_CILP);
1839 1839
1840 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "SM Exception received on gpc %d tpc %d = %u\n", 1840 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "SM Exception received on gpc %d tpc %d = %u\n",
1841 gpc, tpc, global_esr); 1841 gpc, tpc, global_esr);
@@ -2045,7 +2045,7 @@ static bool gr_gp10b_suspend_context(struct channel_gk20a *ch,
2045 if (gk20a_is_channel_ctx_resident(ch)) { 2045 if (gk20a_is_channel_ctx_resident(ch)) {
2046 g->ops.gr.suspend_all_sms(g, 0, false); 2046 g->ops.gr.suspend_all_sms(g, 0, false);
2047 2047
2048 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP) { 2048 if (gr_ctx->compute_preempt_mode == NVGPU_PREEMPTION_MODE_COMPUTE_CILP) {
2049 err = gr_gp10b_set_cilp_preempt_pending(g, ch); 2049 err = gr_gp10b_set_cilp_preempt_pending(g, ch);
2050 if (err) 2050 if (err)
2051 nvgpu_err(g, "unable to set CILP preempt pending"); 2051 nvgpu_err(g, "unable to set CILP preempt pending");
@@ -2278,17 +2278,17 @@ int gr_gp10b_get_preemption_mode_flags(struct gk20a *g,
2278 struct nvgpu_preemption_modes_rec *preemption_modes_rec) 2278 struct nvgpu_preemption_modes_rec *preemption_modes_rec)
2279{ 2279{
2280 preemption_modes_rec->graphics_preemption_mode_flags = ( 2280 preemption_modes_rec->graphics_preemption_mode_flags = (
2281 NVGPU_GRAPHICS_PREEMPTION_MODE_WFI | 2281 NVGPU_PREEMPTION_MODE_GRAPHICS_WFI |
2282 NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP); 2282 NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP);
2283 preemption_modes_rec->compute_preemption_mode_flags = ( 2283 preemption_modes_rec->compute_preemption_mode_flags = (
2284 NVGPU_COMPUTE_PREEMPTION_MODE_WFI | 2284 NVGPU_PREEMPTION_MODE_COMPUTE_WFI |
2285 NVGPU_COMPUTE_PREEMPTION_MODE_CTA | 2285 NVGPU_PREEMPTION_MODE_COMPUTE_CTA |
2286 NVGPU_COMPUTE_PREEMPTION_MODE_CILP); 2286 NVGPU_PREEMPTION_MODE_COMPUTE_CILP);
2287 2287
2288 preemption_modes_rec->default_graphics_preempt_mode = 2288 preemption_modes_rec->default_graphics_preempt_mode =
2289 NVGPU_GRAPHICS_PREEMPTION_MODE_WFI; 2289 NVGPU_PREEMPTION_MODE_GRAPHICS_WFI;
2290 preemption_modes_rec->default_compute_preempt_mode = 2290 preemption_modes_rec->default_compute_preempt_mode =
2291 NVGPU_COMPUTE_PREEMPTION_MODE_WFI; 2291 NVGPU_PREEMPTION_MODE_COMPUTE_WFI;
2292 2292
2293 return 0; 2293 return 0;
2294} 2294}