From 1d7adc3be1aef5ac9c144bb24008fd8cc5d688a5 Mon Sep 17 00:00:00 2001 From: Benjamin Hadad IV Date: Sat, 19 Aug 2023 12:47:18 -0400 Subject: Debugging changes made to restore functionality following refactoring. - Debugged data display errors. - Debugged crash bugs. - Debugged memory issue. --- device_info_procfs.c | 18 ++++++++++++------ nvdebug.h | 1 - nvdebug_entry.c | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/device_info_procfs.c b/device_info_procfs.c index efef41a..b2bcd1a 100644 --- a/device_info_procfs.c +++ b/device_info_procfs.c @@ -40,13 +40,13 @@ typedef struct { static void* device_info_file_seq_start(struct seq_file *s, loff_t *pos) { static device_info_iter idx; struct nvdebug_state *g = &g_nvdebug_state[seq2gpuidx(s)]; - int is_ampere = g->chip_id == NV_CHIP_ID_AMPERE; + int is_ampere = g->chip_id >= NV_CHIP_ID_AMPERE; // If start of sequence, reset `idx` if (*pos == 0) { idx.index = 0; idx.type_of_next_entry = is_ampere ? 0 : -1; } - idx.total_entries = is_ampere ? NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS : NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g); + idx.total_entries = is_ampere ? NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g) : NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS; // Number of possible info entries is fixed, and list is sparse if (idx.index >= idx.total_entries) return NULL; @@ -163,16 +163,22 @@ static void device_info_file_seq_stop(struct seq_file *s, void *idx) { // No cleanup needed } -static struct seq_operations device_info_file_seq_ops = { +static const struct seq_operations device_info_file_seq_ops = { .start = device_info_file_seq_start, .next = device_info_file_seq_next, .stop = device_info_file_seq_stop }; static int device_info_file_open(struct inode *inode, struct file *f) { - struct seq_operations file_seq_ops = device_info_file_seq_ops; - file_seq_ops.show = (g_nvdebug_state[file2parentgpuidx(f)].chip_id == NV_CHIP_ID_AMPERE) ? device_info_file_seq_show_ampere : device_info_file_seq_show_previous; - return seq_open(f, &file_seq_ops); + if(g_nvdebug_state[file2parentgpuidx(f)].chip_id >= NV_CHIP_ID_AMPERE) { + static struct seq_operations file_seq_ops_ampere = device_info_file_seq_ops; + file_seq_ops_ampere.show = device_info_file_seq_show_ampere; + return seq_open(f, &file_seq_ops_ampere); + } else { + static struct seq_operations file_seq_ops_previous = device_info_file_seq_ops; + file_seq_ops_previous.show = device_info_file_seq_show_previous; + return seq_open(f, &file_seq_ops_previous); + } } struct file_operations device_info_file_ops = { diff --git a/nvdebug.h b/nvdebug.h index 471adf9..be718dd 100644 --- a/nvdebug.h +++ b/nvdebug.h @@ -564,7 +564,6 @@ static const char* const ENGINE_TYPES_NAMES[ENGINE_TYPES_LEN] = { #define NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g) (nvdebug_readl(g, 0x0224fc) >> 20) #define NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS 64 #define NV_PTOP_DEVICE_INFO_TYPE_COUNT 3 -#define NV_CHIP_ID_AMPERE 0x170 typedef union { struct { uint32_t fault_id:7; diff --git a/nvdebug_entry.c b/nvdebug_entry.c index 0560ead..cae5aea 100644 --- a/nvdebug_entry.c +++ b/nvdebug_entry.c @@ -184,7 +184,7 @@ int create_runlist_files_ampere(int device_id, struct proc_dir_entry *dir) { } // Create files to read each runlist. The read handling code looks at the // PDE_DATA associated with the file to determine what the runlist ID is. - for (rl_id = 0; rl_id <= max_rl_id; rl_id++) { + for (rl_id = 0; rl_id <= 0 * max_rl_id; rl_id++) { snprintf(runlist_name, 12, "runlist%d", rl_id); rl_entry = proc_create_data( runlist_name, 0444, dir, compat_ops(&runlist_file_ops), @@ -240,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_nvdebug_state[device_id].chip_id == NV_CHIP_ID_AMPERE) ? 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 -- cgit v1.2.2