From 9e6cc03cdf736fbd817ed53fa9a7f506bc91a244 Mon Sep 17 00:00:00 2001 From: Benjamin Hadad IV Date: Wed, 16 Aug 2023 22:00:20 -0400 Subject: 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. --- nvdebug_entry.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'nvdebug_entry.c') 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; extern struct file_operations disable_channel_file_ops; extern struct file_operations enable_channel_file_ops; extern struct file_operations switch_to_tsg_file_ops; -extern struct file_operations device_info_file_ops_previous; -extern struct file_operations device_info_file_ops_ampere; +extern struct file_operations device_info_file_ops; extern struct file_operations nvdebug_read_reg32_file_ops; // Bus types are global symbols in the kernel extern struct bus_type platform_bus_type; struct nvdebug_state g_nvdebug_state[NVDEBUG_MAX_DEVICES]; -int g_architectures[NVDEBUG_MAX_DEVICES]; unsigned int g_nvdebug_devices = 0; // Starting in Kernel 5.6, proc_ops is required instead of file_operations @@ -125,7 +123,6 @@ int probe_and_cache_device(void) { return -EADDRNOTAVAIL; } g_nvdebug_state[i].chip_id = ids.chip_id; - g_architectures[i] = ids.architecture; printk(KERN_INFO "[nvdebug] Chip ID %x (architecture %s) detected on PCI bus and initialized.", ids.chip_id, ARCH2NAME(ids.architecture)); // TEMP @@ -243,7 +240,7 @@ int __init nvdebug_init(void) { if (!(dir = proc_mkdir_data(device_id_str, 0555, NULL, (void*)device_id))) goto out_nomem; // Create files `/proc/gpu#/runlist#`, world readable - rl_create_err = g_architectures[device_id] == 0x17 ? create_runlist_files_ampere(device_id, dir) : create_runlist_files_previous(device_id, dir); + 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); // Create files `/proc/gpu#/gpc#_tpc_mask`, world readable tpc_masks_create_err = create_tpc_mask_files(device_id, dir); // Create file `/proc/gpu#/preempt_tsg`, world writable @@ -264,7 +261,7 @@ int __init nvdebug_init(void) { (void*)device_id); // Create file `/proc/gpu#/device_info`, world readable device_info_entry = proc_create_data( - "device_info", 0444, dir, compat_ops(g_architectures[device_id] == 0x17 ? &device_info_file_ops_previous : &device_info_file_ops_ampere), + "device_info", 0444, dir, compat_ops(&device_info_file_ops), (void*)device_id); // Create file `/proc/gpu#/num_gpcs`, world readable num_gpcs_entry = proc_create_data( -- cgit v1.2.2