mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
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>
237 lines
5.2 KiB
C
237 lines
5.2 KiB
C
/*
|
|
* Copyright (C) 2017 NVIDIA Corporation. All rights reserved.
|
|
*
|
|
* This software is licensed under the terms of the GNU General Public
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
* may be copied, distributed, and modified under those terms.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#include <nvgpu/gr/ctx.h>
|
|
|
|
#include "common/gr/ctx_priv.h"
|
|
|
|
#include "debug_gr.h"
|
|
#include "os_linux.h"
|
|
|
|
#include <linux/uaccess.h>
|
|
#include <linux/debugfs.h>
|
|
|
|
static int gr_default_attrib_cb_size_show(struct seq_file *s, void *data)
|
|
{
|
|
struct gk20a *g = s->private;
|
|
|
|
seq_printf(s, "%u\n", g->ops.gr.init.get_attrib_cb_default_size(g));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int gr_default_attrib_cb_size_open(struct inode *inode,
|
|
struct file *file)
|
|
{
|
|
return single_open(file, gr_default_attrib_cb_size_show,
|
|
inode->i_private);
|
|
}
|
|
|
|
static const struct file_operations gr_default_attrib_cb_size_fops= {
|
|
.open = gr_default_attrib_cb_size_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = single_release,
|
|
};
|
|
|
|
static ssize_t force_preemption_gfxp_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->force_preemption_gfxp) {
|
|
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 force_preemption_gfxp_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->force_preemption_gfxp = val;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
static struct file_operations force_preemption_gfxp_fops = {
|
|
.open = simple_open,
|
|
.read = force_preemption_gfxp_read,
|
|
.write = force_preemption_gfxp_write,
|
|
};
|
|
|
|
static ssize_t force_preemption_cilp_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->force_preemption_cilp) {
|
|
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 force_preemption_cilp_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->force_preemption_cilp = val;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
static struct file_operations force_preemption_cilp_fops = {
|
|
.open = simple_open,
|
|
.read = force_preemption_cilp_read,
|
|
.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)
|
|
{
|
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
|
struct dentry *d;
|
|
|
|
d = debugfs_create_file(
|
|
"gr_default_attrib_cb_size", S_IRUGO, l->debugfs, g,
|
|
&gr_default_attrib_cb_size_fops);
|
|
if (!d)
|
|
return -ENOMEM;
|
|
|
|
d = debugfs_create_file(
|
|
"force_preemption_gfxp", S_IRUGO|S_IWUSR, l->debugfs, g,
|
|
&force_preemption_gfxp_fops);
|
|
if (!d)
|
|
return -ENOMEM;
|
|
|
|
d = debugfs_create_file(
|
|
"force_preemption_cilp", S_IRUGO|S_IWUSR, l->debugfs, g,
|
|
&force_preemption_cilp_fops);
|
|
if (!d)
|
|
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;
|
|
}
|
|
|