From b026c012963b135f8689c4409d12e79a76bb1156 Mon Sep 17 00:00:00 2001 From: Anup Mahindre Date: Wed, 5 Sep 2018 17:36:46 +0530 Subject: gpu: nvgpu: Return gr_ctx_resident from NVGPU_DBG_GPU_IOCTL_REG_OPS NVGPU_DBG_GPU_IOCTL_REG_OPS currently doesn't return if the ctx was resident in engine or not. Regops are broken down into batches of 128 and each batch is executed together. Since there only 32 bits were available in IOCTL args, returning is ctx was resident isn't possible for all batches. Hence return if the ctx was resident for the first batch. Bug 200445575 Change-Id: Iff950be25893de0afadd523d4ea04842a8ddf2af Signed-off-by: Anup Mahindre Reviewed-on: https://git-master.nvidia.com/r/1812975 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a.h | 3 ++- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 9 ++++++--- drivers/gpu/nvgpu/gk20a/gr_gk20a.h | 3 ++- drivers/gpu/nvgpu/gk20a/regops_gk20a.c | 6 ++++-- drivers/gpu/nvgpu/gk20a/regops_gk20a.h | 5 +++-- drivers/gpu/nvgpu/gv11b/gr_gv11b.c | 2 +- drivers/gpu/nvgpu/os/linux/ioctl_dbg.c | 11 +++++++++-- drivers/gpu/nvgpu/vgpu/dbg_vgpu.c | 3 ++- drivers/gpu/nvgpu/vgpu/dbg_vgpu.h | 3 ++- include/uapi/linux/nvgpu.h | 2 +- 10 files changed, 32 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index c98fec48..03510a16 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1133,7 +1133,8 @@ struct gpu_ops { struct { int (*exec_regops)(struct dbg_session_gk20a *dbg_s, struct nvgpu_dbg_reg_op *ops, - u64 num_ops); + u64 num_ops, + bool *is_current_ctx); const struct regop_offset_range* ( *get_global_whitelist_ranges)(void); u64 (*get_global_whitelist_ranges_count)(void); diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index a40d93fd..f3b580e4 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -8358,7 +8358,8 @@ int __gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch, int gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch, struct nvgpu_dbg_reg_op *ctx_ops, u32 num_ops, - u32 num_ctx_wr_ops, u32 num_ctx_rd_ops) + u32 num_ctx_wr_ops, u32 num_ctx_rd_ops, + bool *is_curr_ctx) { struct gk20a *g = ch->g; int err, tmp_err; @@ -8376,7 +8377,9 @@ int gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch, } ch_is_curr_ctx = gk20a_is_channel_ctx_resident(ch); - + if (is_curr_ctx != NULL) { + *is_curr_ctx = ch_is_curr_ctx; + } nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, "is curr ctx=%d", ch_is_curr_ctx); @@ -8694,7 +8697,7 @@ int gr_gk20a_set_sm_debug_mode(struct gk20a *g, i++; } - err = gr_gk20a_exec_ctx_ops(ch, ops, i, i, 0); + err = gr_gk20a_exec_ctx_ops(ch, ops, i, i, 0, NULL); if (err) { nvgpu_err(g, "Failed to access register"); } diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h index 4f83bba3..617aad34 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h @@ -616,7 +616,8 @@ int gk20a_gr_suspend(struct gk20a *g); struct nvgpu_dbg_reg_op; int gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch, struct nvgpu_dbg_reg_op *ctx_ops, u32 num_ops, - u32 num_ctx_wr_ops, u32 num_ctx_rd_ops); + u32 num_ctx_wr_ops, u32 num_ctx_rd_ops, + bool *is_curr_ctx); int __gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch, struct nvgpu_dbg_reg_op *ctx_ops, u32 num_ops, u32 num_ctx_wr_ops, u32 num_ctx_rd_ops, diff --git a/drivers/gpu/nvgpu/gk20a/regops_gk20a.c b/drivers/gpu/nvgpu/gk20a/regops_gk20a.c index 80d27c25..0aec4f86 100644 --- a/drivers/gpu/nvgpu/gk20a/regops_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/regops_gk20a.c @@ -89,7 +89,8 @@ static bool validate_reg_ops(struct dbg_session_gk20a *dbg_s, int exec_regops_gk20a(struct dbg_session_gk20a *dbg_s, struct nvgpu_dbg_reg_op *ops, - u64 num_ops) + u64 num_ops, + bool *is_current_ctx) { int err = 0; unsigned int i; @@ -219,7 +220,8 @@ int exec_regops_gk20a(struct dbg_session_gk20a *dbg_s, if (ctx_wr_count | ctx_rd_count) { err = gr_gk20a_exec_ctx_ops(ch, ops, num_ops, - ctx_wr_count, ctx_rd_count); + ctx_wr_count, ctx_rd_count, + is_current_ctx); if (err) { nvgpu_warn(g, "failed to perform ctx ops\n"); goto clean_up; diff --git a/drivers/gpu/nvgpu/gk20a/regops_gk20a.h b/drivers/gpu/nvgpu/gk20a/regops_gk20a.h index 0fb108a4..96705879 100644 --- a/drivers/gpu/nvgpu/gk20a/regops_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/regops_gk20a.h @@ -1,7 +1,7 @@ /* * Tegra GK20A GPU Debugger Driver Register Ops * - * Copyright (c) 2013-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2013-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -77,7 +77,8 @@ struct regop_offset_range { int exec_regops_gk20a(struct dbg_session_gk20a *dbg_s, struct nvgpu_dbg_reg_op *ops, - u64 num_ops); + u64 num_ops, + bool *is_current_ctx); /* turn seriously unwieldy names -> something shorter */ #define REGOP(x) NVGPU_DBG_REG_OP_##x diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c index 0938e2ed..450775b1 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c @@ -3377,7 +3377,7 @@ int gv11b_gr_set_sm_debug_mode(struct gk20a *g, i++; } - err = gr_gk20a_exec_ctx_ops(ch, ops, i, i, 0); + err = gr_gk20a_exec_ctx_ops(ch, ops, i, i, 0, NULL); if (err) { nvgpu_err(g, "Failed to access register\n"); } diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c index 9ea681b1..1eace94b 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c @@ -869,6 +869,9 @@ static int nvgpu_ioctl_channel_reg_ops(struct dbg_session_gk20a *dbg_s, struct gk20a *g = dbg_s->g; struct channel_gk20a *ch; + bool is_current_ctx; + + nvgpu_log_fn(g, "%d ops, max fragment %d", args->num_ops, g->dbg_regops_tmp_buf_ops); if (args->num_ops > NVGPU_IOCTL_DBG_REG_OPS_LIMIT) { @@ -954,11 +957,15 @@ static int nvgpu_ioctl_channel_reg_ops(struct dbg_session_gk20a *dbg_s, break; err = g->ops.regops.exec_regops( - dbg_s, g->dbg_regops_tmp_buf, num_ops); + dbg_s, g->dbg_regops_tmp_buf, num_ops, &is_current_ctx); if (err) { break; - } + } + + if (ops_offset == 0) { + args->gr_ctx_resident = is_current_ctx; + } err = nvgpu_get_regops_data_linux(g->dbg_regops_tmp_buf, linux_fragment, num_ops); diff --git a/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c b/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c index d188f540..ca8d2872 100644 --- a/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c @@ -33,7 +33,8 @@ int vgpu_exec_regops(struct dbg_session_gk20a *dbg_s, struct nvgpu_dbg_reg_op *ops, - u64 num_ops) + u64 num_ops, + bool *is_current_ctx) { struct channel_gk20a *ch; struct tegra_vgpu_cmd_msg msg; diff --git a/drivers/gpu/nvgpu/vgpu/dbg_vgpu.h b/drivers/gpu/nvgpu/vgpu/dbg_vgpu.h index 90645e59..7a1050ce 100644 --- a/drivers/gpu/nvgpu/vgpu/dbg_vgpu.h +++ b/drivers/gpu/nvgpu/vgpu/dbg_vgpu.h @@ -30,7 +30,8 @@ struct gk20a; int vgpu_exec_regops(struct dbg_session_gk20a *dbg_s, struct nvgpu_dbg_reg_op *ops, - u64 num_ops); + u64 num_ops, + bool *is_current_ctx); int vgpu_dbg_set_powergate(struct dbg_session_gk20a *dbg_s, bool disable_powergate); bool vgpu_check_and_set_global_reservation( struct dbg_session_gk20a *dbg_s, diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index b1dc4df4..1a275b35 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h @@ -1169,7 +1169,7 @@ struct nvgpu_dbg_gpu_reg_op { struct nvgpu_dbg_gpu_exec_reg_ops_args { __u64 ops; /* pointer to nvgpu_reg_op operations */ __u32 num_ops; - __u32 _pad0[1]; + __u32 gr_ctx_resident; }; #define NVGPU_DBG_GPU_IOCTL_REG_OPS \ -- cgit v1.2.2