]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/xe/debugfs: Move sa_info from gt to tile directory
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 29 Aug 2025 20:11:03 +0000 (22:11 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 4 Sep 2025 10:45:09 +0000 (12:45 +0200)
Our drm-based suballocator is implemented per-tile so it is better
to show its debug information also per-tile debugfs directory, not
under per-gt directory as it is done today.

To allow adding more per-tile attributes, prepare necessary helper
functions, like we already did for per-gt or per-uc attributes.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250829201106.1263-1-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/Makefile
drivers/gpu/drm/xe/xe_debugfs.c
drivers/gpu/drm/xe/xe_gt_debugfs.c
drivers/gpu/drm/xe/xe_tile_debugfs.c [new file with mode: 0644]
drivers/gpu/drm/xe/xe_tile_debugfs.h [new file with mode: 0644]

index 987e4fe105382f09af8c5a550cc70a40b69fbc48..95c0f0a9b40372a625f26044623fd026d54ea258 100644 (file)
@@ -325,6 +325,7 @@ ifeq ($(CONFIG_DEBUG_FS),y)
                xe_gt_stats.o \
                xe_guc_debugfs.o \
                xe_huc_debugfs.o \
+               xe_tile_debugfs.o \
                xe_uc_debugfs.o
 
        xe-$(CONFIG_PCI_IOV) += xe_gt_sriov_pf_debugfs.o
index 8d6df6bd885e4363c72449c1e39b1de3848f92a8..4b71570529a631887b316c4681f64c73ab2b96dc 100644 (file)
@@ -25,6 +25,7 @@
 #include "xe_sriov.h"
 #include "xe_sriov_pf.h"
 #include "xe_step.h"
+#include "xe_tile_debugfs.h"
 #include "xe_wa.h"
 #include "xe_vsec.h"
 
@@ -329,23 +330,6 @@ 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;
@@ -398,7 +382,7 @@ void xe_debugfs_register(struct xe_device *xe)
                ttm_resource_manager_create_debugfs(man, root, "stolen_mm");
 
        for_each_tile(tile, xe, tile_id)
-               create_tile_debugfs(tile, root);
+               xe_tile_debugfs_register(tile);
 
        for_each_gt(gt, xe, id)
                xe_gt_debugfs_register(gt);
index 7411c5f5c739856c4cca0921c4454f00ee9bb583..5aa1eded278d1726e2fb3143db9ac840608c9f3f 100644 (file)
@@ -123,18 +123,6 @@ static int powergate_info(struct xe_gt *gt, struct drm_printer *p)
        return ret;
 }
 
-static int sa_info(struct xe_gt *gt, struct drm_printer *p)
-{
-       struct xe_tile *tile = gt_to_tile(gt);
-
-       xe_pm_runtime_get(gt_to_xe(gt));
-       drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,
-                                    xe_sa_manager_gpu_addr(tile->mem.kernel_bb_pool));
-       xe_pm_runtime_put(gt_to_xe(gt));
-
-       return 0;
-}
-
 static int sa_info_vf_ccs(struct xe_gt *gt, struct drm_printer *p)
 {
        struct xe_tile *tile = gt_to_tile(gt);
@@ -316,7 +304,6 @@ static int hwconfig(struct xe_gt *gt, struct drm_printer *p)
  * - without access to the PF specific data
  */
 static const struct drm_info_list vf_safe_debugfs_list[] = {
-       {"sa_info", .show = xe_gt_debugfs_simple_show, .data = sa_info},
        {"topology", .show = xe_gt_debugfs_simple_show, .data = topology},
        {"ggtt", .show = xe_gt_debugfs_simple_show, .data = ggtt},
        {"register-save-restore", .show = xe_gt_debugfs_simple_show, .data = register_save_restore},
diff --git a/drivers/gpu/drm/xe/xe_tile_debugfs.c b/drivers/gpu/drm/xe/xe_tile_debugfs.c
new file mode 100644 (file)
index 0000000..5523874
--- /dev/null
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include <linux/debugfs.h>
+#include <drm/drm_debugfs.h>
+
+#include "xe_pm.h"
+#include "xe_sa.h"
+#include "xe_tile_debugfs.h"
+
+static struct xe_tile *node_to_tile(struct drm_info_node *node)
+{
+       return node->dent->d_parent->d_inode->i_private;
+}
+
+/**
+ * tile_debugfs_simple_show - A show callback for struct drm_info_list
+ * @m: the &seq_file
+ * @data: data used by the drm debugfs helpers
+ *
+ * This callback can be used in struct drm_info_list to describe debugfs
+ * files that are &xe_tile specific.
+ *
+ * It is assumed that those debugfs files will be created on directory entry
+ * which struct dentry d_inode->i_private points to &xe_tile.
+ *
+ *      /sys/kernel/debug/dri/0/
+ *      ├── tile0/               # tile = dentry->d_inode->i_private
+ *      │   │   ├── id               # tile = dentry->d_parent->d_inode->i_private
+ *
+ * This function assumes that &m->private will be set to the &struct
+ * drm_info_node corresponding to the instance of the info on a given &struct
+ * drm_minor (see struct drm_info_list.show for details).
+ *
+ * This function also assumes that struct drm_info_list.data will point to the
+ * function code that will actually print a file content::
+ *
+ *   int (*print)(struct xe_tile *, struct drm_printer *)
+ *
+ * Example::
+ *
+ *    int tile_id(struct xe_tile *tile, struct drm_printer *p)
+ *    {
+ *        drm_printf(p, "%u\n", tile->id);
+ *        return 0;
+ *    }
+ *
+ *    static const struct drm_info_list info[] = {
+ *        { name = "id", .show = tile_debugfs_simple_show, .data = tile_id },
+ *    };
+ *
+ *    dir = debugfs_create_dir("tile0", parent);
+ *    dir->d_inode->i_private = tile;
+ *    drm_debugfs_create_files(info, ARRAY_SIZE(info), dir, minor);
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+static int tile_debugfs_simple_show(struct seq_file *m, void *data)
+{
+       struct drm_printer p = drm_seq_file_printer(m);
+       struct drm_info_node *node = m->private;
+       struct xe_tile *tile = node_to_tile(node);
+       int (*print)(struct xe_tile *, struct drm_printer *) = node->info_ent->data;
+
+       return print(tile, &p);
+}
+
+/**
+ * tile_debugfs_show_with_rpm - A show callback for struct drm_info_list
+ * @m: the &seq_file
+ * @data: data used by the drm debugfs helpers
+ *
+ * Similar to tile_debugfs_simple_show() but implicitly takes a RPM ref.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+static int tile_debugfs_show_with_rpm(struct seq_file *m, void *data)
+{
+       struct drm_info_node *node = m->private;
+       struct xe_tile *tile = node_to_tile(node);
+       struct xe_device *xe = tile_to_xe(tile);
+       int ret;
+
+       xe_pm_runtime_get(xe);
+       ret = tile_debugfs_simple_show(m, data);
+       xe_pm_runtime_put(xe);
+
+       return ret;
+}
+
+static int sa_info(struct xe_tile *tile, struct drm_printer *p)
+{
+       drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,
+                                    xe_sa_manager_gpu_addr(tile->mem.kernel_bb_pool));
+
+       return 0;
+}
+
+/* only for debugfs files which can be safely used on the VF */
+static const struct drm_info_list vf_safe_debugfs_list[] = {
+       { "sa_info", .show = tile_debugfs_show_with_rpm, .data = sa_info },
+};
+
+/**
+ * xe_tile_debugfs_register - Register tile's debugfs attributes
+ * @tile: the &xe_tile to register
+ *
+ * Create debugfs sub-directory with a name that includes a tile ID and
+ * then creates set of debugfs files (attributes) specific to this tile.
+ */
+void xe_tile_debugfs_register(struct xe_tile *tile)
+{
+       struct xe_device *xe = tile_to_xe(tile);
+       struct drm_minor *minor = xe->drm.primary;
+       struct dentry *root = minor->debugfs_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;
+
+       drm_debugfs_create_files(vf_safe_debugfs_list,
+                                ARRAY_SIZE(vf_safe_debugfs_list),
+                                tile->debugfs, minor);
+}
diff --git a/drivers/gpu/drm/xe/xe_tile_debugfs.h b/drivers/gpu/drm/xe/xe_tile_debugfs.h
new file mode 100644 (file)
index 0000000..0e5f724
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef _XE_TILE_DEBUGFS_H_
+#define _XE_TILE_DEBUGFS_H_
+
+struct xe_tile;
+
+void xe_tile_debugfs_register(struct xe_tile *tile);
+
+#endif