diff options
Diffstat (limited to 'nvdebug_entry.c')
| -rw-r--r-- | nvdebug_entry.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/nvdebug_entry.c b/nvdebug_entry.c new file mode 100644 index 0000000..148bd3f --- /dev/null +++ b/nvdebug_entry.c | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | /* Copyright 2021 Joshua Bakita | ||
| 2 | * SPDX-License-Identifier: MIT | ||
| 3 | */ | ||
| 4 | |||
| 5 | /* TODO | ||
| 6 | * - Add sysfs trigger for a preemption | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <linux/kernel.h> | ||
| 10 | #include <linux/module.h> | ||
| 11 | #include <linux/proc_fs.h> // So we can set up entries in /proc | ||
| 12 | |||
| 13 | #include "nvdebug.h" | ||
| 14 | |||
| 15 | // LIAR. But without this we can't use GPL-only exported symbols like | ||
| 16 | // platform_bus_type or bus_find_device_by_name... | ||
| 17 | MODULE_LICENSE("GPL"); | ||
| 18 | MODULE_AUTHOR("Joshua Bakita"); | ||
| 19 | MODULE_DESCRIPTION("A scheduling debugging module for NVIDIA GPUs"); | ||
| 20 | MODULE_SOFTDEP("pre: nvgpu"); // We only support the Jetson boards for now | ||
| 21 | |||
| 22 | extern const struct file_operations runlist_file_ops; | ||
| 23 | |||
| 24 | int __init nvdebug_init(void) { | ||
| 25 | struct proc_dir_entry *entry = proc_create("runlist", 0444, NULL, &runlist_file_ops); | ||
| 26 | if (!entry) { | ||
| 27 | remove_proc_entry("runlist", NULL); | ||
| 28 | printk(KERN_ERR "[nvdebug] Unable to initialize procfs entries!\n"); | ||
| 29 | return -ENOMEM; | ||
| 30 | } | ||
| 31 | return 0; | ||
| 32 | } | ||
| 33 | |||
| 34 | static void __exit nvdebug_exit(void) { | ||
| 35 | remove_proc_entry("runlist", NULL); | ||
| 36 | printk(KERN_INFO "[nvdebug] Exiting...\n"); | ||
| 37 | } | ||
| 38 | |||
| 39 | module_init(nvdebug_init); | ||
| 40 | module_exit(nvdebug_exit); | ||
