gpu: nvgpu: move dump_ctxsw_stats_on_channel_close flag to gr_ctx_desc

Debug boolean flag dump_ctxsw_stats_on_channel_close is right now stored
in gr_gk20a.ctx_vars struct
This flag logically is property of gr.ctx units since it indicates
whether each context should dump ctxsw stats on channel/context close

Move this flag to struct nvgpu_gr_ctx_desc and remove it from
gr_gk20a.ctx_vars

Expose below API from gr.ctx unit to check if flag is set
nvgpu_gr_ctx_desc_dump_ctxsw_stats_on_channel_close()

Move debugfs creation code to create corresponding debugfs to
gr_gk20a_debugfs_init() and change debugfs type from "u32" to "file"

Struct gr.gr_ctx_desc is created only during first poweron.
Return error if this struct is not available.

Remove unnecessary initialization of this variable from platform
specific probe functions

Jira NVGPU-3112

Change-Id: Id675e047237f82e9b8198a42082e99c95824578f
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2099399
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2019-04-15 17:23:17 +05:30
committed by mobile promotions
parent ee5b3823ff
commit 77140c1a84
9 changed files with 72 additions and 18 deletions

View File

@@ -969,3 +969,9 @@ bool nvgpu_gr_ctx_desc_force_preemption_cilp(struct nvgpu_gr_ctx_desc *gr_ctx_de
{ {
return gr_ctx_desc->force_preemption_cilp; return gr_ctx_desc->force_preemption_cilp;
} }
bool nvgpu_gr_ctx_desc_dump_ctxsw_stats_on_channel_close(
struct nvgpu_gr_ctx_desc *gr_ctx_desc)
{
return gr_ctx_desc->dump_ctxsw_stats_on_channel_close;
}

View File

@@ -47,6 +47,8 @@ struct nvgpu_gr_ctx_desc {
bool force_preemption_gfxp; bool force_preemption_gfxp;
bool force_preemption_cilp; bool force_preemption_cilp;
bool dump_ctxsw_stats_on_channel_close;
}; };
struct nvgpu_gr_ctx { struct nvgpu_gr_ctx {

View File

@@ -181,7 +181,8 @@ void nvgpu_gr_setup_free_gr_ctx(struct gk20a *g,
if (gr_ctx != NULL) { if (gr_ctx != NULL) {
if ((g->ops.gr.ctxsw_prog.dump_ctxsw_stats != NULL) && if ((g->ops.gr.ctxsw_prog.dump_ctxsw_stats != NULL) &&
g->gr->ctx_vars.dump_ctxsw_stats_on_channel_close) { nvgpu_gr_ctx_desc_dump_ctxsw_stats_on_channel_close(
g->gr->gr_ctx_desc)) {
g->ops.gr.ctxsw_prog.dump_ctxsw_stats(g, g->ops.gr.ctxsw_prog.dump_ctxsw_stats(g,
nvgpu_gr_ctx_get_ctx_mem(gr_ctx)); nvgpu_gr_ctx_get_ctx_mem(gr_ctx));
} }

View File

@@ -91,8 +91,6 @@ struct nvgpu_gr {
u32 preempt_image_size; u32 preempt_image_size;
u32 zcull_image_size; u32 zcull_image_size;
bool dump_ctxsw_stats_on_channel_close;
} ctx_vars; } ctx_vars;
struct nvgpu_mutex ctx_mutex; /* protect golden ctx init */ struct nvgpu_mutex ctx_mutex; /* protect golden ctx init */

View File

@@ -236,4 +236,7 @@ bool nvgpu_gr_ctx_desc_force_preemption_gfxp(
bool nvgpu_gr_ctx_desc_force_preemption_cilp( bool nvgpu_gr_ctx_desc_force_preemption_cilp(
struct nvgpu_gr_ctx_desc *gr_ctx_desc); struct nvgpu_gr_ctx_desc *gr_ctx_desc);
bool nvgpu_gr_ctx_desc_dump_ctxsw_stats_on_channel_close(
struct nvgpu_gr_ctx_desc *gr_ctx_desc);
#endif /* NVGPU_INCLUDE_GR_CTX_H */ #endif /* NVGPU_INCLUDE_GR_CTX_H */

View File

@@ -411,11 +411,6 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
l->debugfs, l->debugfs,
&g->runlist_interleave); &g->runlist_interleave);
l->debugfs_dump_ctxsw_stats =
debugfs_create_bool("dump_ctxsw_stats_on_channel_close",
S_IRUGO|S_IWUSR, l->debugfs,
&g->gr->ctx_vars.dump_ctxsw_stats_on_channel_close);
gr_gk20a_debugfs_init(g); gr_gk20a_debugfs_init(g);
gk20a_pmu_debugfs_init(g); gk20a_pmu_debugfs_init(g);
gk20a_railgating_debugfs_init(g); gk20a_railgating_debugfs_init(g);

View File

@@ -149,6 +149,58 @@ static struct file_operations force_preemption_cilp_fops = {
.write = force_preemption_cilp_write, .write = force_preemption_cilp_write,
}; };
static ssize_t dump_ctxsw_stats_on_channel_close_read(struct file *file,
char __user *user_buf, size_t count, loff_t *ppos)
{
char buf[3];
struct gk20a *g = file->private_data;
if (g->gr->gr_ctx_desc == NULL) {
return -EFAULT;
}
if (g->gr->gr_ctx_desc->dump_ctxsw_stats_on_channel_close) {
buf[0] = 'Y';
} else {
buf[0] = 'N';
}
buf[1] = '\n';
buf[2] = 0x00;
return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
}
static ssize_t dump_ctxsw_stats_on_channel_close_write(struct file *file,
const char __user *user_buf, size_t count, loff_t *ppos)
{
char buf[32];
int buf_size;
bool val;
struct gk20a *g = file->private_data;
if (g->gr->gr_ctx_desc == NULL) {
return -EFAULT;
}
buf_size = min(count, (sizeof(buf)-1));
if (copy_from_user(buf, user_buf, buf_size)) {
return -EFAULT;
}
if (strtobool(buf, &val) == 0) {
g->gr->gr_ctx_desc->dump_ctxsw_stats_on_channel_close = val;
}
return count;
}
static struct file_operations dump_ctxsw_stats_on_channel_close_fops = {
.open = simple_open,
.read = dump_ctxsw_stats_on_channel_close_read,
.write = dump_ctxsw_stats_on_channel_close_write,
};
int gr_gk20a_debugfs_init(struct gk20a *g) int gr_gk20a_debugfs_init(struct gk20a *g)
{ {
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
@@ -172,6 +224,13 @@ int gr_gk20a_debugfs_init(struct gk20a *g)
if (!d) if (!d)
return -ENOMEM; return -ENOMEM;
d = debugfs_create_file(
"dump_ctxsw_stats_on_channel_close", S_IRUGO|S_IWUSR,
l->debugfs, g,
&dump_ctxsw_stats_on_channel_close_fops);
if (!d)
return -ENOMEM;
return 0; return 0;
} }

View File

@@ -158,11 +158,6 @@ static int gp10b_tegra_probe(struct device *dev)
platform->disable_bigpage = !dev->archdata.iommu; platform->disable_bigpage = !dev->archdata.iommu;
platform->g->gr->ctx_vars.dump_ctxsw_stats_on_channel_close
= false;
platform->g->gr->ctx_vars.dump_ctxsw_stats_on_channel_close
= false;
gp10b_tegra_get_clocks(dev); gp10b_tegra_get_clocks(dev);
nvgpu_linux_init_clk_support(platform->g); nvgpu_linux_init_clk_support(platform->g);

View File

@@ -86,11 +86,6 @@ static int gv11b_tegra_probe(struct device *dev)
platform->disable_bigpage = !dev->archdata.iommu; platform->disable_bigpage = !dev->archdata.iommu;
platform->g->gr->ctx_vars.dump_ctxsw_stats_on_channel_close
= false;
platform->g->gr->ctx_vars.dump_ctxsw_stats_on_channel_close
= false;
gp10b_tegra_get_clocks(dev); gp10b_tegra_get_clocks(dev);
nvgpu_linux_init_clk_support(platform->g); nvgpu_linux_init_clk_support(platform->g);