1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6 #include <linux/string_helpers.h> 7 8 #include <drm/drm_debugfs.h> 9 10 #include "xe_bo.h" 11 #include "xe_device.h" 12 #include "xe_debugfs.h" 13 #include "xe_gt_debugfs.h" 14 #include "xe_step.h" 15 16 #ifdef CONFIG_DRM_XE_DEBUG 17 #include "xe_bo_evict.h" 18 #include "xe_migrate.h" 19 #include "xe_vm.h" 20 #endif 21 22 static struct xe_device *node_to_xe(struct drm_info_node *node) 23 { 24 return to_xe_device(node->minor->dev); 25 } 26 27 static int info(struct seq_file *m, void *data) 28 { 29 struct xe_device *xe = node_to_xe(m->private); 30 struct drm_printer p = drm_seq_file_printer(m); 31 struct xe_gt *gt; 32 u8 id; 33 34 drm_printf(&p, "graphics_verx100 %d\n", xe->info.graphics_verx100); 35 drm_printf(&p, "media_verx100 %d\n", xe->info.media_verx100); 36 drm_printf(&p, "stepping G:%s M:%s D:%s B:%s\n", 37 xe_step_name(xe->info.step.graphics), 38 xe_step_name(xe->info.step.media), 39 xe_step_name(xe->info.step.display), 40 xe_step_name(xe->info.step.basedie)); 41 drm_printf(&p, "is_dgfx %s\n", str_yes_no(xe->info.is_dgfx)); 42 drm_printf(&p, "platform %d\n", xe->info.platform); 43 drm_printf(&p, "subplatform %d\n", 44 xe->info.subplatform > XE_SUBPLATFORM_NONE ? xe->info.subplatform : 0); 45 drm_printf(&p, "devid 0x%x\n", xe->info.devid); 46 drm_printf(&p, "revid %d\n", xe->info.revid); 47 drm_printf(&p, "tile_count %d\n", xe->info.tile_count); 48 drm_printf(&p, "vm_max_level %d\n", xe->info.vm_max_level); 49 drm_printf(&p, "enable_guc %s\n", str_yes_no(xe->info.enable_guc)); 50 drm_printf(&p, "supports_usm %s\n", str_yes_no(xe->info.supports_usm)); 51 drm_printf(&p, "has_flat_ccs %s\n", str_yes_no(xe->info.has_flat_ccs)); 52 for_each_gt(gt, xe, id) { 53 drm_printf(&p, "gt%d force wake %d\n", id, 54 xe_force_wake_ref(gt_to_fw(gt), XE_FW_GT)); 55 drm_printf(&p, "gt%d engine_mask 0x%llx\n", id, 56 gt->info.engine_mask); 57 } 58 59 return 0; 60 } 61 62 static const struct drm_info_list debugfs_list[] = { 63 {"info", info, 0}, 64 }; 65 66 static int forcewake_open(struct inode *inode, struct file *file) 67 { 68 struct xe_device *xe = inode->i_private; 69 struct xe_gt *gt; 70 u8 id; 71 72 for_each_gt(gt, xe, id) 73 XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL)); 74 75 return 0; 76 } 77 78 static int forcewake_release(struct inode *inode, struct file *file) 79 { 80 struct xe_device *xe = inode->i_private; 81 struct xe_gt *gt; 82 u8 id; 83 84 for_each_gt(gt, xe, id) 85 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); 86 87 return 0; 88 } 89 90 static const struct file_operations forcewake_all_fops = { 91 .owner = THIS_MODULE, 92 .open = forcewake_open, 93 .release = forcewake_release, 94 }; 95 96 void xe_debugfs_register(struct xe_device *xe) 97 { 98 struct ttm_device *bdev = &xe->ttm; 99 struct drm_minor *minor = xe->drm.primary; 100 struct dentry *root = minor->debugfs_root; 101 struct ttm_resource_manager *man; 102 struct xe_gt *gt; 103 u32 mem_type; 104 u8 id; 105 106 drm_debugfs_create_files(debugfs_list, 107 ARRAY_SIZE(debugfs_list), 108 root, minor); 109 110 debugfs_create_file("forcewake_all", 0400, root, xe, 111 &forcewake_all_fops); 112 113 for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) { 114 man = ttm_manager_type(bdev, mem_type); 115 116 if (man) { 117 char name[16]; 118 119 sprintf(name, "vram%d_mm", mem_type - XE_PL_VRAM0); 120 ttm_resource_manager_create_debugfs(man, root, name); 121 } 122 } 123 124 man = ttm_manager_type(bdev, XE_PL_TT); 125 ttm_resource_manager_create_debugfs(man, root, "gtt_mm"); 126 127 for_each_gt(gt, xe, id) 128 xe_gt_debugfs_register(gt); 129 } 130