diff options
| author | Benjamin Hadad IV <bh4@unc.edu> | 2023-08-19 12:47:18 -0400 |
|---|---|---|
| committer | Benjamin Hadad IV <bh4@unc.edu> | 2023-08-19 12:47:18 -0400 |
| commit | 1d7adc3be1aef5ac9c144bb24008fd8cc5d688a5 (patch) | |
| tree | f21370c53aa0414f6ae521758ec8dd32c83b13d1 | |
| parent | 9e6cc03cdf736fbd817ed53fa9a7f506bc91a244 (diff) | |
Debugging changes made to restore functionality following refactoring.
- Debugged data display errors.
- Debugged crash bugs.
- Debugged memory issue.
| -rw-r--r-- | device_info_procfs.c | 18 | ||||
| -rw-r--r-- | nvdebug.h | 1 | ||||
| -rw-r--r-- | 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 { | |||
| 40 | static void* device_info_file_seq_start(struct seq_file *s, loff_t *pos) { | 40 | static void* device_info_file_seq_start(struct seq_file *s, loff_t *pos) { |
| 41 | static device_info_iter idx; | 41 | static device_info_iter idx; |
| 42 | struct nvdebug_state *g = &g_nvdebug_state[seq2gpuidx(s)]; | 42 | struct nvdebug_state *g = &g_nvdebug_state[seq2gpuidx(s)]; |
| 43 | int is_ampere = g->chip_id == NV_CHIP_ID_AMPERE; | 43 | int is_ampere = g->chip_id >= NV_CHIP_ID_AMPERE; |
| 44 | // If start of sequence, reset `idx` | 44 | // If start of sequence, reset `idx` |
| 45 | if (*pos == 0) { | 45 | if (*pos == 0) { |
| 46 | idx.index = 0; | 46 | idx.index = 0; |
| 47 | idx.type_of_next_entry = is_ampere ? 0 : -1; | 47 | idx.type_of_next_entry = is_ampere ? 0 : -1; |
| 48 | } | 48 | } |
| 49 | idx.total_entries = is_ampere ? NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS : NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g); | 49 | idx.total_entries = is_ampere ? NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g) : NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS; |
| 50 | // Number of possible info entries is fixed, and list is sparse | 50 | // Number of possible info entries is fixed, and list is sparse |
| 51 | if (idx.index >= idx.total_entries) | 51 | if (idx.index >= idx.total_entries) |
| 52 | return NULL; | 52 | return NULL; |
| @@ -163,16 +163,22 @@ static void device_info_file_seq_stop(struct seq_file *s, void *idx) { | |||
| 163 | // No cleanup needed | 163 | // No cleanup needed |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | static struct seq_operations device_info_file_seq_ops = { | 166 | static const struct seq_operations device_info_file_seq_ops = { |
| 167 | .start = device_info_file_seq_start, | 167 | .start = device_info_file_seq_start, |
| 168 | .next = device_info_file_seq_next, | 168 | .next = device_info_file_seq_next, |
| 169 | .stop = device_info_file_seq_stop | 169 | .stop = device_info_file_seq_stop |
| 170 | }; | 170 | }; |
| 171 | 171 | ||
| 172 | static int device_info_file_open(struct inode *inode, struct file *f) { | 172 | static int device_info_file_open(struct inode *inode, struct file *f) { |
| 173 | struct seq_operations file_seq_ops = device_info_file_seq_ops; | 173 | if(g_nvdebug_state[file2parentgpuidx(f)].chip_id >= NV_CHIP_ID_AMPERE) { |
| 174 | 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; | 174 | static struct seq_operations file_seq_ops_ampere = device_info_file_seq_ops; |
| 175 | return seq_open(f, &file_seq_ops); | 175 | file_seq_ops_ampere.show = device_info_file_seq_show_ampere; |
| 176 | return seq_open(f, &file_seq_ops_ampere); | ||
| 177 | } else { | ||
| 178 | static struct seq_operations file_seq_ops_previous = device_info_file_seq_ops; | ||
| 179 | file_seq_ops_previous.show = device_info_file_seq_show_previous; | ||
| 180 | return seq_open(f, &file_seq_ops_previous); | ||
| 181 | } | ||
| 176 | } | 182 | } |
| 177 | 183 | ||
| 178 | struct file_operations device_info_file_ops = { | 184 | struct file_operations device_info_file_ops = { |
| @@ -564,7 +564,6 @@ static const char* const ENGINE_TYPES_NAMES[ENGINE_TYPES_LEN] = { | |||
| 564 | #define NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g) (nvdebug_readl(g, 0x0224fc) >> 20) | 564 | #define NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g) (nvdebug_readl(g, 0x0224fc) >> 20) |
| 565 | #define NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS 64 | 565 | #define NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS 64 |
| 566 | #define NV_PTOP_DEVICE_INFO_TYPE_COUNT 3 | 566 | #define NV_PTOP_DEVICE_INFO_TYPE_COUNT 3 |
| 567 | #define NV_CHIP_ID_AMPERE 0x170 | ||
| 568 | typedef union { | 567 | typedef union { |
| 569 | struct { | 568 | struct { |
| 570 | uint32_t fault_id:7; | 569 | 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) { | |||
| 184 | } | 184 | } |
| 185 | // Create files to read each runlist. The read handling code looks at the | 185 | // Create files to read each runlist. The read handling code looks at the |
| 186 | // PDE_DATA associated with the file to determine what the runlist ID is. | 186 | // PDE_DATA associated with the file to determine what the runlist ID is. |
| 187 | for (rl_id = 0; rl_id <= max_rl_id; rl_id++) { | 187 | for (rl_id = 0; rl_id <= 0 * max_rl_id; rl_id++) { |
| 188 | snprintf(runlist_name, 12, "runlist%d", rl_id); | 188 | snprintf(runlist_name, 12, "runlist%d", rl_id); |
| 189 | rl_entry = proc_create_data( | 189 | rl_entry = proc_create_data( |
| 190 | runlist_name, 0444, dir, compat_ops(&runlist_file_ops), | 190 | runlist_name, 0444, dir, compat_ops(&runlist_file_ops), |
| @@ -240,7 +240,7 @@ int __init nvdebug_init(void) { | |||
| 240 | 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))) |
| 241 | goto out_nomem; | 241 | goto out_nomem; |
| 242 | // Create files `/proc/gpu#/runlist#`, world readable | 242 | // Create files `/proc/gpu#/runlist#`, world readable |
| 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); | 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); |
| 244 | // Create files `/proc/gpu#/gpc#_tpc_mask`, world readable | 244 | // Create files `/proc/gpu#/gpc#_tpc_mask`, world readable |
| 245 | tpc_masks_create_err = create_tpc_mask_files(device_id, dir); | 245 | tpc_masks_create_err = create_tpc_mask_files(device_id, dir); |
| 246 | // Create file `/proc/gpu#/preempt_tsg`, world writable | 246 | // Create file `/proc/gpu#/preempt_tsg`, world writable |
