diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h index 100c9e357..23f734d84 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h @@ -851,6 +851,9 @@ struct gk20a { /** To enable emulate mode */ u32 emulate_mode; + + /** Flag to check if debugger and profiler support is enabled. */ + u32 support_gpu_tools; }; /** diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c index a65c19ab1..fbafd696c 100644 --- a/drivers/gpu/nvgpu/os/linux/driver_common.c +++ b/drivers/gpu/nvgpu/os/linux/driver_common.c @@ -49,6 +49,28 @@ void nvgpu_kernel_restart(void *cmd) kernel_restart(cmd); } +void nvgpu_read_support_gpu_tools(struct gk20a *g) +{ + struct device_node *np; + int ret = 0; + u32 val = 0; + + np = nvgpu_get_node(g); + ret = of_property_read_u32(np, "support-gpu-tools", &val); + if (ret != 0) { + nvgpu_info(g, "Missing support-gpu-tools property, ret =%d", ret); + /* The debugger/profiler support should be enabled by default. + * So, set support_gpu_tools to 1 even if the property is missing. */ + g->support_gpu_tools = 1; + } else { + if (val != 0U) { + g->support_gpu_tools = 1; + } else { + g->support_gpu_tools = 0; + } + } +} + static void nvgpu_init_vars(struct gk20a *g) { struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); @@ -320,6 +342,11 @@ int nvgpu_probe(struct gk20a *g, return err; } + /* Read the DT 'support-gpu-tools' property before creating + * user nodes (via gk20a_user_nodes_init(). + */ + nvgpu_read_support_gpu_tools(g); + /* * TODO: While removing the legacy nodes the following condition * need to be removed. diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.h b/drivers/gpu/nvgpu/os/linux/driver_common.h index 026ab206a..f1c46ac1f 100644 --- a/drivers/gpu/nvgpu/os/linux/driver_common.h +++ b/drivers/gpu/nvgpu/os/linux/driver_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-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, @@ -23,5 +23,6 @@ int nvgpu_probe(struct gk20a *g, const char *debugfs_symlink); void nvgpu_init_gk20a(struct gk20a *g); +void nvgpu_read_support_gpu_tools(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/os/linux/ioctl.c b/drivers/gpu/nvgpu/os/linux/ioctl.c index b6815bb52..240e7da38 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl.c @@ -168,22 +168,24 @@ struct nvgpu_dev_node { const struct file_operations *fops; /* If node should be created for physical instance in MIG mode */ bool mig_physical_node; + /* Flag to check if node is used by debugger/profiler. */ + bool tools_node; }; static const struct nvgpu_dev_node dev_node_list[] = { - {"power", &gk20a_power_node_ops, false }, - {"as", &gk20a_as_ops, false }, - {"channel", &gk20a_channel_ops, false }, - {"ctrl", &gk20a_ctrl_ops, true }, + {"power", &gk20a_power_node_ops, false, false }, + {"as", &gk20a_as_ops, false, false }, + {"channel", &gk20a_channel_ops, false, false }, + {"ctrl", &gk20a_ctrl_ops, true, false }, #if defined(CONFIG_NVGPU_FECS_TRACE) - {"ctxsw", &gk20a_ctxsw_ops, false }, + {"ctxsw", &gk20a_ctxsw_ops, false, true }, #endif - {"dbg", &gk20a_dbg_ops, false }, - {"prof", &gk20a_prof_ops, false }, - {"prof-ctx", &gk20a_prof_ctx_ops, false }, - {"prof-dev", &gk20a_prof_dev_ops, false }, - {"sched", &gk20a_sched_ops, false }, - {"tsg", &gk20a_tsg_ops, false }, + {"dbg", &gk20a_dbg_ops, false, true }, + {"prof", &gk20a_prof_ops, false, true }, + {"prof-ctx", &gk20a_prof_ctx_ops, false, true }, + {"prof-dev", &gk20a_prof_dev_ops, false, true }, + {"sched", &gk20a_sched_ops, false, false }, + {"tsg", &gk20a_tsg_ops, false, false }, }; static char *nvgpu_devnode(const char *cdev_name) @@ -520,6 +522,12 @@ static bool check_valid_dev_node(struct gk20a *g, struct nvgpu_class *class, } } + /* Do not create nodes used by GPU tools if support for debugger + * and profilers is disabled. + */ + if ((!g->support_gpu_tools) && (node->tools_node)) { + return false; + } return true; } diff --git a/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c b/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c index a0ba14165..7e3511eff 100644 --- a/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c +++ b/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c @@ -401,6 +401,8 @@ int vgpu_probe(struct platform_device *pdev) return err; } + nvgpu_read_support_gpu_tools(gk20a); + vgpu_init_vars(gk20a, platform); init_rwsem(&l->busy_lock);