Files
Laxman Dewangan b702c927da nvgpu: Use kstrtobool instead of strtobool
The function strtobool() is implemented inline with
using kstrtobool(). The function strtobool() is removed
from mainline Linux 6.7 with below change.

**
commit 9bf2850c9170b52a6ab052085feced55effa78ef
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

        kstrtox: remove strtobool()
**

Use the kstrtobool() now.

Bug 4346767

Change-Id: I2b22eb4668ae2b3e693b6b3177cc23270f14b557
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3019995
(cherry picked from commit 475e8e07cf5d22da5721e2ac21b767bfb94a2746)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3037015
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-12-18 09:11:58 -08:00

98 lines
2.5 KiB
C

/*
* Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "debug_ltc.h"
#include "os_linux.h"
#include <nvgpu/gk20a.h>
#include <nvgpu/nvgpu_init.h>
#include <linux/debugfs.h>
#include <linux/uaccess.h>
static ssize_t ltc_intr_illegal_compstat_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->ltc_intr_en_illegal_compstat)
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 ltc_intr_illegal_compstat_write(struct file *file,
const char __user *user_buf, size_t count, loff_t *ppos)
{
char buf[3];
int buf_size;
bool intr_illegal_compstat_enabled;
struct gk20a *g = file->private_data;
int err;
if (!g->ops.ltc.intr.en_illegal_compstat)
return -EINVAL;
buf_size = min(count, (sizeof(buf)-1));
if (copy_from_user(buf, user_buf, buf_size))
return -EFAULT;
err = gk20a_busy(g);
if (err)
return err;
if (kstrtobool(buf, &intr_illegal_compstat_enabled) == 0) {
g->ops.ltc.intr.en_illegal_compstat(g,
intr_illegal_compstat_enabled);
g->ltc_intr_en_illegal_compstat = intr_illegal_compstat_enabled;
}
gk20a_idle(g);
return buf_size;
}
static const struct file_operations ltc_intr_illegal_compstat_fops = {
.open = simple_open,
.read = ltc_intr_illegal_compstat_read,
.write = ltc_intr_illegal_compstat_write,
};
int nvgpu_ltc_debugfs_init(struct gk20a *g)
{
struct dentry *d;
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
struct dentry *gpu_root = l->debugfs;
l->debugfs_ltc = debugfs_create_dir("ltc", gpu_root);
if (IS_ERR_OR_NULL(l->debugfs_ltc))
return -ENODEV;
/* Debug fs node to enable/disable illegal_compstat */
d = debugfs_create_file("intr_illegal_compstat_enable", 0600,
l->debugfs_ltc, g,
&ltc_intr_illegal_compstat_fops);
if (!d)
return -ENOMEM;
return 0;
}