From b9d8f6a83a8e5fec38e9e20a54ee13838936fa10 Mon Sep 17 00:00:00 2001 From: Saman Sahebi Date: Thu, 14 Sep 2023 13:50:48 -0400 Subject: Created new read function in device_info for GRCE mappings and Pascal LCE mappings --- device_info_procfs.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'device_info_procfs.c') diff --git a/device_info_procfs.c b/device_info_procfs.c index b139c36..d5350c8 100644 --- a/device_info_procfs.c +++ b/device_info_procfs.c @@ -9,7 +9,7 @@ // @param off Requested offset. Updated by number of characters written. // @return -errno on error, otherwise number of bytes written to *buf // Note: Parent `data` field MUST be the GPU index -static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off) { +static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off){ char out[16]; int chars_written; struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; @@ -21,11 +21,40 @@ static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name); *off += chars_written; return chars_written; +} +static ssize_t nvdebug_read4_pascal(struct file *f, char __user *buf, size_t size, loff_t *off){ + char out[16]; + int chars_written; + struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; + void* data = PDE_DATA(file_inode(f)); + struct combo local_combo = *(struct combo*) &data; + + // 32 bit register will always take less than 16 characters to print + if (size < 16 || *off != 0) + return 0; + if (local_combo.index % 2 == 0) + chars_written = scnprintf(out, 16, "%#0x\n", (nvdebug_readl(g, local_combo.offset) & 0x0f)); + else + chars_written = scnprintf(out, 16, "%#0x\n", (nvdebug_readl(g, local_combo.offset) & 0xf0) >> 4); + if (copy_to_user(buf, out, chars_written)) + printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name); + *off += chars_written; + return chars_written; + +//(nvdebug_readl(g,NV_LCE_FOR_PCE_GP100(*(int*)PDE_DATA(file_inode(f)))) + + + } struct file_operations nvdebug_read_reg32_file_ops = { .read = nvdebug_reg32_read, .llseek = default_llseek, }; +// File operation for reading 4 bits in 32 bit register (used for Pascal copy engine offsets) +struct file_operations nvdebug_read4_pascal_file_ops = { + .read = nvdebug_read4_pascal, + .llseek = default_llseek, +}; typedef struct { int idx; // Current index in the device_info table -- cgit v1.2.2