Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/guc: Make debugfs guc_log_dmesg attribute write-only
@ 2025-06-03 17:53 Michal Wajdeczko
  2025-06-03 17:58 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Michal Wajdeczko @ 2025-06-03 17:53 UTC (permalink / raw)
  To: intel-xe; +Cc: Michal Wajdeczko, John Harrison

Ocassionally we want to dump a GuC log into the dmesg, but current
implementation is based on the drm debugfs API and was triggering
dump on the read operation.  Expose guc_log_dmesg attribute as
write-only using pure debugfs API to make dump requests explicit.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
---
 drivers/gpu/drm/xe/xe_guc_debugfs.c | 43 ++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_debugfs.c b/drivers/gpu/drm/xe/xe_guc_debugfs.c
index 0b102ab46c4d..eb6124d02d53 100644
--- a/drivers/gpu/drm/xe/xe_guc_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_guc_debugfs.c
@@ -5,6 +5,8 @@
 
 #include "xe_guc_debugfs.h"
 
+#include <linux/debugfs.h>
+
 #include <drm/drm_debugfs.h>
 #include <drm/drm_managed.h>
 
@@ -85,12 +87,6 @@ static int guc_log(struct xe_guc *guc, struct drm_printer *p)
 	return 0;
 }
 
-static int guc_log_dmesg(struct xe_guc *guc, struct drm_printer *p)
-{
-	xe_guc_log_print_dmesg(&guc->log);
-	return 0;
-}
-
 static int guc_ctb(struct xe_guc *guc, struct drm_printer *p)
 {
 	xe_guc_ct_print(&guc->ct, p, true);
@@ -121,9 +117,39 @@ static const struct drm_info_list slpc_debugfs_list[] = {
 /* everything else should be added here */
 static const struct drm_info_list pf_only_debugfs_list[] = {
 	{ "guc_log", .show = guc_debugfs_show, .data = guc_log },
-	{ "guc_log_dmesg", .show = guc_debugfs_show, .data = guc_log_dmesg },
 };
 
+/*
+ *      /sys/kernel/debug/dri/0/
+ *      ├── gt0
+ *      │   ├── uc
+ *      │   │   ├── guc_log_dmesg
+ */
+static ssize_t guc_log_dmesg_write(struct file *file,
+				   const char __user *userbuf,
+				   size_t count, loff_t *ppos)
+{
+	struct seq_file *s = file->private_data;
+	struct xe_guc *guc = s->private;
+	bool yes;
+	int ret;
+
+	if (*ppos)
+		return -EINVAL;
+	ret = kstrtobool_from_user(userbuf, count, &yes);
+	if (ret < 0)
+		return ret;
+	if (yes)
+		xe_guc_log_print_dmesg(&guc->log);
+	return count;
+}
+
+static int guc_log_dmesg_show(struct seq_file *s, void *unused)
+{
+	return 0;
+}
+DEFINE_SHOW_STORE_ATTRIBUTE(guc_log_dmesg);
+
 void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent)
 {
 	struct xe_device *xe =  guc_to_xe(guc);
@@ -142,5 +168,8 @@ void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent)
 			drm_debugfs_create_files(slpc_debugfs_list,
 						 ARRAY_SIZE(slpc_debugfs_list),
 						 parent, minor);
+
+		debugfs_create_file("guc_log_dmesg", 0200, parent,
+				    guc, &guc_log_dmesg_fops);
 	}
 }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-06-24 20:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 17:53 [PATCH] drm/xe/guc: Make debugfs guc_log_dmesg attribute write-only Michal Wajdeczko
2025-06-03 17:58 ` ✓ CI.Patch_applied: success for " Patchwork
2025-06-03 17:58 ` ✓ CI.checkpatch: " Patchwork
2025-06-03 17:59 ` ✗ CI.KUnit: failure " Patchwork
2025-06-04 19:24 ` ✓ CI.Patch_applied: success for drm/xe/guc: Make debugfs guc_log_dmesg attribute write-only (rev2) Patchwork
2025-06-04 19:24 ` ✓ CI.checkpatch: " Patchwork
2025-06-04 19:25 ` ✓ CI.KUnit: " Patchwork
2025-06-04 19:36 ` ✓ CI.Build: " Patchwork
2025-06-04 19:39 ` ✓ CI.Hooks: " Patchwork
2025-06-04 19:40 ` ✓ CI.checksparse: " Patchwork
2025-06-04 20:42 ` ✓ Xe.CI.BAT: " Patchwork
2025-06-05 18:17 ` ✓ Xe.CI.Full: " Patchwork
2025-06-09 22:11 ` [PATCH] drm/xe/guc: Make debugfs guc_log_dmesg attribute write-only John Harrison
2025-06-24 20:51   ` Michal Wajdeczko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox