Skip to contentSkip to conversation

drm/panic: Remove build time dependency with FRAMEBUFFER_CONSOLE

PATCH In review Jocelyn Falempe 4 participants 17 messages Jul 17, 2024 – Jul 22, 2024

Subsystems (6)
lore
Share & tools
lore

Jocelyn Falempe

author maintainer
#0 lore raw

cover drm/panic: Remove build time dependency with FRAMEBUFFER_CONSOLE

When proposing to enable DRM_PANIC on Fedora, some users raised concern about the need to disable VT_CONSOLE.
So this is my new attempt to avoid fbcon/vt_console to overwrite the panic screen.
This time it doesn't involve any locking, so it should be safe.
I added a skip_panic option in struct fb_info, and check if this option and the panic_cpu are set in fb_is_inactive(), to prevent any framebuffer operation. Also skip_panic is only true if the drm driver supports drm_panic, so you will still get the VT panic info on drivers that don't have drm_panic support yet.

Jocelyn Falempe (3):
drm/panic: Add drm_panic_is_enabled()
fbcon: Add an option to disable fbcon in panic. drm/panic: Remove build time dependency with FRAMEBUFFER_CONSOLE

 drivers/gpu/drm/Kconfig          |  2 +-
 drivers/gpu/drm/drm_fb_helper.c  |  2 ++
 drivers/gpu/drm/drm_panic.c      | 20 ++++++++++++++++++++
 drivers/video/fbdev/core/fbcon.c |  7 ++++++-
 include/drm/drm_panic.h          |  2 ++
 include/linux/fb.h               |  1 +
 6 files changed, 32 insertions(+), 2 deletions(-)

base-commit: a237f217bad50c381773da5b00442710d1449098

Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH 1/3 drm/panic: Add drm_panic_is_enabled()

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
 drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++
 include/drm/drm_panic.h     |  2 ++
 2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +20 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct drm_plane *plane, int index)
 static void debugfs_register_plane(struct drm_plane *plane, int index) {}
 #endif /* CONFIG_DRM_PANIC_DEBUG */
 
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+	struct drm_plane *plane;
+
+	if (!dev->mode_config.num_total_plane)
+		return false;
+
+	drm_for_each_plane(plane, dev)
+		if (plane->helper_private && plane->helper_private->get_scanout_buffer)
+			return true;
+	return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);
+
 /**
  * drm_panic_register() - Initialize DRM panic for a device
  * @dev: the drm device on which the panic screen will be displayed.
include/drm/drm_panic.h +2 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
 
 #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);
 
 #else
 
+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) {}
 
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

Jocelyn Falempe <[email protected]> writes:

Hello Jocelyn,

Quoted 27 lines

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
 drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++
 include/drm/drm_panic.h     |  2 ++
 2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +10 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct drm_plane *plane, int index)
 static void debugfs_register_plane(struct drm_plane *plane, int index) {}
 #endif /* CONFIG_DRM_PANIC_DEBUG */
 
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+	struct drm_plane *plane;
+

drivers/gpu/drm/drm_panic.c static void debugfs_register_plane(struct drm_plane *plane, int index) · line 725

Quoted 10 lines
drivers/gpu/drm/drm_panic.c +10 -0
+	if (!dev->mode_config.num_total_plane)
+		return false;
+
+	drm_for_each_plane(plane, dev)
+		if (plane->helper_private && plane->helper_private->get_scanout_buffer)
+			return true;
+	return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);
+
Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Reviewed-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

In reply to Jocelyn Falempe
Quoted 26 lines · Jocelyn Falempe

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
 drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++
 include/drm/drm_panic.h     |  2 ++
 2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +9 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct drm_plane *plane, int index)
 static void debugfs_register_plane(struct drm_plane *plane, int index) {}
 #endif /* CONFIG_DRM_PANIC_DEBUG */
 
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+	struct drm_plane *plane;

drivers/gpu/drm/drm_panic.c static void debugfs_register_plane(struct drm_plane *plane, int index) · line 724

Quoted 10 lines
drivers/gpu/drm/drm_panic.c +10 -0
+
+	if (!dev->mode_config.num_total_plane)
+		return false;
+
+	drm_for_each_plane(plane, dev)
+		if (plane->helper_private && plane->helper_private->get_scanout_buffer)
+			return true;
+	return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);

This feels like overkill since you currently only have one user in the fbdev emulation code, but maybe useful in some other places ...

include/drm/drm_panic.h struct drm_scanout_buffer { · line 151

Quoted 13 lines
drivers/gpu/drm/drm_panic.c +1 -0
+
 /**
  * drm_panic_register() - Initialize DRM panic for a device
  * @dev: the drm device on which the panic screen will be displayed.
include/drm/drm_panic.h +1 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
 
 #ifdef CONFIG_DRM_PANIC
 
+bool drm_panic_is_enabled(struct drm_device *dev);

Since it's internal only, this should be in drivers/gpu/drm/drm_crtc_internal.h and not int he include for drivers. With that:

include/drm/drm_panic.h struct drm_scanout_buffer { · line 153

Quoted 2 lines
include/drm/drm_panic.h +0 -0
 void drm_panic_register(struct drm_device *dev);
 void drm_panic_unregister(struct drm_device *dev);

These two are only used in drm.ko. Can you please move them to drm_crtc_internal.h too and drop the EXPORT_SYMBOL in a follow-up patch? We're trying to limit the exported interface and official headers to really only the pieces drivers actually need.

Thanks, Sima

Quoted 10 lines
include/drm/drm_panic.h +1 -0
 #else
 
+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) {}
 
Signature · 1 line
2.45.2
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author maintainer
#4 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

Quoted 51 lines · Daniel Vetter
Quoted 26 lines · Jocelyn Falempe

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
  drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++
  include/drm/drm_panic.h     |  2 ++
  2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +9 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct drm_plane *plane, int index)
  static void debugfs_register_plane(struct drm_plane *plane, int index) {}
  #endif /* CONFIG_DRM_PANIC_DEBUG */
 
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+	struct drm_plane *plane;

drivers/gpu/drm/drm_panic.c static void debugfs_register_plane(struct drm_plane *plane, int index) · line 724

Quoted 10 lines
drivers/gpu/drm/drm_panic.c +10 -0
+
+	if (!dev->mode_config.num_total_plane)
+		return false;
+
+	drm_for_each_plane(plane, dev)
+		if (plane->helper_private && plane->helper_private->get_scanout_buffer)
+			return true;
+	return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);

This feels like overkill since you currently only have one user in the fbdev emulation code, but maybe useful in some other places ...

Quoted 10 lines
drivers/gpu/drm/drm_panic.c +1 -0
+
  /**
   * drm_panic_register() - Initialize DRM panic for a device
   * @dev: the drm device on which the panic screen will be displayed.
include/drm/drm_panic.h +0 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
 
Quoted 6 lines

include/drm/drm_panic.h struct drm_scanout_buffer { · line 151

Quoted 3 lines
include/drm/drm_panic.h +1 -0
  #ifdef CONFIG_DRM_PANIC
 
+bool drm_panic_is_enabled(struct drm_device *dev);

Since it's internal only, this should be in drivers/gpu/drm/drm_crtc_internal.h and not int he include for drivers.

Yes, that makes sense, drivers won't need that API.

Quoted 11 lines

With that:

include/drm/drm_panic.h struct drm_scanout_buffer { · line 153

Quoted 2 lines
include/drm/drm_panic.h +0 -0
  void drm_panic_register(struct drm_device *dev);
  void drm_panic_unregister(struct drm_device *dev);

These two are only used in drm.ko. Can you please move them to drm_crtc_internal.h too and drop the EXPORT_SYMBOL in a follow-up patch? We're trying to limit the exported interface and official headers to really only the pieces drivers actually need.

Sure, I'll add this to my next drm_panic series.

Quoted 14 lines

Thanks, Sima

Quoted 10 lines
include/drm/drm_panic.h +1 -0
  #else
 
+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) {}
 
Signature · 1 line
2.45.2

Best regards,

Signature · 1 line
Jocelyn
author maintainer
#5 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

Quoted 69 lines · Jocelyn Falempe
Quoted 42 lines · Daniel Vetter
Quoted 27 lines · Jocelyn Falempe

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
  drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++ include/drm/drm_panic.h     |  2 ++

  2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +10 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct 
 drm_plane *plane, int index)
   static void debugfs_register_plane(struct drm_plane *plane, int index) {}
   #endif /* CONFIG_DRM_PANIC_DEBUG */
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+    struct drm_plane *plane;
+

drivers/gpu/drm/drm_panic.c static void debugfs_register_plane(struct · line 725

Quoted 10 lines
drivers/gpu/drm/drm_panic.c +9 -0
+    if (!dev->mode_config.num_total_plane)
+        return false;
+
+    drm_for_each_plane(plane, dev)
+        if (plane->helper_private && 
 plane->helper_private->get_scanout_buffer)
+            return true;
+    return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);

This feels like overkill since you currently only have one user in the fbdev emulation code, but maybe useful in some other places ...

Quoted 14 lines

include/drm/drm_panic.h struct drm_scanout_buffer { · line 149

Quoted 11 lines
drivers/gpu/drm/drm_panic.c +1 -0
+
   /**
    * drm_panic_register() - Initialize DRM panic for a device

   * @dev: the drm device on which the panic screen will be displayed.

include/drm/drm_panic.h +1 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
   #ifdef CONFIG_DRM_PANIC
+bool drm_panic_is_enabled(struct drm_device *dev);

Since it's internal only, this should be in drivers/gpu/drm/drm_crtc_internal.h and not int he include for drivers.

Yes, that makes sense, drivers won't need that API.

Quoted 7 lines

With that:

Quoted 2 lines
include/drm/drm_panic.h +0 -0
   void drm_panic_register(struct drm_device *dev);
   void drm_panic_unregister(struct drm_device *dev);
Quoted 6 lines
Quoted 4 lines

These two are only used in drm.ko. Can you please move them to drm_crtc_internal.h too and drop the EXPORT_SYMBOL in a follow-up patch? We're trying to limit the exported interface and official headers to really only the pieces drivers actually need.

Sure, I'll add this to my next drm_panic series.

I think this also applies to drm_panic_init() and drm_panic_exit(), that I introduce in my QR code series:
https://patchwork.freedesktop.org/patch/604890/?series=135944&rev=2
I will move them to drm_crtc_internal.h

Quoted 15 lines
Quoted 12 lines

Thanks, Sima

Quoted 7 lines
include/drm/drm_panic.h +1 -0
   #else
+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) {}
Signature · 1 line
2.45.2

Best regards,

#6 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

Quoted 78 lines · Jocelyn Falempe
Quoted 75 lines · Jocelyn Falempe
Quoted 43 lines · Daniel Vetter
Quoted 28 lines · Jocelyn Falempe

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
  drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++ include/drm/drm_panic.h     |  2 ++

  2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +10 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct
 drm_plane *plane, int index)
   static void debugfs_register_plane(struct drm_plane *plane,
 int index) {}
   #endif /* CONFIG_DRM_PANIC_DEBUG */
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+    struct drm_plane *plane;
+

drivers/gpu/drm/drm_panic.c static void debugfs_register_plane(struct · line 726

Quoted 10 lines
drivers/gpu/drm/drm_panic.c +9 -0
+    if (!dev->mode_config.num_total_plane)
+        return false;
+
+    drm_for_each_plane(plane, dev)
+        if (plane->helper_private &&
 plane->helper_private->get_scanout_buffer)
+            return true;
+    return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);

This feels like overkill since you currently only have one user in the fbdev emulation code, but maybe useful in some other places ...

Quoted 14 lines

include/drm/drm_panic.h struct drm_scanout_buffer { · line 149

Quoted 11 lines
drivers/gpu/drm/drm_panic.c +1 -0
+
   /**

   * drm_panic_register() - Initialize DRM panic for a device
   * @dev: the drm device on which the panic screen will be displayed.

include/drm/drm_panic.h +1 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
   #ifdef CONFIG_DRM_PANIC
+bool drm_panic_is_enabled(struct drm_device *dev);

Since it's internal only, this should be in drivers/gpu/drm/drm_crtc_internal.h and not int he include for drivers.

Yes, that makes sense, drivers won't need that API.

Quoted 11 lines

With that:

include/drm/drm_panic.h struct drm_scanout_buffer { · line 153

Quoted 2 lines
include/drm/drm_panic.h +0 -0
   void drm_panic_register(struct drm_device *dev);
   void drm_panic_unregister(struct drm_device *dev);

These two are only used in drm.ko. Can you please move them to drm_crtc_internal.h too and drop the EXPORT_SYMBOL in a follow-up patch? We're trying to limit the exported interface and official headers to really only the pieces drivers actually need.

Quoted 6 lines
Quoted 1 line

Sure, I'll add this to my next drm_panic series.

I think this also applies to drm_panic_init() and drm_panic_exit(), that I introduce in my QR code series:
https://patchwork.freedesktop.org/patch/604890/?series=135944&rev=2
I will move them to drm_crtc_internal.h

Yup.
-Sima

Quoted 17 lines
Quoted 16 lines
Quoted 13 lines

Thanks, Sima

Quoted 7 lines
include/drm/drm_panic.h +1 -0
   #else
+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) {}
Signature · 1 line
2.45.2

Best regards,

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#7 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

In reply to Jocelyn Falempe

Hi,

Quoted 45 lines · Jocelyn Falempe

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
 drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++
 include/drm/drm_panic.h     |  2 ++
 2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +20 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct drm_plane *plane, int index)
 static void debugfs_register_plane(struct drm_plane *plane, int index) {}
 #endif /* CONFIG_DRM_PANIC_DEBUG */
 
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+	struct drm_plane *plane;
+
+	if (!dev->mode_config.num_total_plane)
+		return false;
+
+	drm_for_each_plane(plane, dev)
+		if (plane->helper_private && plane->helper_private->get_scanout_buffer)
+			return true;
+	return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);
+
 /**
  * drm_panic_register() - Initialize DRM panic for a device
  * @dev: the drm device on which the panic screen will be displayed.
include/drm/drm_panic.h +0 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644

include/drm/drm_panic.h struct drm_scanout_buffer { · line 157

Quoted 10 lines
include/drm/drm_panic.h +2 -0
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
 
 #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);
 
 #else
 
+bool drm_panic_is_enabled(struct drm_device *dev) {return false; }

This was moved to drivers/gpu/drm/drm_crtc_internal.h in the applied version and I can't find that version on the mailing list; imo this kind of change requires a resend.

Also, the above breaks CONFIG_DRM_PANIC=n builds:

In file included from drivers/gpu/drm/drm_atomic_uapi.c:43:
drivers/gpu/drm/drm_crtc_internal.h:322:6: error: no previous prototype for ‘drm_panic_is_enabled’ [-Werror=missing-prototypes]
322 | bool drm_panic_is_enabled(struct drm_device *dev) {return false; }

Stubs like the above must be an inline function.

Quoted 6 lines
include/drm/drm_panic.h +0 -0
 static inline void drm_panic_register(struct drm_device *dev) {}
 static inline void drm_panic_unregister(struct drm_device *dev) {}
 
Signature · 1 line
2.45.2
author maintainer
#8 lore raw

Re: [PATCH 1/3] drm/panic: Add drm_panic_is_enabled()

Quoted 55 lines · Imre Deak

Hi,

Quoted 52 lines · Jocelyn Falempe

It allows to check if the drm device supports drm_panic. Prepare the work to have better integration with fbcon and vtconsole.

---
  drivers/gpu/drm/drm_panic.c | 20 ++++++++++++++++++++
  include/drm/drm_panic.h     |  2 ++
  2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_panic.c +20 -0
index 948aed00595e..d9a25c2d0a65 100644
@@ -703,6 +703,26 @@ static void debugfs_register_plane(struct drm_plane *plane, int index)
  static void debugfs_register_plane(struct drm_plane *plane, int index) {}
  #endif /* CONFIG_DRM_PANIC_DEBUG */
 
+/**
+ * drm_panic_is_enabled
+ * @dev: the drm device that may supports drm_panic
+ *
+ * returns true if the drm device supports drm_panic
+ */
+bool drm_panic_is_enabled(struct drm_device *dev)
+{
+	struct drm_plane *plane;
+
+	if (!dev->mode_config.num_total_plane)
+		return false;
+
+	drm_for_each_plane(plane, dev)
+		if (plane->helper_private && plane->helper_private->get_scanout_buffer)
+			return true;
+	return false;
+}
+EXPORT_SYMBOL(drm_panic_is_enabled);
+
  /**
   * drm_panic_register() - Initialize DRM panic for a device
   * @dev: the drm device on which the panic screen will be displayed.
include/drm/drm_panic.h +1 -0
index 73bb3f3d9ed9..c3a358dc3e27 100644
@@ -148,11 +148,13 @@ struct drm_scanout_buffer {
 
  #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);
 
Quoted 7 lines

include/drm/drm_panic.h struct drm_scanout_buffer { · line 157

Quoted 3 lines
include/drm/drm_panic.h +1 -0
  #else
 
+bool drm_panic_is_enabled(struct drm_device *dev) {return false; }

This was moved to drivers/gpu/drm/drm_crtc_internal.h in the applied version and I can't find that version on the mailing list; imo this kind of change requires a resend.

Sorry, I though that was a minor change, but I messed it up.

Yes sending to the mailing list also triggers the CI, and checks for simple errors like this, I will send a fix shortly.

Quoted 16 lines

Also, the above breaks CONFIG_DRM_PANIC=n builds:

In file included from drivers/gpu/drm/drm_atomic_uapi.c:43:
drivers/gpu/drm/drm_crtc_internal.h:322:6: error: no previous prototype for ‘drm_panic_is_enabled’ [-Werror=missing-prototypes]
322 | bool drm_panic_is_enabled(struct drm_device *dev) {return false; }

Stubs like the above must be an inline function.

Quoted 6 lines
include/drm/drm_panic.h +0 -0
  static inline void drm_panic_register(struct drm_device *dev) {}
  static inline void drm_panic_unregister(struct drm_device *dev) {}
 
Signature · 1 line
2.45.2
author maintainer
#9 lore raw

PATCH 2/3 fbcon: Add an option to disable fbcon in panic.

In reply to Jocelyn Falempe

This is required to avoid conflict between DRM_PANIC, and fbcon. If a drm device already handle panic with drm_panic, it should set the skip_panic field in fb_info, so that fbcon will stay quiet, and not overwrite the panic_screen.

---
 drivers/gpu/drm/drm_fb_helper.c  | 2 ++
 drivers/video/fbdev/core/fbcon.c | 7 ++++++-
 include/linux/fb.h               | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +2 -0
index e2e19f49342e..3662d664d8f9 100644
@@ -40,6 +40,7 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_modeset_helper_vtables.h>
+#include <drm/drm_panic.h>
 #include <drm/drm_print.h>
 #include <drm/drm_vblank.h>
 
@@ -524,6 +525,7 @@ struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper)
 	fb_helper->info = info;
 	info->skip_vt_switch = true;
 
+	info->skip_panic = drm_panic_is_enabled(fb_helper->dev);
 	return info;
 
 err_release:
drivers/video/fbdev/core/fbcon.c +6 -1
index 3f7333dca508..498d9c07df80 100644
@@ -270,12 +270,17 @@ static int fbcon_get_rotate(struct fb_info *info)
 	return (ops) ? ops->rotate : 0;
 }
 
+static bool fbcon_skip_panic(struct fb_info *info)
+{
+	return (info->skip_panic && unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID));
+}
+
 static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
 {
 	struct fbcon_ops *ops = info->fbcon_par;
 
 	return (info->state != FBINFO_STATE_RUNNING ||
-		vc->vc_mode != KD_TEXT || ops->graphics);
+		vc->vc_mode != KD_TEXT || ops->graphics || fbcon_skip_panic(info));
 }
 
 static int get_color(struct vc_data *vc, struct fb_info *info,
include/linux/fb.h +1 -0
index db7d97b10964..865dad03e73e 100644
@@ -510,6 +510,7 @@ struct fb_info {
 	void *par;
 
 	bool skip_vt_switch; /* no VT switch on suspend/resume required */
+	bool skip_panic; /* Do not write to the fb after a panic */
 };
 
 /* This will go away
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 2/3
#10 lore raw

Re: [PATCH 2/3] fbcon: Add an option to disable fbcon in panic.

Quoted 7 lines · Jocelyn Falempe

This is required to avoid conflict between DRM_PANIC, and fbcon. If a drm device already handle panic with drm_panic, it should set the skip_panic field in fb_info, so that fbcon will stay quiet, and not overwrite the panic_screen.

---

This makes sense to me as well.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Reviewed-by on v1 2/3
#11 lore raw

Re: [PATCH 2/3] fbcon: Add an option to disable fbcon in panic.

In reply to Jocelyn Falempe
Quoted 25 lines · Jocelyn Falempe

This is required to avoid conflict between DRM_PANIC, and fbcon. If a drm device already handle panic with drm_panic, it should set the skip_panic field in fb_info, so that fbcon will stay quiet, and not overwrite the panic_screen.

---
 drivers/gpu/drm/drm_fb_helper.c  | 2 ++
 drivers/video/fbdev/core/fbcon.c | 7 ++++++-
 include/linux/fb.h               | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -0
index e2e19f49342e..3662d664d8f9 100644
@@ -40,6 +40,7 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_modeset_helper_vtables.h>
+#include <drm/drm_panic.h>
 #include <drm/drm_print.h>
 #include <drm/drm_vblank.h>
 

drivers/gpu/drm/drm_fb_helper.c struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper) · line 531

Quoted 7 lines
drivers/gpu/drm/drm_fb_helper.c +1 -0
@@ -524,6 +525,7 @@ struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper)
 	fb_helper->info = info;
 	info->skip_vt_switch = true;
 
+	info->skip_panic = drm_panic_is_enabled(fb_helper->dev);
 	return info;
 
 err_release:

Bit a bikeshed, but I'd split this patch out since it's for drm's fbdev emulation, not the fbcon core code. With that:

Quoted 38 lines
drivers/video/fbdev/core/fbcon.c +6 -1
index 3f7333dca508..498d9c07df80 100644
@@ -270,12 +270,17 @@ static int fbcon_get_rotate(struct fb_info *info)
 	return (ops) ? ops->rotate : 0;
 }
 
+static bool fbcon_skip_panic(struct fb_info *info)
+{
+	return (info->skip_panic && unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID));
+}
+
 static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
 {
 	struct fbcon_ops *ops = info->fbcon_par;
 
 	return (info->state != FBINFO_STATE_RUNNING ||
-		vc->vc_mode != KD_TEXT || ops->graphics);
+		vc->vc_mode != KD_TEXT || ops->graphics || fbcon_skip_panic(info));
 }
 
 static int get_color(struct vc_data *vc, struct fb_info *info,
include/linux/fb.h +1 -0
index db7d97b10964..865dad03e73e 100644
@@ -510,6 +510,7 @@ struct fb_info {
 	void *par;
 
 	bool skip_vt_switch; /* no VT switch on suspend/resume required */
+	bool skip_panic; /* Do not write to the fb after a panic */
 };
 
 /* This will go away
Signature · 1 line
2.45.2
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author maintainer
#12 lore raw

Re: [PATCH 2/3] fbcon: Add an option to disable fbcon in panic.

Quoted 32 lines · Daniel Vetter
Quoted 31 lines · Jocelyn Falempe

This is required to avoid conflict between DRM_PANIC, and fbcon. If a drm device already handle panic with drm_panic, it should set the skip_panic field in fb_info, so that fbcon will stay quiet, and not overwrite the panic_screen.

---
  drivers/gpu/drm/drm_fb_helper.c  | 2 ++
  drivers/video/fbdev/core/fbcon.c | 7 ++++++-
  include/linux/fb.h               | 1 +
  3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +2 -0
index e2e19f49342e..3662d664d8f9 100644
@@ -40,6 +40,7 @@
  #include <drm/drm_fourcc.h>
  #include <drm/drm_framebuffer.h>
  #include <drm/drm_modeset_helper_vtables.h>
+#include <drm/drm_panic.h>
  #include <drm/drm_print.h>
  #include <drm/drm_vblank.h>
 
@@ -524,6 +525,7 @@ struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper)
  	fb_helper->info = info;
  	info->skip_vt_switch = true;
 
+	info->skip_panic = drm_panic_is_enabled(fb_helper->dev);
  	return info;
 
Quoted 6 lines

drivers/gpu/drm/drm_fb_helper.c struct fb_info *drm_fb_helper_alloc_info(struct drm_fb_helper *fb_helper) · line 531

Quoted 1 line
drivers/gpu/drm/drm_fb_helper.c +0 -0
  err_release:

Bit a bikeshed, but I'd split this patch out since it's for drm's fbdev emulation, not the fbcon core code. With that:

Agreed, I considered doing that when writing the patch, but as it was 1 line, I kept it with the fbcon change.

Thanks,

Signature · 1 line
Jocelyn
Quoted 1 line
author maintainer
#13 lore raw

PATCH 3/3 drm/panic: Remove build time dependency with FRAMEBUFFER_CONSOLE

In reply to Jocelyn Falempe

Now that fbcon has the skip_panic option, there is no more conflicts between drm_panic and fbcon.
Remove the build time dependency, so they can be both enabled.

---
 drivers/gpu/drm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +1 -1
index 6dd0016fc9cd..a22cab218004 100644
@@ -107,7 +107,7 @@ config DRM_KMS_HELPER
 
 config DRM_PANIC
 	bool "Display a user-friendly message when a kernel panic occurs"
-	depends on DRM && !(FRAMEBUFFER_CONSOLE && VT_CONSOLE)
+	depends on DRM
 	select FONT_SUPPORT
 	help
 	  Enable a drm panic handler, which will display a user-friendly message
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 3/3
#14 lore raw
Quoted 14 lines · Jocelyn Falempe

Now that fbcon has the skip_panic option, there is no more conflicts between drm_panic and fbcon.
Remove the build time dependency, so they can be both enabled.

---
 drivers/gpu/drm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +0 -0
index 6dd0016fc9cd..a22cab218004 100644

drivers/gpu/drm/Kconfig config DRM_KMS_HELPER · line 110

Quoted 5 lines
drivers/gpu/drm/Kconfig +1 -1
@@ -107,7 +107,7 @@ config DRM_KMS_HELPER
 
 config DRM_PANIC
 	bool "Display a user-friendly message when a kernel panic occurs"
-	depends on DRM && !(FRAMEBUFFER_CONSOLE && VT_CONSOLE)
+	depends on DRM

This is great. Thanks for finding an alternative approach! I don't see any issues this time, because there is no locking involved. But let's see what others think about it.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Reviewed-by
#15 lore raw
Quoted 17 lines · Javier Martinez Canillas
Quoted 15 lines · Jocelyn Falempe

Now that fbcon has the skip_panic option, there is no more conflicts between drm_panic and fbcon.
Remove the build time dependency, so they can be both enabled.

---
 drivers/gpu/drm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +0 -0
index 6dd0016fc9cd..a22cab218004 100644
@@ -107,7 +107,7 @@ config DRM_KMS_HELPER
 
Quoted 8 lines

drivers/gpu/drm/Kconfig config DRM_KMS_HELPER · line 110

Quoted 4 lines
drivers/gpu/drm/Kconfig +1 -1
 config DRM_PANIC
 	bool "Display a user-friendly message when a kernel panic occurs"
-	depends on DRM && !(FRAMEBUFFER_CONSOLE && VT_CONSOLE)
+	depends on DRM

This is great. Thanks for finding an alternative approach! I don't see any issues this time, because there is no locking involved. But let's see what others think about it.

Looks like it should work, I did check the history of fbcon_is_active and we've used that to force/disable panic output for fbcon in the past. So I think it's the right tool.

Quoted 1 line

Cheers, Sima

Quoted 8 lines
Signature · 6 lines
-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author maintainer
#16 lore raw
In reply to Jocelyn Falempe
Quoted 6 lines · Jocelyn Falempe

When proposing to enable DRM_PANIC on Fedora, some users raised concern about the need to disable VT_CONSOLE.
So this is my new attempt to avoid fbcon/vt_console to overwrite the panic screen.
This time it doesn't involve any locking, so it should be safe.
I added a skip_panic option in struct fb_info, and check if this option and the panic_cpu are set in fb_is_inactive(), to prevent any framebuffer operation. Also skip_panic is only true if the drm driver supports drm_panic, so you will still get the VT panic info on drivers that don't have drm_panic support yet.

Thanks all,

I've just pushed them to drm-misc-next, with the required changes. (splitting patch 2 in 2, and moving function prototype to drm_crtc_internal.h).

Best regards,

Signature · 1 line
Jocelyn
Quoted 15 lines

Jocelyn Falempe (3):
drm/panic: Add drm_panic_is_enabled()
fbcon: Add an option to disable fbcon in panic. drm/panic: Remove build time dependency with FRAMEBUFFER_CONSOLE

  drivers/gpu/drm/Kconfig          |  2 +-
  drivers/gpu/drm/drm_fb_helper.c  |  2 ++
  drivers/gpu/drm/drm_panic.c      | 20 ++++++++++++++++++++
  drivers/video/fbdev/core/fbcon.c |  7 ++++++-
  include/drm/drm_panic.h          |  2 ++
  include/linux/fb.h               |  1 +
  6 files changed, 32 insertions(+), 2 deletions(-)

base-commit: a237f217bad50c381773da5b00442710d1449098