Skip to contentSkip to conversation

drm/log: Introduce a new boot logger to draw the kmsg on the screen

RFC PATCH Superseded Jocelyn Falempe 3 participants 15 messages Aug 1, 2024 – Sep 6, 2024

Subsystems (3)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Jocelyn Falempe

author maintainer
#0 lore raw

cover drm/log: Introduce a new boot logger to draw the kmsg on the screen

drm_log is a simple logger that uses the drm_client API to print the kmsg boot log on the screen. This is not a full replacement to fbcon, as it will only print the kmsg.
It will never handle user input, or a terminal because this is better done in userspace.

If you're curious on how it looks like, I've put a small demo here:
https://people.redhat.com/jfalempe/drm_log/drm_log_draft_preview.webm

Design decisions:
* It uses the drm_client API, so it should work on all drm drivers from the start.
* It doesn't scroll the message, that way it doesn't need to redraw the whole screen for each new message. It also means it doesn't have to keep drawn messages in memory, to redraw them when scrolling.
* It uses a circular buffer so the console->write() callback is very quick, and will never stall.
* Drawing is done asynchronously using a workqueue.
* drm_log can only be built-in (and drm must be built-in too).
The reason is that, if you build it as a module, then a userspace application will be more appropriate than this module.

TODO items:
* It currently only handles the first drm_client hotplug event, I need a bit more time to fix that.
* I didn't find a way to know when drm_log loses focus, I would like to unregister it, so it won't waste CPU cycles in the background.
* I copied the drm_client API usage from drm_fbdev_shmem, so there might be some adjustment to work on DMA GPU (I didn't try yet).
* Flicker-free boot: I don't want drm_log to introduce new modeset during the boot, so it may need some adjustment.
* I tried to use the new nbcon interface, but didn't get any message from the write_atomic() callback, but the goal is to use that when it's ready.
* Add color support, to make timestamp, or error message, in different color for better visibility.
* If built with VT_CONSOLE=n and FRAMEBUFFER_CONSOLE=y, fbcon is taking the focus, and you won't see the drm_log.
It would be nice to have drm_log for boot logs, and still use fbcon for terminal, when userspace is started.

The first patch is not for review/merge, it's a squash of my pending drm_panic series:
https://patchwork.freedesktop.org/series/136377/
https://patchwork.freedesktop.org/series/135944/

The second patch, moves the drawing function from drm_panic.c, to drm_draw.c, so they can be re-used by drm_log. The third patch is the actual drm_log implementation.

I want to get some feedbacks before spending more time on this, and make sure I'm heading in the right direction.

Thanks and best regards,

Signature · 30 lines
Jocelyn

Jocelyn Falempe (3):
  [NOT FOR REVIEW] drm/panic: Squash of pending series
  drm/panic: Move drawing functions to drm_draw
  drm/log: Introduce a new boot logger to draw the kmsg on the screen

 drivers/gpu/drm/Kconfig             |   47 ++
 drivers/gpu/drm/Makefile            |    4 +
 drivers/gpu/drm/drm_crtc_internal.h |    8 +
 drivers/gpu/drm/drm_draw.c          |  216 ++++++
 drivers/gpu/drm/drm_draw.h          |   56 ++
 drivers/gpu/drm/drm_drv.c           |    5 +
 drivers/gpu/drm/drm_log.c           |  477 +++++++++++++
 drivers/gpu/drm/drm_log.h           |    8 +
 drivers/gpu/drm/drm_panic.c         |  596 +++++++++-------
 drivers/gpu/drm/drm_panic_qr.rs     | 1003 +++++++++++++++++++++++++++
 include/drm/drm_panic.h             |   21 +-
 include/drm/drm_rect.h              |   15 +
 12 files changed, 2181 insertions(+), 275 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_draw.c
 create mode 100644 drivers/gpu/drm/drm_draw.h
 create mode 100644 drivers/gpu/drm/drm_log.c
 create mode 100644 drivers/gpu/drm/drm_log.h
 create mode 100644 drivers/gpu/drm/drm_panic_qr.rs


base-commit: bb99c51bdaa846bddb85a1e7acca3a3aa5e9f082
-- 
2.45.2
author maintainer
#1 lore raw

RFC PATCH 1/3 drm/panic: Squash of pending series

This is a squashed patch of:
https://patchwork.freedesktop.org/series/136377/
https://patchwork.freedesktop.org/series/135944/

This is to avoid to rebase when they are merged.

---
 drivers/gpu/drm/Kconfig             |   31 +
 drivers/gpu/drm/Makefile            |    1 +
 drivers/gpu/drm/drm_crtc_internal.h |    8 +
 drivers/gpu/drm/drm_drv.c           |    3 +
 drivers/gpu/drm/drm_panic.c         |  367 ++++++++--
 drivers/gpu/drm/drm_panic_qr.rs     | 1003 +++++++++++++++++++++++++++
 include/drm/drm_panic.h             |   21 +-
 include/drm/drm_rect.h              |   15 +
 8 files changed, 1389 insertions(+), 60 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_panic_qr.rs
drivers/gpu/drm/Kconfig +31 -0
index b6ea88d228e1..b3ab3ace7f8e 100644
@@ -149,6 +149,37 @@ config DRM_PANIC_SCREEN
 	  or by writing to /sys/module/drm/parameters/panic_screen sysfs entry
 	  Default is "user"
 
+config DRM_PANIC_SCREEN_QR_CODE
+	bool "Add a panic screen with a QR code"
+	depends on DRM_PANIC && RUST
+	help
+	  This option adds a QR code generator, and a panic screen with a QR
+	  code. The QR code will contain the last lines of kmsg and other debug
+	  information. This should be easier for the user to report a kernel
+	  panic, with all debug information available.
+	  To use this panic screen, also set DRM_PANIC_SCREEN to "qr_code"
+
+config DRM_PANIC_SCREEN_QR_CODE_URL
+	string "Base URL of the QR code in the panic screen"
+	depends on DRM_PANIC_SCREEN_QR_CODE
+	help
+	  This option sets the base URL to report the kernel panic. If it's set
+	  the QR code will contain the URL and the kmsg compressed with zlib as
+	  a URL parameter. If it's empty, the QR code will contain the kmsg as
+	  uncompressed text only.
+	  There is a demo code in javascript, to decode and uncompress the kmsg
+	  data from the URL parameter at https://github.com/kdj0c/panic_report
+
+config DRM_PANIC_SCREEN_QR_VERSION
+	int "Maximum version (size) of the QR code."
+	depends on DRM_PANIC_SCREEN_QR_CODE
+	default 40
+	help
+	  This option limits the version (or size) of the QR code. QR code
+	  version ranges from Version 1 (21x21) to Version 40 (177x177).
+	  Smaller QR code are easier to read, but will contain less debugging
+	  data. Default is 40.
+
 config DRM_DEBUG_DP_MST_TOPOLOGY_REFS
         bool "Enable refcount backtrace history in the DP MST helpers"
 	depends on STACKTRACE_SUPPORT
drivers/gpu/drm/Makefile +1 -0
index 68cc9258ffc4..c62339b89d46 100644
@@ -89,6 +89,7 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += \
 	drm_privacy_screen_x86.o
 drm-$(CONFIG_DRM_ACCEL) += ../../accel/drm_accel.o
 drm-$(CONFIG_DRM_PANIC) += drm_panic.o
+drm-$(CONFIG_DRM_PANIC_SCREEN_QR_CODE) += drm_panic_qr.o
 obj-$(CONFIG_DRM)	+= drm.o
 
 obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
drivers/gpu/drm/drm_crtc_internal.h +8 -0
index 061436361998..89706aa8232f 100644
@@ -318,8 +318,16 @@ drm_edid_load_firmware(struct drm_connector *connector)
 /* drm_panic.c */
 #ifdef CONFIG_DRM_PANIC
 bool drm_panic_is_enabled(struct drm_device *dev);
+void drm_panic_register(struct drm_device *dev);
+void drm_panic_unregister(struct drm_device *dev);
+void drm_panic_init(void);
+void drm_panic_exit(void);
 #else
 static inline bool drm_panic_is_enabled(struct drm_device *dev) { return false; }
+static inline void drm_panic_register(struct drm_device *dev) {}
+static inline void drm_panic_unregister(struct drm_device *dev) {}
+static inline void drm_panic_init(void) {}
+static inline void drm_panic_exit(void) {}
 #endif
 
 #endif /* __DRM_CRTC_INTERNAL_H__ */
drivers/gpu/drm/drm_drv.c +3 -0
index 93543071a500..27007b53a8c8 100644
@@ -1067,6 +1067,7 @@ static const struct file_operations drm_stub_fops = {
 static void drm_core_exit(void)
 {
 	drm_privacy_screen_lookup_exit();
+	drm_panic_exit();
 	accel_core_exit();
 	unregister_chrdev(DRM_MAJOR, "drm");
 	debugfs_remove(drm_debugfs_root);
@@ -1099,6 +1100,8 @@ static int __init drm_core_init(void)
 	if (ret < 0)
 		goto error;
 
+	drm_panic_init();
+
 	drm_privacy_screen_lookup_init();
 
 	drm_core_init_complete = true;
drivers/gpu/drm/drm_panic.c +322 -45

538 lines not on this page · raw message

drivers/gpu/drm/drm_panic_qr.rs new file +1003 -0

1,003 lines not on this page · raw message

include/drm/drm_panic.h +6 -15
index 73bb3f3d9ed9..54085d5d05c3 100644
@@ -1,4 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0 or MIT */
+
+/*
+ * Copyright (c) 2024 Intel
+ * Copyright (c) 2024 Red Hat
+ */
+
 #ifndef __DRM_PANIC_H__
 #define __DRM_PANIC_H__
 
@@ -8,9 +14,6 @@
 
 #include <drm/drm_device.h>
 #include <drm/drm_fourcc.h>
-/*
- * Copyright (c) 2024 Intel
- */
 
 /**
  * struct drm_scanout_buffer - DRM scanout buffer
@@ -146,16 +149,4 @@ struct drm_scanout_buffer {
 #define drm_panic_unlock(dev, flags) \
 	raw_spin_unlock_irqrestore(&(dev)->mode_config.panic_lock, flags)
 
-#ifdef CONFIG_DRM_PANIC
-
-void drm_panic_register(struct drm_device *dev);
-void drm_panic_unregister(struct drm_device *dev);
-
-#else
-
-static inline void drm_panic_register(struct drm_device *dev) {}
-static inline void drm_panic_unregister(struct drm_device *dev) {}
-
-#endif
-
 #endif /* __DRM_PANIC_H__ */
include/drm/drm_rect.h +15 -0
index 73fcb899a01d..7bafde747d56 100644
@@ -238,6 +238,21 @@ static inline void drm_rect_fp_to_int(struct drm_rect *dst,
 		      drm_rect_height(src) >> 16);
 }
 
+/**
+ * drm_rect_overlap - Check if two rectangles overlap
+ * @r1: first rectangle
+ * @r2: second rectangle
+ *
+ * RETURNS:
+ * %true if the rectangles overlap, %false otherwise.
+ */
+static inline bool drm_rect_overlap(const struct drm_rect *r1,
+				    const struct drm_rect *r2)
+{
+	return (r1->x2 > r2->x1 && r2->x2 > r1->x1 &&
+		r1->y2 > r2->y1 && r2->y2 > r1->y1);
+}
+
 bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);
 bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst,
 			  const struct drm_rect *clip);
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

RFC PATCH 2/3 drm/panic: Move drawing functions to drm_draw

In reply to Jocelyn Falempe

Move the color conversions, blit and fill functions to drm_draw.c, so that they can be re-used by drm_log.
drm_draw is internal to the drm subsystem, and shouldn't be used by gpu drivers.

---
 drivers/gpu/drm/Kconfig     |   5 +
 drivers/gpu/drm/Makefile    |   1 +
 drivers/gpu/drm/drm_draw.c  | 216 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_draw.h  |  56 ++++++++
 drivers/gpu/drm/drm_panic.c | 247 ++++--------------------------------
 5 files changed, 301 insertions(+), 224 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_draw.c
 create mode 100644 drivers/gpu/drm/drm_draw.h
drivers/gpu/drm/Kconfig +5 -0
index b3ab3ace7f8e..c39bf143d705 100644
@@ -105,10 +105,15 @@ config DRM_KMS_HELPER
 	help
 	  CRTC helpers for KMS drivers.
 
+config DRM_DRAW
+	bool
+	depends on DRM
+
 config DRM_PANIC
 	bool "Display a user-friendly message when a kernel panic occurs"
 	depends on DRM
 	select FONT_SUPPORT
+	select DRM_DRAW
 	help
 	  Enable a drm panic handler, which will display a user-friendly message
 	  when a kernel panic occurs. It's useful when using a user-space
drivers/gpu/drm/Makefile +1 -0
index c62339b89d46..632247cddac9 100644
@@ -89,6 +89,7 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += \
 	drm_privacy_screen_x86.o
 drm-$(CONFIG_DRM_ACCEL) += ../../accel/drm_accel.o
 drm-$(CONFIG_DRM_PANIC) += drm_panic.o
+drm-$(CONFIG_DRM_DRAW) += drm_draw.o
 drm-$(CONFIG_DRM_PANIC_SCREEN_QR_CODE) += drm_panic_qr.o
 obj-$(CONFIG_DRM)	+= drm.o
 
drivers/gpu/drm/drm_draw.c new file +216 -0

216 lines not on this page · raw message

drivers/gpu/drm/drm_draw.h new file +56 -0

56 lines not on this page · raw message

drivers/gpu/drm/drm_panic.c +23 -224

332 lines not on this page · raw message

Signature · 1 line
2.45.2
author maintainer
#3 lore raw

RFC PATCH 3/3 drm/log: Introduce a new boot logger to draw the kmsg on the screen

In reply to Jocelyn Falempe

drm_log is a simple logger that uses the drm_client API to print the kmsg boot log on the screen. This is not a full replacement to fbcon, as it will only print the kmsg. It will never handle user input, or a terminal because this is better done in userspace.

Design decisions:
* It uses the drm_client API, so it should work on all drm drivers from the start.
* It doesn't scroll the message, that way it doesn't need to redraw the whole screen for each new message. It also means it doesn't have to keep drawn messages in memory, to redraw them when scrolling.
* It uses a circular buffer so the console->write() callback is very quick, and will never stall.
* Drawing is done asynchronously using a workqueue.
* drm_log can only be built-in (and drm must be built-in too).
The reason is that, if you build it as a module, then a userspace application will be more appropriate than this module.

---
 drivers/gpu/drm/Kconfig   |  11 +
 drivers/gpu/drm/Makefile  |   2 +
 drivers/gpu/drm/drm_drv.c |   2 +
 drivers/gpu/drm/drm_log.c | 477 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_log.h |   8 +
 5 files changed, 500 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_log.c
 create mode 100644 drivers/gpu/drm/drm_log.h
drivers/gpu/drm/Kconfig +11 -0
index c39bf143d705..b98e8b1755a9 100644
@@ -185,6 +185,17 @@ config DRM_PANIC_SCREEN_QR_VERSION
 	  Smaller QR code are easier to read, but will contain less debugging
 	  data. Default is 40.
 
+config DRM_LOG
+	bool "Print the kernel boot message on the screen"
+	depends on DRM=y
+	depends on !FRAMEBUFFER_CONSOLE
+	select DRM_DRAW
+	help
+	  This enable a drm logger, that will print the kernel messages to the
+	  screen until the userspace is ready to take over.
+	  It only makes sense to have it built-in, because otherwise it would
+	  be loaded after userspace.
+
 config DRM_DEBUG_DP_MST_TOPOLOGY_REFS
         bool "Enable refcount backtrace history in the DP MST helpers"
 	depends on STACKTRACE_SUPPORT
drivers/gpu/drm/Makefile +2 -0
index 632247cddac9..ac06b6f2aa10 100644
@@ -149,6 +149,8 @@ drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
 obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 
+obj-$(CONFIG_DRM_LOG) += drm_log.o
+
 #
 # Drivers and the rest
 #
drivers/gpu/drm/drm_drv.c +2 -0
index 27007b53a8c8..471960a6c0c9 100644
@@ -48,6 +48,7 @@
 #include <drm/drm_privacy_screen_machine.h>
 
 #include "drm_crtc_internal.h"
+#include "drm_log.h"
 #include "drm_internal.h"
 
 MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
@@ -946,6 +947,7 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 			goto err_unload;
 	}
 	drm_panic_register(dev);
+	drm_log_register(dev);
 
 	DRM_INFO("Initialized %s %d.%d.%d for %s on minor %d\n",
 		 driver->name, driver->major, driver->minor,
drivers/gpu/drm/drm_log.c new file +477 -0

477 lines not on this page · raw message

drivers/gpu/drm/drm_log.h new file +8 -0
new file mode 100644
index 000000000000..0107b79d7125
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+#ifndef __DRM_LOG_H__
+#define __DRM_LOG_H__
+
+void drm_log_register(struct drm_device *dev);
+void drm_log_unregister(struct drm_device *dev);
+
+#endif
Signature · 1 line
2.45.2
#4 lore raw
Quoted 3 lines · Jocelyn Falempe

* It uses a circular buffer so the console->write() callback is very quick, and will never stall.
* Drawing is done asynchronously using a workqueue.

For CON_NBCON, neither of the above points are necessary. You can draw directly from the write_thread() callback. See below:

drivers/gpu/drm/drm_log.c line 269

Quoted 10 lines
drivers/gpu/drm/drm_log.c new file +10 -0
+static bool drm_log_work_draw(void)
+{
+	unsigned int len;
+	char buf[512];
+
+	len = drm_log_buf_read(buf, sizeof(buf));
+	if (len)
+		drm_log_draw_all(buf, len);
+	return len != 0;
+}

For CON_NBCON, this is essentially your write_thread() callback:

void drm_log_write_thread(struct console *con,
struct nbcon_write_context *wctxt)

{
	drm_log_draw_all(wctxt->outbuf, wctxt->len);
}

You cannot implement a write_atomic() callback because the console must be able to print directly in NMI context and must not defer. But write_atomic() is optional, so you should be fine there.

Disclaimer: Only in PREEMPT_RT patchset at the moment.

John Ogness

author maintainer
#5 lore raw
Quoted 27 lines · John Ogness
Quoted 3 lines · Jocelyn Falempe

* It uses a circular buffer so the console->write() callback is very quick, and will never stall.
* Drawing is done asynchronously using a workqueue.

For CON_NBCON, neither of the above points are necessary. You can draw directly from the write_thread() callback. See below:

drivers/gpu/drm/drm_log.c line 269

Quoted 10 lines
drivers/gpu/drm/drm_log.c new file +10 -0
+static bool drm_log_work_draw(void)
+{
+	unsigned int len;
+	char buf[512];
+
+	len = drm_log_buf_read(buf, sizeof(buf));
+	if (len)
+		drm_log_draw_all(buf, len);
+	return len != 0;
+}

For CON_NBCON, this is essentially your write_thread() callback:

void drm_log_write_thread(struct console *con,
struct nbcon_write_context *wctxt)

{
	drm_log_draw_all(wctxt->outbuf, wctxt->len);
}
Quoted 5 lines

You cannot implement a write_atomic() callback because the console must be able to print directly in NMI context and must not defer. But write_atomic() is optional, so you should be fine there.

Disclaimer: Only in PREEMPT_RT patchset at the moment.

Thanks, so that means the circular buffer and workqueue are only necessary until write_thread() is merged in mainline. It will be a nice simplification.
I think I can also register one console for each drm driver, which will simplify drm_log even further. (currently it would mean having a circular buffer and work function for each driver which is a bit too much). Do you know if there is a chance to have write_thread() in 6.12 or 6.13 ?

Quoted 2 lines

John Ogness >

Best regards

Signature · 1 line
Jocelyn
#6 lore raw
Quoted 4 lines · Jocelyn Falempe

I think I can also register one console for each drm driver, which will simplify drm_log even further. (currently it would mean having a circular buffer and work function for each driver which is a bit too much).

Indeed.

Quoted 2 lines

Do you know if there is a chance to have write_thread() in 6.12 or 6.13 ?

Sorry, I have no crystal ball. Petr Mladek and I are working really hard to get things in shape for mainline. I do think there is a chance for the 6.12 merge window. But it would also need to get past Linus. Our recent atomic console efforts were rejected [0] for the 6.11 merge window. We are working to get that series in shape for 6.12 in parallel.

John

[0] https://lore.kernel.org/lkml/CAHk-=whU_woFnFN-3Jv2hNCmwLg_fkrT42AWwxm-=Ha5BmNX4w@mail.gmail.com

#7 lore raw
Quoted 10 lines · John Ogness
Quoted 4 lines · Jocelyn Falempe

I think I can also register one console for each drm driver, which will simplify drm_log even further. (currently it would mean having a circular buffer and work function for each driver which is a bit too much).

Indeed.

Quoted 2 lines

Do you know if there is a chance to have write_thread() in 6.12 or 6.13 ?

FYI: The full NBCON API (with write_thread()) is now available in linux-next.

It would be great to see a version of drm_log that only implements write_thread() and does not do any of its own buffering with workqueue and also does not need to track multiple graphic loggers at the same time.

John Ogness

author maintainer
#8 lore raw
Quoted 12 lines · John Ogness
Quoted 10 lines · John Ogness
Quoted 4 lines · Jocelyn Falempe

I think I can also register one console for each drm driver, which will simplify drm_log even further. (currently it would mean having a circular buffer and work function for each driver which is a bit too much).

Indeed.

Quoted 2 lines

Do you know if there is a chance to have write_thread() in 6.12 or 6.13 ?

Quoted 7 lines

FYI: The full NBCON API (with write_thread()) is now available in linux-next.

It would be great to see a version of drm_log that only implements write_thread() and does not do any of its own buffering with workqueue and also does not need to track multiple graphic loggers at the same time.

Thanks for the head-up.
I will rebase it on top of Linux-next, and adapt to the new write_thread() API, it should be much simpler.

I also need to adapt to the drm client rework (https://patchwork.freedesktop.org/series/137391/) so that it will be possible to choose on kernel command line between drm_log and fbdev emulation/fbcon.

Best regards,

Signature · 1 line
Jocelyn
Quoted 3 lines

John Ogness

#9 lore raw
Quoted 8 lines · Jocelyn Falempe
Quoted 4 lines

It would be great to see a version of drm_log that only implements write_thread() and does not do any of its own buffering with workqueue and also does not need to track multiple graphic loggers at the same time.

Thanks for the head-up.
I will rebase it on top of Linux-next, and adapt to the new write_thread() API, it should be much simpler.

For drm_log, your write_atomic() callback should be NULL. You only need to implement the write_thead(), device_lock(), and device_unlock() callbacks.

Your device_lock()/device_unlock() callbacks probably just need to lock/unlock your mutex @drm_log_lock.

device_lock() is already called when the write_thread() callback is called. So your write_thread callback really only needs to call your drm_log_draw_kmsg_record(&dclient->scanout, wctxt->outbuf, wctxt->len).

Please let me know if you run into any issues. We probably should write a document "HOWTO write an NBCON console driver".

John Ogness

#10 lore raw
Quoted 2 lines · John Ogness

Your device_lock()/device_unlock() callbacks probably just need to lock/unlock your mutex @drm_log_lock.

Sorry, forgot to mention that the device_lock() callback must also disable migration. Since you are using a mutex, you will need to manually do that as well...

mutex_lock(&drm_log_lock);
migrate_disable();

John

author maintainer
#11 lore raw
Quoted 10 lines · John Ogness
Quoted 2 lines · John Ogness

Your device_lock()/device_unlock() callbacks probably just need to lock/unlock your mutex @drm_log_lock.

Sorry, forgot to mention that the device_lock() callback must also disable migration. Since you are using a mutex, you will need to manually do that as well...

mutex_lock(&drm_log_lock);
migrate_disable();

Thanks a lot, I've done most of the conversion, and it's already working great. I will send a new series next week.

Best regards,

Signature · 1 line
Jocelyn
Quoted 3 lines

John

#12 lore raw
In reply to Jocelyn Falempe
kernel test robot noticed the following build errors:

Hi Jocelyn,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on bb99c51bdaa846bddb85a1e7acca3a3aa5e9f082]

url:    https://github.com/intel-lab-lkp/linux/commits/Jocelyn-Falempe/drm-panic-Squash-of-pending-series/20240802-204640
base:   bb99c51bdaa846bddb85a1e7acca3a3aa5e9f082
patch link:    https://lore.kernel.org/r/20240801100640.462606-4-jfalempe%40redhat.com
patch subject: [RFC PATCH 3/3] drm/log: Introduce a new boot logger to draw the kmsg on the screen
config: i386-buildonly-randconfig-004-20240803 (https://download.01.org/0day-ci/archive/20240804/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8183-ipu_adl.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8183-vdec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8183-venc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8186-cam.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8186-img.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8186-ipe.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8186-mdp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8186-vdec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8186-venc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-apmixedsys.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-topckgen.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-peri_ao.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-infra_ao.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-adsp_audio26m.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-mfg.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-vdo0.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8188-vdo1.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8192-mdp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8192-scp_adsp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8192-vdec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/mediatek/clk-mt8192-venc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/qcom/hdma_mgmt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/ti/omap-dma.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/dmatest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/imx/soc-imx8m.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/amlogic/meson-clk-measure.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/qcom/spm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/reset/hisilicon/hi6220_reset.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/8250/8250_base.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/8250/8250_pxa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/owl-uart.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/goldfish.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/hw_random/omap-rng.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/lp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/nvram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-spmi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/block/brd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/block/loop.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/misc/fastrpc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/misc/open-dice.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dax/dax.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/spi/spi-fsl-lib.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/input/touchscreen/cyttsp_i2c_common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/input/misc/soc_button_array.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/input/vivaldi-fmap.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/rtc-omap.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/pwrseq_emmc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/host/of_mmc_spi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-a4tech.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-apple.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-aureal.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-cherry.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-cypress.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-dr.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-emsff.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-elecom.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-evision.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ezkey.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-kensington.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-lcpower.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-maltron.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-mf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-microsoft.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-petalynx.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-razer.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-redragon.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-semitek.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-sjoy.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-speedlink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-steam.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-sunplus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-topseed.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-twinhan.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-xinmo.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-zpff.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-bootrom.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-hid.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-loopback.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-power-supply.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-raw.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-vibrator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-gbphy.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-spi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-spilib.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-uart.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_performance.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/perf/arm_cspmu/ampere_cspmu.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem-apple-efuses.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/spmi/hisi-spmi-controller.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/greybus/greybus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/adc/ingenic-adc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/buffer/kfifo_buf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-hub.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-aspeed.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-ast-cf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-scom.o

>> ERROR: modpost: "drm_log_register" [drivers/gpu/drm/drm.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#13 lore raw
In reply to Jocelyn Falempe
kernel test robot noticed the following build errors:

Hi Jocelyn,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on bb99c51bdaa846bddb85a1e7acca3a3aa5e9f082]

url:    https://github.com/intel-lab-lkp/linux/commits/Jocelyn-Falempe/drm-panic-Squash-of-pending-series/20240802-204640
base:   bb99c51bdaa846bddb85a1e7acca3a3aa5e9f082
patch link:    https://lore.kernel.org/r/20240801100640.462606-4-jfalempe%40redhat.com
patch subject: [RFC PATCH 3/3] drm/log: Introduce a new boot logger to draw the kmsg on the screen
config: i386-buildonly-randconfig-006-20240803 (https://download.01.org/0day-ci/archive/20240804/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: drm_log_register
   >>> referenced by drm_drv.c
   >>>               drivers/gpu/drm/drm_drv.o:(drm_dev_register) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#14 lore raw
In reply to Jocelyn Falempe
Quoted 3 lines · Jocelyn Falempe

* I tried to use the new nbcon interface, but didn't get any message from the write_atomic() callback, but the goal is to use that when it's ready.

Be aware that the write_atomic() callback _must_ also print from NMI context. write_thread() may be the callback you are interested instead. Note that for CON_NBCON, write_atomic() is optional, write_thread() is mandatory.

Disclaimer: All of this currently only available in the PREEMPT_RT patchset. So until it hits mainline, semantics may yet change.

John Ogness