From 69be500c0b6fab324a34fc0b0f6b80f21a128c7e Mon Sep 17 00:00:00 2001 From: seshendra Gadagottu Date: Mon, 9 Jul 2018 16:25:40 -0700 Subject: gpu: nvgpu: debugfs node to enable/disable ltc_illegal_compstat intr Added debugfs node under ltc directory with name: intr_illegal_compstat_enable Enabling/disabling of ltc_illegal_compstat intr is possible through debugfs node. Since ltc state is lost with rail gate, this setting is cached and will be populated during ltc initialization. Bug 2099406 Change-Id: I4bf62228dfd2bbb94f87f923f9f4f6e5ad0b07f0 Signed-off-by: seshendra Gadagottu Reviewed-on: https://git-master.nvidia.com/r/1774683 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/debug.c | 2 + drivers/gpu/nvgpu/os/linux/debug_ltc.c | 93 ++++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/os/linux/debug_ltc.h | 21 ++++++++ drivers/gpu/nvgpu/os/linux/os_linux.h | 1 + 4 files changed, 117 insertions(+) create mode 100644 drivers/gpu/nvgpu/os/linux/debug_ltc.c create mode 100644 drivers/gpu/nvgpu/os/linux/debug_ltc.h (limited to 'drivers/gpu/nvgpu/os') diff --git a/drivers/gpu/nvgpu/os/linux/debug.c b/drivers/gpu/nvgpu/os/linux/debug.c index c4dae9e6..9403e72e 100644 --- a/drivers/gpu/nvgpu/os/linux/debug.c +++ b/drivers/gpu/nvgpu/os/linux/debug.c @@ -22,6 +22,7 @@ #include "debug_sched.h" #include "debug_hal.h" #include "debug_xve.h" +#include "debug_ltc.h" #include "debug_bios.h" #include "os_linux.h" #include "platform_gk20a.h" @@ -435,6 +436,7 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) #ifdef CONFIG_NVGPU_TRACK_MEM_USAGE nvgpu_kmem_debugfs_init(g); #endif + nvgpu_ltc_debugfs_init(g); if (g->pci_vendor_id) { nvgpu_xve_debugfs_init(g); nvgpu_bios_debugfs_init(g); diff --git a/drivers/gpu/nvgpu/os/linux/debug_ltc.c b/drivers/gpu/nvgpu/os/linux/debug_ltc.c new file mode 100644 index 00000000..88fb45f4 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_ltc.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2018 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 "debug_ltc.h" +#include "os_linux.h" +#include "gk20a/gk20a.h" + +#include +#include + +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 (strtobool(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, + <c_intr_illegal_compstat_fops); + if (!d) + return -ENOMEM; + + return 0; +} diff --git a/drivers/gpu/nvgpu/os/linux/debug_ltc.h b/drivers/gpu/nvgpu/os/linux/debug_ltc.h new file mode 100644 index 00000000..3ad734ce --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_ltc.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2018 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. + * + */ + +#ifndef __NVGPU_DEBUG_LTC_H__ +#define __NVGPU_DEBUG_LTC_H__ + +struct gk20a; +int nvgpu_ltc_debugfs_init(struct gk20a *g); + +#endif /* __NVGPU_DEBUG_LTC_H__ */ diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h index 85d697bd..13c20a81 100644 --- a/drivers/gpu/nvgpu/os/linux/os_linux.h +++ b/drivers/gpu/nvgpu/os/linux/os_linux.h @@ -135,6 +135,7 @@ struct nvgpu_os_linux { struct dentry *debugfs_xve; struct dentry *debugfs_kmem; struct dentry *debugfs_hal; + struct dentry *debugfs_ltc; struct dentry *debugfs_force_preemption_cilp; struct dentry *debugfs_force_preemption_gfxp; -- cgit v1.2.2