summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
diff options
context:
space:
mode:
authorVaibhav Kachore <vkachore@nvidia.com>2018-07-06 05:40:03 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-07-10 21:13:43 -0400
commite14fdcd8f1f4125da697433b1744b1e4e4f15b09 (patch)
treef48ff794ef77e977ccba397f5abf14f5ae7b185b /drivers/gpu/nvgpu/vgpu/gr_vgpu.c
parent4cd59404a2d4ab1c31605d96cff848dd4e93c3b4 (diff)
gpu: nvgpu: enable HWPM Mode-E context switch
- Write new pm mode to context buffer header. Ucode use this mode to enable mode-e context switch. This is Mode-B context switch of PMs with Mode-E streamout on one context. If this mode is set, Ucode makes sure that Mode-E pipe (perfmons, routers, pma) is idle before it context switches PMs. - This allows us to collect counters in a secure way (i.e. on context basis) with stream out. Bug 2106999 Change-Id: I5a7435f09d1bf053ca428e538b0a57f3a175ac37 Signed-off-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1760366 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/gr_vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/vgpu/gr_vgpu.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
index 83d27f17..0077c537 100644
--- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
@@ -1066,7 +1066,7 @@ int vgpu_gr_update_smpc_ctxsw_mode(struct gk20a *g,
1066} 1066}
1067 1067
1068int vgpu_gr_update_hwpm_ctxsw_mode(struct gk20a *g, 1068int vgpu_gr_update_hwpm_ctxsw_mode(struct gk20a *g,
1069 struct channel_gk20a *ch, u64 gpu_va, bool enable) 1069 struct channel_gk20a *ch, u64 gpu_va, u32 mode)
1070{ 1070{
1071 struct tsg_gk20a *tsg; 1071 struct tsg_gk20a *tsg;
1072 struct nvgpu_gr_ctx *ch_ctx; 1072 struct nvgpu_gr_ctx *ch_ctx;
@@ -1089,16 +1089,33 @@ int vgpu_gr_update_hwpm_ctxsw_mode(struct gk20a *g,
1089 ch_ctx = &tsg->gr_ctx; 1089 ch_ctx = &tsg->gr_ctx;
1090 pm_ctx = &ch_ctx->pm_ctx; 1090 pm_ctx = &ch_ctx->pm_ctx;
1091 1091
1092 if (enable) { 1092 if (mode == NVGPU_DBG_HWPM_CTXSW_MODE_CTXSW) {
1093 /* 1093 /*
1094 * send command to enable HWPM only once - otherwise server 1094 * send command to enable HWPM only once - otherwise server
1095 * will return an error due to using the same GPU VA twice. 1095 * will return an error due to using the same GPU VA twice.
1096 */ 1096 */
1097 if (pm_ctx->pm_mode == ctxsw_prog_main_image_pm_mode_ctxsw_f())
1098 return 0;
1099 1097
1098 if (pm_ctx->pm_mode == ctxsw_prog_main_image_pm_mode_ctxsw_f()) {
1099 return 0;
1100 }
1100 p->mode = TEGRA_VGPU_CTXSW_MODE_CTXSW; 1101 p->mode = TEGRA_VGPU_CTXSW_MODE_CTXSW;
1102 } else if (mode == NVGPU_DBG_HWPM_CTXSW_MODE_NO_CTXSW) {
1103 if (pm_ctx->pm_mode == ctxsw_prog_main_image_pm_mode_no_ctxsw_f()) {
1104 return 0;
1105 }
1106 p->mode = TEGRA_VGPU_CTXSW_MODE_NO_CTXSW;
1107 } else if ((mode == NVGPU_DBG_HWPM_CTXSW_MODE_STREAM_OUT_CTXSW) &&
1108 (g->ops.gr.get_hw_accessor_stream_out_mode)){
1109 if (pm_ctx->pm_mode == g->ops.gr.get_hw_accessor_stream_out_mode()) {
1110 return 0;
1111 }
1112 p->mode = TEGRA_VGPU_CTXSW_MODE_STREAM_OUT_CTXSW;
1113 } else {
1114 nvgpu_err(g, "invalid hwpm context switch mode");
1115 return -EINVAL;
1116 }
1101 1117
1118 if (mode != NVGPU_DBG_HWPM_CTXSW_MODE_NO_CTXSW) {
1102 /* Allocate buffer if necessary */ 1119 /* Allocate buffer if necessary */
1103 if (pm_ctx->mem.gpu_va == 0) { 1120 if (pm_ctx->mem.gpu_va == 0) {
1104 pm_ctx->mem.gpu_va = __nvgpu_vm_alloc_va(ch->vm, 1121 pm_ctx->mem.gpu_va = __nvgpu_vm_alloc_va(ch->vm,
@@ -1109,11 +1126,6 @@ int vgpu_gr_update_hwpm_ctxsw_mode(struct gk20a *g,
1109 return -ENOMEM; 1126 return -ENOMEM;
1110 pm_ctx->mem.size = g->gr.ctx_vars.pm_ctxsw_image_size; 1127 pm_ctx->mem.size = g->gr.ctx_vars.pm_ctxsw_image_size;
1111 } 1128 }
1112 } else {
1113 if (pm_ctx->pm_mode == ctxsw_prog_main_image_pm_mode_no_ctxsw_f())
1114 return 0;
1115
1116 p->mode = TEGRA_VGPU_CTXSW_MODE_NO_CTXSW;
1117 } 1129 }
1118 1130
1119 msg.cmd = TEGRA_VGPU_CMD_CHANNEL_SET_HWPM_CTXSW_MODE; 1131 msg.cmd = TEGRA_VGPU_CMD_CHANNEL_SET_HWPM_CTXSW_MODE;
@@ -1124,10 +1136,15 @@ int vgpu_gr_update_hwpm_ctxsw_mode(struct gk20a *g,
1124 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); 1136 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
1125 WARN_ON(err || msg.ret); 1137 WARN_ON(err || msg.ret);
1126 err = err ? err : msg.ret; 1138 err = err ? err : msg.ret;
1127 if (!err) 1139 if (!err) {
1128 pm_ctx->pm_mode = enable ? 1140 if (mode == NVGPU_DBG_HWPM_CTXSW_MODE_CTXSW) {
1129 ctxsw_prog_main_image_pm_mode_ctxsw_f() : 1141 pm_ctx->pm_mode = ctxsw_prog_main_image_pm_mode_ctxsw_f();
1130 ctxsw_prog_main_image_pm_mode_no_ctxsw_f(); 1142 } else if (mode == NVGPU_DBG_HWPM_CTXSW_MODE_NO_CTXSW) {
1143 pm_ctx->pm_mode = ctxsw_prog_main_image_pm_mode_no_ctxsw_f();
1144 } else {
1145 pm_ctx->pm_mode = g->ops.gr.get_hw_accessor_stream_out_mode();
1146 }
1147 }
1131 1148
1132 return err; 1149 return err;
1133} 1150}