aboutsummaryrefslogtreecommitdiffstats
path: root/nvdebug_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'nvdebug_entry.c')
-rw-r--r--nvdebug_entry.c46
1 files changed, 31 insertions, 15 deletions
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;
28extern struct file_operations switch_to_tsg_file_ops; 28extern struct file_operations switch_to_tsg_file_ops;
29extern struct file_operations device_info_file_ops; 29extern struct file_operations device_info_file_ops;
30extern struct file_operations nvdebug_read_reg32_file_ops; 30extern struct file_operations nvdebug_read_reg32_file_ops;
31 31extern struct file_operations nvdebug_read4_pascal_file_ops;
32// Bus types are global symbols in the kernel 32// Bus types are global symbols in the kernel
33extern struct bus_type platform_bus_type; 33extern struct bus_type platform_bus_type;
34struct nvdebug_state g_nvdebug_state[NVDEBUG_MAX_DEVICES]; 34struct nvdebug_state g_nvdebug_state[NVDEBUG_MAX_DEVICES];
@@ -261,23 +261,27 @@ int __init nvdebug_init(void) {
261 (void*)NV_FUSE_GPC); 261 (void*)NV_FUSE_GPC);
262 // In both nouveau and nvgpu, the PCE_MAP register is available on Pascal+ 262 // In both nouveau and nvgpu, the PCE_MAP register is available on Pascal+
263 if (g_nvdebug_state[res].chip_id >= NV_CHIP_ID_PASCAL){ 263 if (g_nvdebug_state[res].chip_id >= NV_CHIP_ID_PASCAL){
264 264 // Declare struct for storing pce index and offset
265 struct combo local_combo;
266 struct combo* local_combo_ptr = &local_combo;
265 // Create a pce mask for iteration 267 // Create a pce mask for iteration
266 u32 ce_pce_map = nvdebug_readl(&g_nvdebug_state[device_id], NV_CE_PCE_MAP); 268 u32 ce_pce_map = nvdebug_readl(&g_nvdebug_state[device_id], NV_CE_PCE_MAP);
267 u32 num_pce = U32(hweight32(ce_pce_map));
268 char file_name[20]; 269 char file_name[20];
269 int pce_id; 270 int pce_id = 0;
270 int i; 271 int i;
271 for (i = 0; pce_id = 0; pce_id < num_pce; i < MAP_SIZE; i++){ 272 for (i = 0; i < MAP_SIZE; i++){
272 // If pce is enabled, create files and iterate pce_id; otherwise, do nothing 273 // If pce is enabled, create files and iterate pce_id; otherwise, do nothing
273 if ((1 << i) & ce_pce_map){ 274 if ((1 << i) & ce_pce_map){
274 snprintf(file_name, 20, "lce_for_pce%d",pce_id); 275 snprintf(file_name, 20, "lce_for_pce%d",pce_id);
275 switch (g_nvdebug_state[res].chip_id){ 276 // Depending on GPU architecture, fetch data for the LCE of particular PCE
277 switch (g_nvdebug_state[res].chip_id & 0xff0){
276 278
277 case NV_CHIP_ID_PASCAL: 279 case NV_CHIP_ID_PASCAL:
280 local_combo.offset = NV_LCE_FOR_PCE_GP100(pce_id);
281 local_combo.index = pce_id;
278 lce_for_pce_entry = proc_create_data( 282 lce_for_pce_entry = proc_create_data(
279 file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops), 283 file_name, 0444, dir, compat_ops(&nvdebug_read4_pascal_file_ops),
280 (void*)(uintptr_t)NV_LCE_FOR_PCE_GP100(pce_id)); 284 *(void**)local_combo_ptr);
281 break; 285 break;
282 case NV_CHIP_ID_VOLTA: 286 case NV_CHIP_ID_VOLTA:
283 lce_for_pce_entry = proc_create_data( 287 lce_for_pce_entry = proc_create_data(
@@ -289,16 +293,28 @@ int __init nvdebug_init(void) {
289 file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops), 293 file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops),
290 (void*)(uintptr_t)NV_LCE_FOR_PCE_GA100(pce_id)); 294 (void*)(uintptr_t)NV_LCE_FOR_PCE_GA100(pce_id));
291 break; 295 break;
296 case NV_CHIP_ID_TURING:
297 lce_for_pce_entry = proc_create_data(
298 file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops),
299 (void*)(uintptr_t)NV_LCE_FOR_PCE_TU104(pce_id));
300 break;
301
302 }
303 // Make 2 files for 2 GRCEs
304 if (pce_id < NV_GRCE_NUM){
305 local_combo.offset = NV_GRCE_FOR_CE(pce_id);
306 local_combo.index = 0;
307 snprintf(file_name, 20, "pce_for_grce%d",pce_id);
308 grce_for_pce_entry = proc_create_data(
309 file_name, 0444, dir, compat_ops(&nvdebug_read4_pascal_file_ops),
310 *(void**)local_combo_ptr);
292 } 311 }
293 snprintf(file_name, 20, "grce_for_pce%d",pce_id);
294 grce_for_pce_entry = proc_create_data(
295 file_name, 0444, dir, compat_ops(&nvdebug_read_reg32_file_ops),
296 (void*)(uintptr_t)NV_GRCE_FOR_CE(pce_id));
297 if (!lce_for_pce_entry || !grce_for_pce_entry) 312 if (!lce_for_pce_entry || !grce_for_pce_entry)
298 return -ENOMEM; 313 return -ENOMEM;
299 pce_id++ 314 pce_id++;
300 } 315
301 } 316 }
317 }
302 318
303 // TODO: Redo to num_pces 319 // TODO: Redo to num_pces
304 num_gpcs_entry = proc_create_data( 320 num_gpcs_entry = proc_create_data(