From 51f808e092846a60ea6c88ea3a1d2e349c92977b Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Wed, 20 Sep 2023 13:09:17 -0400 Subject: Bug fixes and cleanup for new device_info logic - Update comments to match new structure - Make show() function idempotent - Skip empty table entries without aborting - Include names for new engine types - Add warning log messages for skipped table entries - Remove non-functional runlist file creation logic for Ampere+ --- nvdebug_entry.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'nvdebug_entry.c') diff --git a/nvdebug_entry.c b/nvdebug_entry.c index cae5aea..0754f12 100644 --- a/nvdebug_entry.c +++ b/nvdebug_entry.c @@ -138,8 +138,8 @@ int probe_and_cache_device(void) { } // Create files `/proc/gpu#/runlist#`, world readable -int create_runlist_files_previous(int device_id, struct proc_dir_entry *dir) { - ptop_device_info_previous_t info; +int create_runlist_files(int device_id, struct proc_dir_entry *dir) { + ptop_device_info_gk104_t info; struct proc_dir_entry *rl_entry; int i, rl_id; char runlist_name[12]; @@ -147,8 +147,8 @@ int create_runlist_files_previous(int device_id, struct proc_dir_entry *dir) { // Figure out how many runlists there are by checking the device info // registers. Runlists are always numbered sequentially, so we just have // to find the highest-valued one and add 1 to get the number of runlists. - for (i = 0; i < NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS; i++) { - info.raw = nvdebug_readl(&g_nvdebug_state[device_id], NV_PTOP_DEVICE_INFO_PREVIOUS(i)); + for (i = 0; i < NV_PTOP_DEVICE_INFO__SIZE_1_GK104; i++) { + info.raw = nvdebug_readl(&g_nvdebug_state[device_id], NV_PTOP_DEVICE_INFO_GK104(i)); if (info.info_type != INFO_TYPE_ENUM || !info.runlist_is_valid) continue; if (info.runlist_enum > max_rl_id) @@ -167,34 +167,6 @@ int create_runlist_files_previous(int device_id, struct proc_dir_entry *dir) { return 0; } -// Create files `/proc/gpu#/runlist#`, world readable -int create_runlist_files_ampere(int device_id, struct proc_dir_entry *dir) { - ptop_device_info_ampere_t info; - struct proc_dir_entry *rl_entry; - int i, rl_id; - char runlist_name[12]; - int max_rl_id = 0; // Always at least one runlist - // Figure out how many runlists there are by checking the device info - // registers. Runlists are always numbered sequentially, so we just have - // to find the highest-valued one and add 1 to get the number of runlists. - for (i = 0; i < NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(&g_nvdebug_state[device_id]); i++) { - info.raw = nvdebug_readl(&g_nvdebug_state[device_id], NV_PTOP_DEVICE_INFO_AMPERE(i)); - if (info.runlist_enum > max_rl_id) - max_rl_id = info.runlist_enum; - } - // 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 <= 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), - (void*)(uintptr_t)rl_id); - if (!rl_entry) - return -ENOMEM; - } - return 0; -} - // Create files /proc/gpu# // TODO: Don't run this on unsupported GPUs int create_tpc_mask_files(int device_id, struct proc_dir_entry *dir) { @@ -240,7 +212,8 @@ 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); + if (g_nvdebug_state[device_id].chip_id < NV_CHIP_ID_AMPERE) + create_runlist_files(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