]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/xe: Add clearing stats to GT debugfs
authorMatthew Brost <matthew.brost@intel.com>
Fri, 29 Aug 2025 17:22:31 +0000 (10:22 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Wed, 3 Sep 2025 05:23:07 +0000 (22:23 -0700)
It helpful to clear GT stats, run a test cases which is being profiled,
and look at the results of the stats from the individual test case. Make
stats entry writable and upon write clear the stats.

v5:
 - Drop clear_stats debugfs entry (Lucas)
v6:
 - Use xe_gt_stats_clear rather than helper (Michal)
 - Rework loop in xe_gt_stats_clear (Michal)

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20250829172232.1308004-2-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_gt_debugfs.c
drivers/gpu/drm/xe/xe_gt_stats.c
drivers/gpu/drm/xe/xe_gt_stats.h

index bf3a67b5951cffc796e91c37cddfe7a31ef20ac8..7411c5f5c739856c4cca0921c4454f00ee9bb583 100644 (file)
@@ -327,7 +327,6 @@ static const struct drm_info_list vf_safe_debugfs_list[] = {
        {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc},
        {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc},
        {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc},
-       {"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info},
        {"hwconfig", .show = xe_gt_debugfs_simple_show, .data = hwconfig},
 };
 
@@ -363,6 +362,24 @@ static ssize_t write_to_gt_call(const char __user *userbuf, size_t count, loff_t
        return count;
 }
 
+static ssize_t stats_write(struct file *file, const char __user *userbuf,
+                          size_t count, loff_t *ppos)
+{
+       struct seq_file *s = file->private_data;
+       struct xe_gt *gt = s->private;
+
+       return write_to_gt_call(userbuf, count, ppos, xe_gt_stats_clear, gt);
+}
+
+static int stats_show(struct seq_file *s, void *unused)
+{
+       struct drm_printer p = drm_seq_file_printer(s);
+       struct xe_gt *gt = s->private;
+
+       return xe_gt_stats_print_info(gt, &p);
+}
+DEFINE_SHOW_STORE_ATTRIBUTE(stats);
+
 static void force_reset(struct xe_gt *gt)
 {
        struct xe_device *xe = gt_to_xe(gt);
@@ -448,6 +465,7 @@ void xe_gt_debugfs_register(struct xe_gt *gt)
        root->d_inode->i_private = gt;
 
        /* VF safe */
+       debugfs_create_file("stats", 0600, root, gt, &stats_fops);
        debugfs_create_file("force_reset", 0600, root, gt, &force_reset_fops);
        debugfs_create_file("force_reset_sync", 0600, root, gt, &force_reset_sync_fops);
 
index 30f942671c2b98351ee42602dba2182316d51eb4..17056d832138a5bde49588f53f7e6fe060ba8af8 100644 (file)
@@ -50,3 +50,17 @@ int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
 
        return 0;
 }
+
+/**
+ * xe_gt_stats_clear - Clear the GT stats
+ * @gt: GT structure
+ *
+ * This clear (zeros) all the available GT stats.
+ */
+void xe_gt_stats_clear(struct xe_gt *gt)
+{
+       int id;
+
+       for (id = 0; id < ARRAY_SIZE(gt->stats.counters); ++id)
+               atomic64_set(&gt->stats.counters[id], 0);
+}
index 38325ef536176577907e0340e9815a171432ac48..e8aea32bc97186248805b42d6abcba154f27645b 100644 (file)
@@ -13,6 +13,7 @@ struct drm_printer;
 
 #ifdef CONFIG_DEBUG_FS
 int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p);
+void xe_gt_stats_clear(struct xe_gt *gt);
 void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr);
 #else
 static inline void