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 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'device_info_procfs.c') 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 = { -- cgit v1.2.2