From: Jocelyn Falempe <jfalempe@redhat.com>
To: dri-devel@lists.freedesktop.org, tzimmermann@suse.de,
airlied@redhat.com, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, daniel@ffwll.ch, javierm@redhat.com,
bluescreen_avenger@verizon.net, noralf@tronnes.org
Cc: gpiccoli@igalia.com, Jocelyn Falempe <jfalempe@redhat.com>
Subject: [PATCH v8 3/8] drm/panic: Add debugfs entry to test without triggering panic.
Date: Tue, 27 Feb 2024 11:04:14 +0100 [thread overview]
Message-ID: <20240227100459.194478-4-jfalempe@redhat.com> (raw)
In-Reply-To: <20240227100459.194478-1-jfalempe@redhat.com>
Add a debugfs file, so you can test drm_panic without freezing
your machine. This is unsafe, and should be enabled only for
developer or tester.
to display the drm_panic screen, just run:
echo 1 > /sys/kernel/debug/drm_panic/trigger
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
---
drivers/gpu/drm/Kconfig | 9 +++++++
drivers/gpu/drm/drm_panic.c | 47 +++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c17d8a8f6877..8dcea29f595c 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -125,6 +125,15 @@ config DRM_PANIC_BACKGROUND_COLOR
depends on DRM_PANIC
default 0x000000
+config DRM_PANIC_DEBUG
+ bool "Add a debug fs entry to trigger drm_panic"
+ depends on DRM_PANIC && DEBUG_FS
+ help
+ Add drm_panic/trigger in the kernel debugfs, to force the panic
+ handler to write the panic message to the scanout buffer. This is
+ unsafe and should not be enabled on a production build.
+ If in doubt, say "N".
+
config DRM_DEBUG_DP_MST_TOPOLOGY_REFS
bool "Enable refcount backtrace history in the DP MST helpers"
depends on STACKTRACE_SUPPORT
diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
index c9f386476ef9..c5d3f725c5f5 100644
--- a/drivers/gpu/drm/drm_panic.c
+++ b/drivers/gpu/drm/drm_panic.c
@@ -398,3 +398,50 @@ void drm_panic_unregister(struct drm_plane *plane)
}
EXPORT_SYMBOL(drm_panic_unregister);
+
+/*
+ * DEBUG, This is currently unsafe.
+ * Also it will call all panic_notifier, since there is no way to filter and
+ * only call the drm_panic notifier.
+ */
+#ifdef CONFIG_DRM_PANIC_DEBUG
+#include <linux/debugfs.h>
+
+static struct dentry *debug_dir;
+static struct dentry *debug_trigger;
+
+static ssize_t dbgfs_trigger_write(struct file *file, const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ bool run;
+
+ if (kstrtobool_from_user(user_buf, count, &run) == 0 && run)
+ atomic_notifier_call_chain(&panic_notifier_list, 0, "Test drm panic from debugfs");
+ return count;
+}
+
+static const struct file_operations dbg_drm_panic_ops = {
+ .owner = THIS_MODULE,
+ .write = dbgfs_trigger_write,
+};
+
+static int __init debugfs_start(void)
+{
+ debug_dir = debugfs_create_dir("drm_panic", NULL);
+
+ if (IS_ERR(debug_dir))
+ return PTR_ERR(debug_dir);
+ debug_trigger = debugfs_create_file("trigger", 0200, debug_dir,
+ NULL, &dbg_drm_panic_ops);
+ return 0;
+}
+
+static void __exit debugfs_end(void)
+{
+ debugfs_remove_recursive(debug_dir);
+}
+
+module_init(debugfs_start);
+module_exit(debugfs_end);
+
+#endif
--
2.43.0
next prev parent reply other threads:[~2024-02-27 10:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 10:04 [RFC][PATCH v8 0/8] drm/panic: Add a drm panic handler Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 1/8] drm/format-helper: Add drm_fb_blit_from_r1 and drm_fb_fill Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 2/8] drm/panic: Add a drm panic handler Jocelyn Falempe
2024-02-27 10:04 ` Jocelyn Falempe [this message]
2024-02-29 11:21 ` [PATCH v8 3/8] drm/panic: Add debugfs entry to test without triggering panic Daniel Vetter
2024-02-29 13:56 ` Jocelyn Falempe
2024-02-29 19:08 ` kernel test robot
2024-02-27 10:04 ` [PATCH v8 4/8] drm/fb_dma: Add generic set_scanout_buffer() for drm_panic Jocelyn Falempe
2024-02-29 15:12 ` kernel test robot
2024-03-01 2:13 ` kernel test robot
2024-02-27 10:04 ` [PATCH v8 5/8] drm/simpledrm: Add drm_panic support Jocelyn Falempe
2024-02-29 11:17 ` Daniel Vetter
2024-02-29 14:02 ` Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 6/8] drm/mgag200: " Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 7/8] drm/imx: " Jocelyn Falempe
2024-02-27 10:04 ` [PATCH v8 8/8] drm/ast: " Jocelyn Falempe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240227100459.194478-4-jfalempe@redhat.com \
--to=jfalempe@redhat.com \
--cc=airlied@redhat.com \
--cc=bluescreen_avenger@verizon.net \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gpiccoli@igalia.com \
--cc=javierm@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=noralf@tronnes.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.