Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 147 lines 4.5 kB view raw
1// SPDX-License-Identifier: MIT 2/* 3 * Copyright © 2025 Intel Corporation 4 */ 5 6#include <linux/debugfs.h> 7#include <drm/drm_debugfs.h> 8 9#include "xe_ggtt.h" 10#include "xe_pm.h" 11#include "xe_sa.h" 12#include "xe_tile_debugfs.h" 13 14static struct xe_tile *node_to_tile(struct drm_info_node *node) 15{ 16 return node->dent->d_parent->d_inode->i_private; 17} 18 19/** 20 * xe_tile_debugfs_simple_show() - A show callback for struct drm_info_list 21 * @m: the &seq_file 22 * @data: data used by the drm debugfs helpers 23 * 24 * This callback can be used in struct drm_info_list to describe debugfs 25 * files that are &xe_tile specific. 26 * 27 * It is assumed that those debugfs files will be created on directory entry 28 * which struct dentry d_inode->i_private points to &xe_tile. 29 * 30 * /sys/kernel/debug/dri/0/ 31 * ├── tile0/ # tile = dentry->d_inode->i_private 32 * │ │ ├── id # tile = dentry->d_parent->d_inode->i_private 33 * 34 * This function assumes that &m->private will be set to the &struct 35 * drm_info_node corresponding to the instance of the info on a given &struct 36 * drm_minor (see struct drm_info_list.show for details). 37 * 38 * This function also assumes that struct drm_info_list.data will point to the 39 * function code that will actually print a file content:: 40 * 41 * int (*print)(struct xe_tile *, struct drm_printer *) 42 * 43 * Example:: 44 * 45 * int tile_id(struct xe_tile *tile, struct drm_printer *p) 46 * { 47 * drm_printf(p, "%u\n", tile->id); 48 * return 0; 49 * } 50 * 51 * static const struct drm_info_list info[] = { 52 * { name = "id", .show = tile_debugfs_simple_show, .data = tile_id }, 53 * }; 54 * 55 * dir = debugfs_create_dir("tile0", parent); 56 * dir->d_inode->i_private = tile; 57 * drm_debugfs_create_files(info, ARRAY_SIZE(info), dir, minor); 58 * 59 * Return: 0 on success or a negative error code on failure. 60 */ 61int xe_tile_debugfs_simple_show(struct seq_file *m, void *data) 62{ 63 struct drm_printer p = drm_seq_file_printer(m); 64 struct drm_info_node *node = m->private; 65 struct xe_tile *tile = node_to_tile(node); 66 int (*print)(struct xe_tile *, struct drm_printer *) = node->info_ent->data; 67 68 return print(tile, &p); 69} 70 71/** 72 * xe_tile_debugfs_show_with_rpm() - A show callback for struct drm_info_list 73 * @m: the &seq_file 74 * @data: data used by the drm debugfs helpers 75 * 76 * Similar to tile_debugfs_simple_show() but implicitly takes a RPM ref. 77 * 78 * Return: 0 on success or a negative error code on failure. 79 */ 80int xe_tile_debugfs_show_with_rpm(struct seq_file *m, void *data) 81{ 82 struct drm_info_node *node = m->private; 83 struct xe_tile *tile = node_to_tile(node); 84 struct xe_device *xe = tile_to_xe(tile); 85 86 guard(xe_pm_runtime)(xe); 87 return xe_tile_debugfs_simple_show(m, data); 88} 89 90static int ggtt(struct xe_tile *tile, struct drm_printer *p) 91{ 92 return xe_ggtt_dump(tile->mem.ggtt, p); 93} 94 95static int sa_info(struct xe_tile *tile, struct drm_printer *p) 96{ 97 drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p, 98 xe_sa_manager_gpu_addr(tile->mem.kernel_bb_pool)); 99 100 return 0; 101} 102 103/* only for debugfs files which can be safely used on the VF */ 104static const struct drm_info_list vf_safe_debugfs_list[] = { 105 { "ggtt", .show = xe_tile_debugfs_show_with_rpm, .data = ggtt }, 106 { "sa_info", .show = xe_tile_debugfs_show_with_rpm, .data = sa_info }, 107}; 108 109static void tile_debugfs_create_vram_mm(struct xe_tile *tile) 110{ 111 if (tile->mem.vram) 112 ttm_resource_manager_create_debugfs(&tile->mem.vram->ttm.manager, tile->debugfs, 113 "vram_mm"); 114} 115 116/** 117 * xe_tile_debugfs_register - Register tile's debugfs attributes 118 * @tile: the &xe_tile to register 119 * 120 * Create debugfs sub-directory with a name that includes a tile ID and 121 * then creates set of debugfs files (attributes) specific to this tile. 122 */ 123void xe_tile_debugfs_register(struct xe_tile *tile) 124{ 125 struct xe_device *xe = tile_to_xe(tile); 126 struct drm_minor *minor = xe->drm.primary; 127 struct dentry *root = minor->debugfs_root; 128 char name[8]; 129 130 snprintf(name, sizeof(name), "tile%u", tile->id); 131 tile->debugfs = debugfs_create_dir(name, root); 132 if (IS_ERR(tile->debugfs)) 133 return; 134 135 /* 136 * Store the xe_tile pointer as private data of the tile/ directory 137 * node so other tile specific attributes under that directory may 138 * refer to it by looking at its parent node private data. 139 */ 140 tile->debugfs->d_inode->i_private = tile; 141 142 drm_debugfs_create_files(vf_safe_debugfs_list, 143 ARRAY_SIZE(vf_safe_debugfs_list), 144 tile->debugfs, minor); 145 146 tile_debugfs_create_vram_mm(tile); 147}