From 0596e479ffcca43957f8d32127cea5527460b983 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 23 Sep 2021 12:49:27 -0400 Subject: Add APIs to enable/disable a channel and switch to or preempt a specific TSG Adds: - /proc/preempt_tsg which takes a TSG ID - /proc/disable_channel which takes a channel ID - /proc/enable_channel which takes a channel ID - /proc/switch_to_tsg which takes a TSG ID Also significantly expands documentation and structs available in nvdebug.h. --- nvdebug_entry.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'nvdebug_entry.c') diff --git a/nvdebug_entry.c b/nvdebug_entry.c index 6346659..14ad6e9 100644 --- a/nvdebug_entry.c +++ b/nvdebug_entry.c @@ -20,11 +20,31 @@ MODULE_DESCRIPTION("A scheduling debugging module for NVIDIA GPUs"); MODULE_SOFTDEP("pre: nvgpu"); // We only support the Jetson boards for now extern const struct file_operations runlist_file_ops; +extern const struct file_operations preempt_tsg_file_ops; +extern const struct file_operations disable_channel_file_ops; +extern const struct file_operations enable_channel_file_ops; +extern const struct file_operations switch_to_tsg_file_ops; int __init nvdebug_init(void) { - struct proc_dir_entry *entry = proc_create("runlist", 0444, NULL, &runlist_file_ops); - if (!entry) { + struct proc_dir_entry *rl_entry, *preempt_entry, *disable_channel_entry, + *enable_channel_entry, *switch_to_tsg_entry; + // Create file `/proc/preempt_tsg`, world readable + rl_entry = proc_create("runlist", 0444, NULL, &runlist_file_ops); + // Create file `/proc/preempt_tsg`, world writable + preempt_entry = proc_create("preempt_tsg", 0222, NULL, &preempt_tsg_file_ops); + // Create file `/proc/disable_channel`, world writable + disable_channel_entry = proc_create("disable_channel", 0222, NULL, &disable_channel_file_ops); + // Create file `/proc/enable_channel`, world writable + enable_channel_entry = proc_create("enable_channel", 0222, NULL, &enable_channel_file_ops); + // Create file `/proc/switch_to_tsg`, world writable + switch_to_tsg_entry = proc_create("switch_to_tsg", 0222, NULL, &switch_to_tsg_file_ops); + // ProcFS entry creation only fails if out of memory + if (!rl_entry || !preempt_entry || !disable_channel_entry || !enable_channel_entry || !switch_to_tsg_entry) { remove_proc_entry("runlist", NULL); + remove_proc_entry("preempt_tsg", NULL); + remove_proc_entry("disable_channel", NULL); + remove_proc_entry("enable_channel", NULL); + remove_proc_entry("switch_to_tsg", NULL); printk(KERN_ERR "[nvdebug] Unable to initialize procfs entries!\n"); return -ENOMEM; } @@ -34,6 +54,10 @@ int __init nvdebug_init(void) { static void __exit nvdebug_exit(void) { remove_proc_entry("runlist", NULL); + remove_proc_entry("preempt_tsg", NULL); + remove_proc_entry("disable_channel", NULL); + remove_proc_entry("enable_channel", NULL); + remove_proc_entry("switch_to_tsg", NULL); printk(KERN_INFO "[nvdebug] Exiting...\n"); } -- cgit v1.2.2