aboutsummaryrefslogtreecommitdiffstats
path: root/device_info_procfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'device_info_procfs.c')
-rw-r--r--device_info_procfs.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/device_info_procfs.c b/device_info_procfs.c
index 8fe9709..c8903fc 100644
--- a/device_info_procfs.c
+++ b/device_info_procfs.c
@@ -61,6 +61,30 @@ struct file_operations nvdebug_read_reg_range_file_ops = {
61 .llseek = default_llseek, 61 .llseek = default_llseek,
62}; 62};
63 63
64static ssize_t local_memory_read(struct file *f, char __user *buf, size_t size, loff_t *off) {
65 struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)];
66 char out[30];
67 int chars_written;
68 memory_range_t mem_range;
69 if (size < 30 || *off != 0)
70 return 0;
71 mem_range.raw = nvdebug_readl(g, NV_FB_MMU_LOCAL_MEMORY_RANGE);
72 if (mem_range.raw == -1)
73 return -EIO;
74 // 64-bit size has at most 19 characters + 8 for text and termination
75 chars_written = scnprintf(out, 30, "%lld bytes\n", memory_range_to_bytes(mem_range));
76 if (copy_to_user(buf, out, chars_written))
77 printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name);
78 *off += chars_written;
79 return chars_written;
80}
81
82// Read out size of on-device VRAM
83struct file_operations local_memory_file_ops = {
84 .read = local_memory_read,
85 .llseek = default_llseek,
86};
87
64typedef struct { 88typedef struct {
65 int idx; // Current index in the device_info table 89 int idx; // Current index in the device_info table
66 int length; // Length of device_info table (including unpopulated entries) 90 int length; // Length of device_info table (including unpopulated entries)