mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/panic: Bring back the kmsg screen fixes lost in a merge
@ 2026-11-19 19:10 Devin Wittmayer
  2026-11-20 14:34 ` Jocelyn Falempe
  0 siblings, 1 reply; 2+ messages in thread
From: Devin Wittmayer @ 2026-11-19 19:10 UTC (permalink / raw)
  To: Jocelyn Falempe, Javier Martinez Canillas
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel, desobei,
	luyuantao

Commit b537d87d2632 ("drm/panic: Fix the loop that causes kmsg to not
display correctly") and commit 1ba640563843 ("drm/panic: Fix kmsg screen
hang on a long log line") changed the old panic file. By the time they
reached drm-fixes, that code had moved into the helper library, and the
merge left the helper as it was.

So the panic screen that prints the kernel log hangs again on a long
log line, and the machine never reboots. The helper's KUnit suite hangs
the same way.

Make both changes in the helper.

Fixes: 5c3d323984fd ("drm/panic: Move panic display code into helper library")
Reported-by: desobei <desobei@outlook.com>
Closes: https://lore.kernel.org/all/PH7PR19MB6658FDBDD012399C6E8D330FAF792@PH7PR19MB6658.namprd19.prod.outlook.com/
Tested-by: desobei <desobei@outlook.com>
Cc: luyuantao <luyuantao@kylinos.cn>
Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca>
---
Both were lost in merge 1c3b1398f1cf. My other fix in that pull, for
the panic screen setting, made it through.

Panics with a long line in the log, on drm-misc-fixes:

                              without this    with this
    QEMU, 40 panics           all hang        all reboot
    AMD mini PC, 8 panics     all hang        all reboot

Panics with nothing long in the log reboot either way.

 drivers/gpu/drm/drm_panic_helper.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_panic_helper.c b/drivers/gpu/drm/drm_panic_helper.c
index 8913c3d22e8d..385a07ed314b 100644
--- a/drivers/gpu/drm/drm_panic_helper.c
+++ b/drivers/gpu/drm/drm_panic_helper.c
@@ -513,7 +513,8 @@ VISIBLE_IF_KUNIT int drm_panic_helper_draw_screen_kmsg(struct drm_scanout_buffer
 	const struct font_desc *font = get_default_font(sb->width, sb->height, NULL, NULL);
 	struct drm_rect r_screen = DRM_RECT_INIT(0, 0, sb->width, sb->height);
 	struct kmsg_dump_iter iter;
-	char kmsg_buf[512];
+	/* the size printk formats one record into, too big for the stack */
+	static char kmsg_buf[2048];
 	size_t kmsg_len;
 	struct drm_panic_line line;
 	int yoffset;
@@ -530,10 +531,15 @@ VISIBLE_IF_KUNIT int drm_panic_helper_draw_screen_kmsg(struct drm_scanout_buffer
 	drm_panic_helper_fill(sb, &r_screen, bg_color);
 
 	kmsg_dump_rewind(&iter);
-	while (kmsg_dump_get_buffer(&iter, false, kmsg_buf, sizeof(kmsg_buf), &kmsg_len)) {
+	while (yoffset >= 0 && kmsg_dump_get_buffer(&iter, false, kmsg_buf,
+	       sizeof(kmsg_buf), &kmsg_len)) {
 		char *start;
 		char *end;
 
+		/* a record that does not fit comes back empty, every time */
+		if (!kmsg_len)
+			break;
+
 		/* ignore terminating NUL and newline */
 		start = kmsg_buf + kmsg_len - 2;
 		end = kmsg_buf + kmsg_len - 1;
-- 
2.56.1


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

end of thread, other threads:[~2026-11-20 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 19:10 [PATCH] drm/panic: Bring back the kmsg screen fixes lost in a merge Devin Wittmayer
2026-11-20 14:34 ` Jocelyn Falempe

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

all inboxes | Powered by JetHome®