From b9d8f6a83a8e5fec38e9e20a54ee13838936fa10 Mon Sep 17 00:00:00 2001 From: Saman Sahebi Date: Thu, 14 Sep 2023 13:50:48 -0400 Subject: Created new read function in device_info for GRCE mappings and Pascal LCE mappings --- nvdebug_entry.c | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'nvdebug_entry.c') diff --git a/nvdebug_entry.c b/nvdebug_entry.c index d355151..3815e06 100644 --- a/nvdebug_entry.c +++ b/nvdebug_entry.c @@ -28,7 +28,7 @@ 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; extern struct file_operations nvdebug_read_reg32_file_ops; - +extern struct file_operations nvdebug_read4_pascal_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]; @@ -261,23 +261,27 @@ int __init nvdebug_init(void) { (void*)NV_FUSE_GPC); // In both nouveau and nvgpu, the PCE_MAP register is available on Pascal+ if (g_nvdebug_state[res].chip_id >= NV_CHIP_ID_PASCAL){ - + // Declare struct for storing pce index and offset + struct combo local_combo; + struct combo* local_combo_ptr = &local_combo; // Create a pce mask for iteration u32 ce_pce_map = nvdebug_readl(&g_nvdebug_state[device_id], NV_CE_PCE_MAP); - u32 num_pce = U32(hweight32(ce_pce_map)); char file_name[20]; - int pce_id; + int pce_id = 0; int i; - for (i = 0; pce_id = 0; pce_id < num_pce; i < MAP_SIZE; i++){ + for (i = 0; i < MAP_SIZE; i++){ // If pce is enabled, create files and iterate pce_id; otherwise, do nothing if ((1 << i) & ce_pce_map){ snprintf(file_name, 20, "lce_for_pce%d",pce_id); - switch (g_nvdebug_state[res].chip_id){ + // Depending on GPU architecture, fetch data for the LCE of particular PCE + switch (g_nvdebug_state[res].chip_id & 0xff0){ case NV_CHIP_ID_PASCAL: + local_combo.offset = NV_LCE_FOR_PCE_GP100(pce_id); + local_combo.index = pce_id; lce_for_pce_entry = proc_create_data( - file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops), - (void*)(uintptr_t)NV_LCE_FOR_PCE_GP100(pce_id)); + file_name, 0444, dir, compat_ops(&nvdebug_read4_pascal_file_ops), + *(void**)local_combo_ptr); break; case NV_CHIP_ID_VOLTA: lce_for_pce_entry = proc_create_data( @@ -289,16 +293,28 @@ int __init nvdebug_init(void) { file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops), (void*)(uintptr_t)NV_LCE_FOR_PCE_GA100(pce_id)); break; + case NV_CHIP_ID_TURING: + lce_for_pce_entry = proc_create_data( + file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops), + (void*)(uintptr_t)NV_LCE_FOR_PCE_TU104(pce_id)); + break; + + } + // Make 2 files for 2 GRCEs + if (pce_id < NV_GRCE_NUM){ + local_combo.offset = NV_GRCE_FOR_CE(pce_id); + local_combo.index = 0; + snprintf(file_name, 20, "pce_for_grce%d",pce_id); + grce_for_pce_entry = proc_create_data( + file_name, 0444, dir, compat_ops(&nvdebug_read4_pascal_file_ops), + *(void**)local_combo_ptr); } - snprintf(file_name, 20, "grce_for_pce%d",pce_id); - grce_for_pce_entry = proc_create_data( - file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops), - (void*)(uintptr_t)NV_GRCE_FOR_CE(pce_id)); if (!lce_for_pce_entry || !grce_for_pce_entry) return -ENOMEM; - pce_id++ - } - } + pce_id++; + + } + } // TODO: Redo to num_pces num_gpcs_entry = proc_create_data( -- cgit v1.2.2