aboutsummaryrefslogtreecommitdiffstats
path: root/device_info_procfs.c
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2024-04-11 13:42:54 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2024-04-11 13:42:54 -0400
commit7cfa24cebeaf144b446d07e15fb25e78bb14841e (patch)
tree639db3695c54a1e50b3f10e1abb2bfaf5b8dd906 /device_info_procfs.c
parenta8fd5a8dee066d0008e7667b0c9e6a60cd5f3a2e (diff)
Linux 5.17+ support and allow including nvdebug.h independently
- Move Linux-specific functions to nvdebug_linux.h and .c - Workaround PDE_DATA() being pde_data() on Linux 5.17+
Diffstat (limited to 'device_info_procfs.c')
-rw-r--r--device_info_procfs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/device_info_procfs.c b/device_info_procfs.c
index 168905f..8fe9709 100644
--- a/device_info_procfs.c
+++ b/device_info_procfs.c
@@ -1,4 +1,4 @@
1#include "nvdebug.h" 1#include "nvdebug_linux.h"
2#include <linux/seq_file.h> // For seq_* functions and types 2#include <linux/seq_file.h> // For seq_* functions and types
3#include <linux/uaccess.h> // For copy_to_user() 3#include <linux/uaccess.h> // For copy_to_user()
4 4
@@ -16,7 +16,7 @@ static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size,
16 if (size < 16 || *off != 0) 16 if (size < 16 || *off != 0)
17 return 0; 17 return 0;
18 // 32 bit register will always take less than 16 characters to print 18 // 32 bit register will always take less than 16 characters to print
19 chars_written = scnprintf(out, 16, "%#0x\n", nvdebug_readl(g, (uintptr_t)PDE_DATA(file_inode(f)))); 19 chars_written = scnprintf(out, 16, "%#0x\n", nvdebug_readl(g, (uintptr_t)pde_data(file_inode(f))));
20 if (copy_to_user(buf, out, chars_written)) 20 if (copy_to_user(buf, out, chars_written))
21 printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name); 21 printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name);
22 *off += chars_written; 22 *off += chars_written;
@@ -30,7 +30,7 @@ static ssize_t nvdebug_reg_range_read(struct file *f, char __user *buf, size_t s
30 struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; 30 struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)];
31 // See comment in nvdebug_entry.c to understand `union reg_range` 31 // See comment in nvdebug_entry.c to understand `union reg_range`
32 union reg_range range; 32 union reg_range range;
33 range.raw = (uintptr_t)PDE_DATA(file_inode(f)); 33 range.raw = (uintptr_t)pde_data(file_inode(f));
34 34
35 // "0x" + up to 32-bit register as hex + "\n\0" is at most 12 characters 35 // "0x" + up to 32-bit register as hex + "\n\0" is at most 12 characters
36 if (size < 12 || *off != 0) 36 if (size < 12 || *off != 0)
@@ -55,7 +55,7 @@ struct file_operations nvdebug_read_reg32_file_ops = {
55}; 55};
56 56
57// Generic mechanism used for printing a subset of bits from a register 57// Generic mechanism used for printing a subset of bits from a register
58// Please store a `union reg_range` rather than a `uintptr_t` in the PDE_DATA 58// Please store a `union reg_range` rather than a `uintptr_t` in the pde_data
59struct file_operations nvdebug_read_reg_range_file_ops = { 59struct file_operations nvdebug_read_reg_range_file_ops = {
60 .read = nvdebug_reg_range_read, 60 .read = nvdebug_reg_range_read,
61 .llseek = default_llseek, 61 .llseek = default_llseek,