summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c
diff options
context:
space:
mode:
authorVinod G <vinodg@nvidia.com>2018-06-18 15:04:13 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-06-20 02:40:49 -0400
commit06ceff1240902c7f4cdb01dcbc9c988fc5fd9495 (patch)
tree3dd1b088f7df458119cc8e7f00f75466a04f2d33 /drivers/gpu/nvgpu/os/linux/ioctl_dbg.c
parent52f1ab0372af3907364dea8b9ff3d25eaa4cbd7f (diff)
gpu: nvgpu: PG refcount check moved to a wrapper function.
Moved PG refcount checking to a wrapper function, this function manages the refcount and decides whether to call dbg_set_powergate function. Instead of checking the dbg_s->is_pg_disabled variable, code is checking g->dbg_powergating_disabled_refcount variable to know if powergate is disabled or not. Updating hwpm ctxsw mode without disabling powergate will result in priv errors. Bug 200410871 Bug 2109765 Change-Id: I33c9022cb04cd39249c78e72584dfe6afb7212d0 Signed-off-by: Vinod G <vinodg@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1753550 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Richard Zhao <rizhao@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/ioctl_dbg.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/ioctl_dbg.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c
index 31e7e2cb..76ff25c0 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c
@@ -181,7 +181,9 @@ int gk20a_dbg_gpu_dev_release(struct inode *inode, struct file *filp)
181 * calling powergate/timeout enable ioctl 181 * calling powergate/timeout enable ioctl
182 */ 182 */
183 nvgpu_mutex_acquire(&g->dbg_sessions_lock); 183 nvgpu_mutex_acquire(&g->dbg_sessions_lock);
184 g->ops.dbg_session_ops.dbg_set_powergate(dbg_s, false); 184 if (dbg_s->is_pg_disabled) {
185 nvgpu_set_powergate_locked(dbg_s, false);
186 }
185 nvgpu_dbg_timeout_enable(dbg_s, NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE); 187 nvgpu_dbg_timeout_enable(dbg_s, NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE);
186 188
187 /* If this session owned the perf buffer, release it */ 189 /* If this session owned the perf buffer, release it */
@@ -867,9 +869,10 @@ static int nvgpu_ioctl_channel_reg_ops(struct dbg_session_gk20a *dbg_s,
867 /* In the virtual case, the server will handle 869 /* In the virtual case, the server will handle
868 * disabling/enabling powergating when processing reg ops 870 * disabling/enabling powergating when processing reg ops
869 */ 871 */
870 powergate_err = g->ops.dbg_session_ops.dbg_set_powergate(dbg_s, 872 powergate_err = nvgpu_set_powergate_locked(dbg_s, true);
871 true); 873 if (!powergate_err) {
872 is_pg_disabled = true; 874 is_pg_disabled = true;
875 }
873 } 876 }
874 877
875 if (!powergate_err) { 878 if (!powergate_err) {
@@ -938,9 +941,8 @@ static int nvgpu_ioctl_channel_reg_ops(struct dbg_session_gk20a *dbg_s,
938 941
939 /* enable powergate, if previously disabled */ 942 /* enable powergate, if previously disabled */
940 if (is_pg_disabled) { 943 if (is_pg_disabled) {
941 powergate_err = 944 powergate_err = nvgpu_set_powergate_locked(dbg_s,
942 g->ops.dbg_session_ops.dbg_set_powergate(dbg_s, 945 false);
943 false);
944 } 946 }
945 } 947 }
946 948
@@ -964,14 +966,16 @@ static int nvgpu_ioctl_powergate_gk20a(struct dbg_session_gk20a *dbg_s,
964 g->name, args->mode); 966 g->name, args->mode);
965 967
966 nvgpu_mutex_acquire(&g->dbg_sessions_lock); 968 nvgpu_mutex_acquire(&g->dbg_sessions_lock);
967 if (args->mode == NVGPU_DBG_GPU_POWERGATE_MODE_DISABLE) { 969 if ((args->mode != NVGPU_DBG_GPU_POWERGATE_MODE_DISABLE) &&
968 err = g->ops.dbg_session_ops.dbg_set_powergate(dbg_s, true); 970 (args->mode != NVGPU_DBG_GPU_POWERGATE_MODE_ENABLE)) {
969 } else if (args->mode == NVGPU_DBG_GPU_POWERGATE_MODE_ENABLE) {
970 err = g->ops.dbg_session_ops.dbg_set_powergate(dbg_s, false);
971 } else {
972 nvgpu_err(g, "invalid powergate mode"); 971 nvgpu_err(g, "invalid powergate mode");
973 err = -EINVAL; 972 err = -EINVAL;
973 goto pg_err_end;
974 } 974 }
975
976 err = nvgpu_set_powergate_locked(dbg_s,
977 args->mode == NVGPU_DBG_GPU_POWERGATE_MODE_DISABLE);
978pg_err_end:
975 nvgpu_mutex_release(&g->dbg_sessions_lock); 979 nvgpu_mutex_release(&g->dbg_sessions_lock);
976 return err; 980 return err;
977} 981}
@@ -1053,7 +1057,7 @@ static int nvgpu_dbg_gpu_ioctl_hwpm_ctxsw_mode(struct dbg_session_gk20a *dbg_s,
1053 err = -EINVAL; 1057 err = -EINVAL;
1054 goto clean_up; 1058 goto clean_up;
1055 } 1059 }
1056 if (!dbg_s->is_pg_disabled) { 1060 if (g->dbg_powergating_disabled_refcount == 0) {
1057 nvgpu_err(g, "powergate is not disabled"); 1061 nvgpu_err(g, "powergate is not disabled");
1058 err = -ENOSYS; 1062 err = -ENOSYS;
1059 goto clean_up; 1063 goto clean_up;