]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/debugfs: Improve .show() helper for GT-based attributes
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 19 Sep 2025 16:04:30 +0000 (18:04 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 23 Sep 2025 18:04:15 +0000 (20:04 +0200)
Like we did for tile-based attributes, introduce separate show()
helper that implicitly takes an RPM reference prior to the call
to the actual print() function. This translates into some savings.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250919160430.573-3-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_debugfs.c
drivers/gpu/drm/xe/xe_gt_debugfs.h

index e4eba91cb83d9bbd5757f6de9d25f5f6109a32dd..b9176d4398e1bd5fe29c02e82cc6ab5f53b46a4f 100644 (file)
 #include "xe_uc_debugfs.h"
 #include "xe_wa.h"
 
+static struct xe_gt *node_to_gt(struct drm_info_node *node)
+{
+       return node->dent->d_parent->d_inode->i_private;
+}
+
 /**
  * xe_gt_debugfs_simple_show - A show callback for struct drm_info_list
  * @m: the &seq_file
@@ -77,8 +82,7 @@ int xe_gt_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 dentry *parent = node->dent->d_parent;
-       struct xe_gt *gt = parent->d_inode->i_private;
+       struct xe_gt *gt = node_to_gt(node);
        int (*print)(struct xe_gt *, struct drm_printer *) = node->info_ent->data;
 
        if (WARN_ON(!print))
@@ -87,15 +91,36 @@ int xe_gt_debugfs_simple_show(struct seq_file *m, void *data)
        return print(gt, &p);
 }
 
-static int hw_engines(struct xe_gt *gt, struct drm_printer *p)
+/**
+ * xe_gt_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 xe_gt_debugfs_simple_show() but implicitly takes a RPM ref.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_gt_debugfs_show_with_rpm(struct seq_file *m, void *data)
 {
+       struct drm_info_node *node = m->private;
+       struct xe_gt *gt = node_to_gt(node);
        struct xe_device *xe = gt_to_xe(gt);
+       int ret;
+
+       xe_pm_runtime_get(xe);
+       ret = xe_gt_debugfs_simple_show(m, data);
+       xe_pm_runtime_put(xe);
+
+       return ret;
+}
+
+static int hw_engines(struct xe_gt *gt, struct drm_printer *p)
+{
        struct xe_hw_engine *hwe;
        enum xe_hw_engine_id id;
        unsigned int fw_ref;
        int ret = 0;
 
-       xe_pm_runtime_get(xe);
        fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
        if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) {
                ret = -ETIMEDOUT;
@@ -107,37 +132,19 @@ static int hw_engines(struct xe_gt *gt, struct drm_printer *p)
 
 fw_put:
        xe_force_wake_put(gt_to_fw(gt), fw_ref);
-       xe_pm_runtime_put(xe);
-
-       return ret;
-}
-
-static int powergate_info(struct xe_gt *gt, struct drm_printer *p)
-{
-       int ret;
-
-       xe_pm_runtime_get(gt_to_xe(gt));
-       ret = xe_gt_idle_pg_print(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
 
        return ret;
 }
 
 static int topology(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_gt_topology_dump(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int steering(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_gt_mcr_steering_dump(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
@@ -146,8 +153,6 @@ static int register_save_restore(struct xe_gt *gt, struct drm_printer *p)
        struct xe_hw_engine *hwe;
        enum xe_hw_engine_id id;
 
-       xe_pm_runtime_get(gt_to_xe(gt));
-
        xe_reg_sr_dump(&gt->reg_sr, p);
        drm_printf(p, "\n");
 
@@ -165,98 +170,66 @@ static int register_save_restore(struct xe_gt *gt, struct drm_printer *p)
        for_each_hw_engine(hwe, gt, id)
                xe_reg_whitelist_dump(&hwe->reg_whitelist, p);
 
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int workarounds(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_wa_dump(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int tunings(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_tuning_dump(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int pat(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_pat_dump(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int mocs(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_mocs_dump(gt, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int rcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_RENDER);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int ccs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COMPUTE);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int bcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COPY);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int vcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_DECODE);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int vecs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_ENHANCE);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
 static int hwconfig(struct xe_gt *gt, struct drm_printer *p)
 {
-       xe_pm_runtime_get(gt_to_xe(gt));
        xe_guc_hwconfig_dump(&gt->uc.guc, p);
-       xe_pm_runtime_put(gt_to_xe(gt));
-
        return 0;
 }
 
@@ -266,25 +239,26 @@ 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[] = {
-       {"topology", .show = xe_gt_debugfs_simple_show, .data = topology},
-       {"register-save-restore", .show = xe_gt_debugfs_simple_show, .data = register_save_restore},
-       {"workarounds", .show = xe_gt_debugfs_simple_show, .data = workarounds},
-       {"tunings", .show = xe_gt_debugfs_simple_show, .data = tunings},
-       {"default_lrc_rcs", .show = xe_gt_debugfs_simple_show, .data = rcs_default_lrc},
-       {"default_lrc_ccs", .show = xe_gt_debugfs_simple_show, .data = ccs_default_lrc},
-       {"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},
-       {"hwconfig", .show = xe_gt_debugfs_simple_show, .data = hwconfig},
+       { "topology", .show = xe_gt_debugfs_show_with_rpm, .data = topology },
+       { "register-save-restore",
+               .show = xe_gt_debugfs_show_with_rpm, .data = register_save_restore },
+       { "workarounds", .show = xe_gt_debugfs_show_with_rpm, .data = workarounds },
+       { "tunings", .show = xe_gt_debugfs_show_with_rpm, .data = tunings },
+       { "default_lrc_rcs", .show = xe_gt_debugfs_show_with_rpm, .data = rcs_default_lrc },
+       { "default_lrc_ccs", .show = xe_gt_debugfs_show_with_rpm, .data = ccs_default_lrc },
+       { "default_lrc_bcs", .show = xe_gt_debugfs_show_with_rpm, .data = bcs_default_lrc },
+       { "default_lrc_vcs", .show = xe_gt_debugfs_show_with_rpm, .data = vcs_default_lrc },
+       { "default_lrc_vecs", .show = xe_gt_debugfs_show_with_rpm, .data = vecs_default_lrc },
+       { "hwconfig", .show = xe_gt_debugfs_show_with_rpm, .data = hwconfig },
 };
 
 /* everything else should be added here */
 static const struct drm_info_list pf_only_debugfs_list[] = {
-       {"hw_engines", .show = xe_gt_debugfs_simple_show, .data = hw_engines},
-       {"mocs", .show = xe_gt_debugfs_simple_show, .data = mocs},
-       {"pat", .show = xe_gt_debugfs_simple_show, .data = pat},
-       {"powergate_info", .show = xe_gt_debugfs_simple_show, .data = powergate_info},
-       {"steering", .show = xe_gt_debugfs_simple_show, .data = steering},
+       { "hw_engines", .show = xe_gt_debugfs_show_with_rpm, .data = hw_engines },
+       { "mocs", .show = xe_gt_debugfs_show_with_rpm, .data = mocs },
+       { "pat", .show = xe_gt_debugfs_show_with_rpm, .data = pat },
+       { "powergate_info", .show = xe_gt_debugfs_show_with_rpm, .data = xe_gt_idle_pg_print },
+       { "steering", .show = xe_gt_debugfs_show_with_rpm, .data = steering },
 };
 
 static ssize_t write_to_gt_call(const char __user *userbuf, size_t count, loff_t *ppos,
index 05a6cc93c78c789eef39b8bba6f26915706d4dda..32ee3264051b0edefb10c5b7200410fb19ef5fbb 100644 (file)
@@ -11,5 +11,6 @@ struct xe_gt;
 
 void xe_gt_debugfs_register(struct xe_gt *gt);
 int xe_gt_debugfs_simple_show(struct seq_file *m, void *data);
+int xe_gt_debugfs_show_with_rpm(struct seq_file *m, void *data);
 
 #endif