]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/xe: Move debugfs GT attributes under tile directory
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 14 Jul 2025 19:36:45 +0000 (21:36 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 16 Jul 2025 15:24:00 +0000 (17:24 +0200)
While in sysfs we are correctly trying to reflect the hardware
architecture and we expose GT attributes in per tile hierarchy,
in debugfs we expose GT attributes at flat level, without tiles.

Create debugfs directories to represent each tile and move GT
attributes under matching parent tile directory. To not break
existing debugfs tools, create symlink under old location:

 /sys/kernel/debug/dri/0000:00:02.0/
 ├── ...
 ├── gt0 -> tile0/gt0
 ├── gt1 -> tile0/gt1
 ├── tile0
 │   ├── gt0
 │   │   ├── ...
 │   ├── gt1
 │   │   ├── ...

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250714193645.763-1-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_debugfs.c
drivers/gpu/drm/xe/xe_device_types.h
drivers/gpu/drm/xe/xe_gt_debugfs.c

index 26e9d146ccbf6d8a6400e195b4797009c2a3740d..129186f4193bd2cc4af59a27e83737bc4415579e 100644 (file)
@@ -247,14 +247,33 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = {
        .write = atomic_svm_timeslice_ms_set,
 };
 
+static void create_tile_debugfs(struct xe_tile *tile, struct dentry *root)
+{
+       char name[8];
+
+       snprintf(name, sizeof(name), "tile%u", tile->id);
+       tile->debugfs = debugfs_create_dir(name, root);
+       if (IS_ERR(tile->debugfs))
+               return;
+
+       /*
+        * Store the xe_tile pointer as private data of the tile/ directory
+        * node so other tile specific attributes under that directory may
+        * refer to it by looking at its parent node private data.
+        */
+       tile->debugfs->d_inode->i_private = tile;
+}
+
 void xe_debugfs_register(struct xe_device *xe)
 {
        struct ttm_device *bdev = &xe->ttm;
        struct drm_minor *minor = xe->drm.primary;
        struct dentry *root = minor->debugfs_root;
        struct ttm_resource_manager *man;
+       struct xe_tile *tile;
        struct xe_gt *gt;
        u32 mem_type;
+       u8 tile_id;
        u8 id;
 
        drm_debugfs_create_files(debugfs_list,
@@ -288,6 +307,9 @@ void xe_debugfs_register(struct xe_device *xe)
        if (man)
                ttm_resource_manager_create_debugfs(man, root, "stolen_mm");
 
+       for_each_tile(tile, xe, tile_id)
+               create_tile_debugfs(tile, root);
+
        for_each_gt(gt, xe, id)
                xe_gt_debugfs_register(gt);
 
index d4d2c6854790cae8f4c2ebb2e3274d3d947b9516..98ce1255f1d060e813434c420404f40898c6e381 100644 (file)
@@ -255,6 +255,9 @@ struct xe_tile {
 
        /** @sysfs: sysfs' kobj used by xe_tile_sysfs */
        struct kobject *sysfs;
+
+       /** @debugfs: debugfs directory associated with this tile */
+       struct dentry *debugfs;
 };
 
 /**
index 848618acdca8dc4d971d824327523407fec307f2..061a81f82e76a7c3a2488e54700c707090b92f49 100644 (file)
@@ -388,13 +388,18 @@ void xe_gt_debugfs_register(struct xe_gt *gt)
 {
        struct xe_device *xe = gt_to_xe(gt);
        struct drm_minor *minor = gt_to_xe(gt)->drm.primary;
+       struct dentry *parent = gt->tile->debugfs;
        struct dentry *root;
+       char symlink[16];
        char name[8];
 
        xe_gt_assert(gt, minor->debugfs_root);
 
+       if (IS_ERR(parent))
+               return;
+
        snprintf(name, sizeof(name), "gt%d", gt->info.id);
-       root = debugfs_create_dir(name, minor->debugfs_root);
+       root = debugfs_create_dir(name, parent);
        if (IS_ERR(root)) {
                drm_warn(&xe->drm, "Create GT directory failed");
                return;
@@ -426,4 +431,11 @@ void xe_gt_debugfs_register(struct xe_gt *gt)
                xe_gt_sriov_pf_debugfs_register(gt, root);
        else if (IS_SRIOV_VF(xe))
                xe_gt_sriov_vf_debugfs_register(gt, root);
+
+       /*
+        * Backwards compatibility only: create a link for the legacy clients
+        * who may expect gt/ directory at the root level, not the tile level.
+        */
+       snprintf(symlink, sizeof(symlink), "tile%u/%s", gt->tile->id, name);
+       debugfs_create_symlink(name, minor->debugfs_root, symlink);
 }