diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h index 82526437d..06c0841ad 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h @@ -24,6 +24,7 @@ #define NVGPU_NVHOST_H #include +#include struct gk20a; #define NVGPU_INVALID_SYNCPT_ID (~U32(0U)) @@ -87,7 +88,10 @@ void nvgpu_free_nvhost_dev(struct gk20a *g); * @retval TRUE For syncpoint support. * */ -bool nvgpu_has_syncpoints(struct gk20a *g); +static inline bool nvgpu_has_syncpoints(struct gk20a *g) +{ + return nvgpu_is_enabled(g, NVGPU_HAS_SYNCPOINTS); +} #ifdef CONFIG_NVGPU_KERNEL_MODE_SUBMIT /** diff --git a/drivers/gpu/nvgpu/os/linux/debug.c b/drivers/gpu/nvgpu/os/linux/debug.c index 8ca775c52..f224a2820 100644 --- a/drivers/gpu/nvgpu/os/linux/debug.c +++ b/drivers/gpu/nvgpu/os/linux/debug.c @@ -384,6 +384,48 @@ static const struct file_operations dbg_tsg_timeslice_max_fops = { .write = dbg_tsg_timeslice_max_write, }; +static ssize_t disable_syncpts_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char buf[3]; + struct gk20a *g = file->private_data; + + if (!nvgpu_is_enabled(g, NVGPU_HAS_SYNCPOINTS)) + 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 disable_syncpts_write(struct file *file, + const char __user *user_buf, size_t count, loff_t *ppos) +{ + char buf[3]; + int buf_size; + bool disable_syncpts; + struct gk20a *g = file->private_data; + + buf_size = min(count, (sizeof(buf)-1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (!g->nvhost) + return -ENOSYS; + + if (strtobool(buf, &disable_syncpts) == 0) + nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, !disable_syncpts); + + return count; +} + +static const struct file_operations disable_syncpts_fops = { + .open = simple_open, + .read = disable_syncpts_read, + .write = disable_syncpts_write, +}; + void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) { struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); @@ -408,8 +450,13 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) debugfs_create_u32("ch_wdt_init_limit_ms", S_IRUGO|S_IWUSR, l->debugfs, &g->ch_wdt_init_limit_ms); - debugfs_create_bool("disable_syncpoints", S_IRUGO|S_IWUSR, - l->debugfs, &l->disable_syncpoints); + l->debugfs_disable_syncpts = + debugfs_create_file("disable_syncpoints", + S_IRUGO|S_IWUSR, + l->debugfs, + g, + &disable_syncpts_fops); + debugfs_create_bool("enable_platform_dbg", S_IRUGO|S_IWUSR, l->debugfs, &l->enable_platform_dbg); diff --git a/drivers/gpu/nvgpu/os/linux/nvhost_common.c b/drivers/gpu/nvgpu/os/linux/nvhost_common.c index 0a3c8d687..88da9bc03 100644 --- a/drivers/gpu/nvgpu/os/linux/nvhost_common.c +++ b/drivers/gpu/nvgpu/os/linux/nvhost_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2021, 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, @@ -41,14 +41,6 @@ void nvgpu_free_nvhost_dev(struct gk20a *g) nvgpu_kfree(g, g->nvhost); } -bool nvgpu_has_syncpoints(struct gk20a *g) -{ - struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); - - return nvgpu_is_enabled(g, NVGPU_HAS_SYNCPOINTS) && - !l->disable_syncpoints; -} - int nvgpu_nvhost_create_symlink(struct gk20a *g) { struct device *dev = dev_from_gk20a(g); diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h index 00444d0de..ff256241b 100644 --- a/drivers/gpu/nvgpu/os/linux/os_linux.h +++ b/drivers/gpu/nvgpu/os/linux/os_linux.h @@ -114,6 +114,7 @@ struct nvgpu_os_linux { struct dentry *debugfs_timeouts_enabled; struct dentry *debugfs_disable_bigpage; struct dentry *debugfs_dbg_tsg_timeslice_max_us; + struct dentry *debugfs_disable_syncpts; struct dentry *debugfs_runlist_interleave; struct dentry *debugfs_allocators; @@ -135,8 +136,6 @@ struct nvgpu_os_linux { bool init_done; - /** Debugfs knob for forcing syncpt support off in runtime. */ - bool disable_syncpoints; bool enable_platform_dbg; }; diff --git a/libs/dgpu/libnvgpu-drv-dgpu_safe.export b/libs/dgpu/libnvgpu-drv-dgpu_safe.export index a49caad61..a7cf01904 100644 --- a/libs/dgpu/libnvgpu-drv-dgpu_safe.export +++ b/libs/dgpu/libnvgpu-drv-dgpu_safe.export @@ -497,7 +497,6 @@ nvgpu_gr_subctx_alloc nvgpu_gr_subctx_free nvgpu_gr_suspend nvgpu_gr_sw_ready -nvgpu_has_syncpoints nvgpu_init_enabled_flags nvgpu_init_errata_flags nvgpu_init_hal diff --git a/libs/igpu/libnvgpu-drv-igpu_safe.export b/libs/igpu/libnvgpu-drv-igpu_safe.export index 0564a2bf3..f0f7e8192 100644 --- a/libs/igpu/libnvgpu-drv-igpu_safe.export +++ b/libs/igpu/libnvgpu-drv-igpu_safe.export @@ -513,7 +513,6 @@ nvgpu_gr_subctx_alloc nvgpu_gr_subctx_free nvgpu_gr_suspend nvgpu_gr_sw_ready -nvgpu_has_syncpoints nvgpu_init_enabled_flags nvgpu_init_errata_flags nvgpu_init_fb_support