aboutsummaryrefslogtreecommitdiffstats
path: root/nvdebug_entry.c
diff options
context:
space:
mode:
authorBenjamin Hadad IV <bh4@unc.edu>2023-08-16 22:00:20 -0400
committerBenjamin Hadad IV <bh4@unc.edu>2023-08-16 22:00:20 -0400
commit9e6cc03cdf736fbd817ed53fa9a7f506bc91a244 (patch)
tree9a40dacb60282939a979377bfa605556ef64c04f /nvdebug_entry.c
parent845960fc1b15995fdbd6d61c384567652a150bc4 (diff)
A variety of changes have been made as part of the code review.
- Functions have been consolidated. - Code was clarified and tidied up overall. - Unnecessary elements were removed.
Diffstat (limited to 'nvdebug_entry.c')
-rw-r--r--nvdebug_entry.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/nvdebug_entry.c b/nvdebug_entry.c
index d3d934e..0560ead 100644
--- a/nvdebug_entry.c
+++ b/nvdebug_entry.c
@@ -23,14 +23,12 @@ extern struct file_operations preempt_tsg_file_ops;
23extern struct file_operations disable_channel_file_ops; 23extern struct file_operations disable_channel_file_ops;
24extern struct file_operations enable_channel_file_ops; 24extern struct file_operations enable_channel_file_ops;
25extern struct file_operations switch_to_tsg_file_ops; 25extern struct file_operations switch_to_tsg_file_ops;
26extern struct file_operations device_info_file_ops_previous; 26extern struct file_operations device_info_file_ops;
27extern struct file_operations device_info_file_ops_ampere;
28extern struct file_operations nvdebug_read_reg32_file_ops; 27extern struct file_operations nvdebug_read_reg32_file_ops;
29 28
30// Bus types are global symbols in the kernel 29// Bus types are global symbols in the kernel
31extern struct bus_type platform_bus_type; 30extern struct bus_type platform_bus_type;
32struct nvdebug_state g_nvdebug_state[NVDEBUG_MAX_DEVICES]; 31struct nvdebug_state g_nvdebug_state[NVDEBUG_MAX_DEVICES];
33int g_architectures[NVDEBUG_MAX_DEVICES];
34unsigned int g_nvdebug_devices = 0; 32unsigned int g_nvdebug_devices = 0;
35 33
36// Starting in Kernel 5.6, proc_ops is required instead of file_operations 34// Starting in Kernel 5.6, proc_ops is required instead of file_operations
@@ -125,7 +123,6 @@ int probe_and_cache_device(void) {
125 return -EADDRNOTAVAIL; 123 return -EADDRNOTAVAIL;
126 } 124 }
127 g_nvdebug_state[i].chip_id = ids.chip_id; 125 g_nvdebug_state[i].chip_id = ids.chip_id;
128 g_architectures[i] = ids.architecture;
129 printk(KERN_INFO "[nvdebug] Chip ID %x (architecture %s) detected on PCI bus and initialized.", 126 printk(KERN_INFO "[nvdebug] Chip ID %x (architecture %s) detected on PCI bus and initialized.",
130 ids.chip_id, ARCH2NAME(ids.architecture)); 127 ids.chip_id, ARCH2NAME(ids.architecture));
131 // TEMP 128 // TEMP
@@ -243,7 +240,7 @@ int __init nvdebug_init(void) {
243 if (!(dir = proc_mkdir_data(device_id_str, 0555, NULL, (void*)device_id))) 240 if (!(dir = proc_mkdir_data(device_id_str, 0555, NULL, (void*)device_id)))
244 goto out_nomem; 241 goto out_nomem;
245 // Create files `/proc/gpu#/runlist#`, world readable 242 // Create files `/proc/gpu#/runlist#`, world readable
246 rl_create_err = g_architectures[device_id] == 0x17 ? create_runlist_files_ampere(device_id, dir) : create_runlist_files_previous(device_id, dir); 243 rl_create_err = (g_nvdebug_state[device_id].chip_id == NV_CHIP_ID_AMPERE) ? create_runlist_files_ampere(device_id, dir) : create_runlist_files_previous(device_id, dir);
247 // Create files `/proc/gpu#/gpc#_tpc_mask`, world readable 244 // Create files `/proc/gpu#/gpc#_tpc_mask`, world readable
248 tpc_masks_create_err = create_tpc_mask_files(device_id, dir); 245 tpc_masks_create_err = create_tpc_mask_files(device_id, dir);
249 // Create file `/proc/gpu#/preempt_tsg`, world writable 246 // Create file `/proc/gpu#/preempt_tsg`, world writable
@@ -264,7 +261,7 @@ int __init nvdebug_init(void) {
264 (void*)device_id); 261 (void*)device_id);
265 // Create file `/proc/gpu#/device_info`, world readable 262 // Create file `/proc/gpu#/device_info`, world readable
266 device_info_entry = proc_create_data( 263 device_info_entry = proc_create_data(
267 "device_info", 0444, dir, compat_ops(g_architectures[device_id] == 0x17 ? &device_info_file_ops_previous : &device_info_file_ops_ampere), 264 "device_info", 0444, dir, compat_ops(&device_info_file_ops),
268 (void*)device_id); 265 (void*)device_id);
269 // Create file `/proc/gpu#/num_gpcs`, world readable 266 // Create file `/proc/gpu#/num_gpcs`, world readable
270 num_gpcs_entry = proc_create_data( 267 num_gpcs_entry = proc_create_data(