linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH drm-next] drm/bochs: Add support for drm_panic
@ 2025-06-13 13:20 Ryosuke Yasuoka
  2025-06-19  6:12 ` Jocelyn Falempe
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-06-13 13:20 UTC (permalink / raw)
  To: kraxel, maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	jfalempe
  Cc: Ryosuke Yasuoka, virtualization, linux-kernel, dri-devel

Add drm_panic moudle for bochs drm so that panic screen can be displayed
on panic.

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
 drivers/gpu/drm/tiny/bochs.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index 8706763af8fb..ed42ad5c4927 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -19,6 +19,7 @@
 #include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_managed.h>
 #include <drm/drm_module.h>
+#include <drm/drm_panic.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_probe_helper.h>
 
@@ -469,10 +470,28 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	bochs_hw_setformat(bochs, fb->format);
 }
 
+static int bochs_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane,
+							  struct drm_scanout_buffer *sb)
+{
+	struct bochs_device *bochs = to_bochs_device(plane->dev);
+	struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map);
+
+	if (plane->state && plane->state->fb) {
+		sb->format = plane->state->fb->format;
+		sb->width = plane->state->fb->width;
+		sb->height = plane->state->fb->height;
+		sb->pitch[0] = plane->state->fb->pitches[0];
+		sb->map[0] = map;
+		return 0;
+	}
+	return -ENODEV;
+}
+
 static const struct drm_plane_helper_funcs bochs_primary_plane_helper_funcs = {
 	DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
 	.atomic_check = bochs_primary_plane_helper_atomic_check,
 	.atomic_update = bochs_primary_plane_helper_atomic_update,
+	.get_scanout_buffer = bochs_primary_plane_helper_get_scanout_buffer,
 };
 
 static const struct drm_plane_funcs bochs_primary_plane_funcs = {

base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
-- 
2.49.0


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-06-13 13:20 [PATCH drm-next] drm/bochs: Add support for drm_panic Ryosuke Yasuoka
@ 2025-06-19  6:12 ` Jocelyn Falempe
  2025-06-19  6:37   ` Ryosuke Yasuoka
  2025-06-23 10:12 ` Jocelyn Falempe
  2025-07-14  0:04 ` Askar Safin
  2 siblings, 1 reply; 11+ messages in thread
From: Jocelyn Falempe @ 2025-06-19  6:12 UTC (permalink / raw)
  To: Ryosuke Yasuoka, kraxel, maarten.lankhorst, mripard, tzimmermann,
	airlied, simona
  Cc: virtualization, linux-kernel, dri-devel

On 13/06/2025 15:20, Ryosuke Yasuoka wrote:
> Add drm_panic moudle for bochs drm so that panic screen can be displayed
> on panic.

Thanks for the patch, it's simple and looks good to me.

Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>

If no objections, I will push it next Monday.

Best regards,

-- 

Jocelyn

> 
> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> ---
>   drivers/gpu/drm/tiny/bochs.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> index 8706763af8fb..ed42ad5c4927 100644
> --- a/drivers/gpu/drm/tiny/bochs.c
> +++ b/drivers/gpu/drm/tiny/bochs.c
> @@ -19,6 +19,7 @@
>   #include <drm/drm_gem_shmem_helper.h>
>   #include <drm/drm_managed.h>
>   #include <drm/drm_module.h>
> +#include <drm/drm_panic.h>
>   #include <drm/drm_plane_helper.h>
>   #include <drm/drm_probe_helper.h>
>   
> @@ -469,10 +470,28 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
>   	bochs_hw_setformat(bochs, fb->format);
>   }
>   
> +static int bochs_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane,
> +							  struct drm_scanout_buffer *sb)
> +{
> +	struct bochs_device *bochs = to_bochs_device(plane->dev);
> +	struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map);
> +
> +	if (plane->state && plane->state->fb) {
> +		sb->format = plane->state->fb->format;
> +		sb->width = plane->state->fb->width;
> +		sb->height = plane->state->fb->height;
> +		sb->pitch[0] = plane->state->fb->pitches[0];
> +		sb->map[0] = map;
> +		return 0;
> +	}
> +	return -ENODEV;
> +}
> +
>   static const struct drm_plane_helper_funcs bochs_primary_plane_helper_funcs = {
>   	DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
>   	.atomic_check = bochs_primary_plane_helper_atomic_check,
>   	.atomic_update = bochs_primary_plane_helper_atomic_update,
> +	.get_scanout_buffer = bochs_primary_plane_helper_get_scanout_buffer,
>   };
>   
>   static const struct drm_plane_funcs bochs_primary_plane_funcs = {
> 
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-06-19  6:12 ` Jocelyn Falempe
@ 2025-06-19  6:37   ` Ryosuke Yasuoka
  2025-06-19  6:42     ` Jocelyn Falempe
  0 siblings, 1 reply; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-06-19  6:37 UTC (permalink / raw)
  To: Jocelyn Falempe
  Cc: kraxel, maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	virtualization, linux-kernel, dri-devel

On Thu, Jun 19, 2025 at 3:12 PM Jocelyn Falempe <jfalempe@redhat.com> wrote:
>
> On 13/06/2025 15:20, Ryosuke Yasuoka wrote:
> > Add drm_panic moudle for bochs drm so that panic screen can be displayed
> > on panic.
>
> Thanks for the patch, it's simple and looks good to me.
>
> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
>
> If no objections, I will push it next Monday.
>
> Best regards,
>
> --
>
> Jocelyn

Thank you Jocelyn for reviewing my patch.
Now I found a typo in the commit message; moudle -> module.

Let me fix it in v2.

Ryosuke

> >
> > Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> > ---
> >   drivers/gpu/drm/tiny/bochs.c | 19 +++++++++++++++++++
> >   1 file changed, 19 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> > index 8706763af8fb..ed42ad5c4927 100644
> > --- a/drivers/gpu/drm/tiny/bochs.c
> > +++ b/drivers/gpu/drm/tiny/bochs.c
> > @@ -19,6 +19,7 @@
> >   #include <drm/drm_gem_shmem_helper.h>
> >   #include <drm/drm_managed.h>
> >   #include <drm/drm_module.h>
> > +#include <drm/drm_panic.h>
> >   #include <drm/drm_plane_helper.h>
> >   #include <drm/drm_probe_helper.h>
> >
> > @@ -469,10 +470,28 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
> >       bochs_hw_setformat(bochs, fb->format);
> >   }
> >
> > +static int bochs_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane,
> > +                                                       struct drm_scanout_buffer *sb)
> > +{
> > +     struct bochs_device *bochs = to_bochs_device(plane->dev);
> > +     struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map);
> > +
> > +     if (plane->state && plane->state->fb) {
> > +             sb->format = plane->state->fb->format;
> > +             sb->width = plane->state->fb->width;
> > +             sb->height = plane->state->fb->height;
> > +             sb->pitch[0] = plane->state->fb->pitches[0];
> > +             sb->map[0] = map;
> > +             return 0;
> > +     }
> > +     return -ENODEV;
> > +}
> > +
> >   static const struct drm_plane_helper_funcs bochs_primary_plane_helper_funcs = {
> >       DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
> >       .atomic_check = bochs_primary_plane_helper_atomic_check,
> >       .atomic_update = bochs_primary_plane_helper_atomic_update,
> > +     .get_scanout_buffer = bochs_primary_plane_helper_get_scanout_buffer,
> >   };
> >
> >   static const struct drm_plane_funcs bochs_primary_plane_funcs = {
> >
> > base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
>


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-06-19  6:37   ` Ryosuke Yasuoka
@ 2025-06-19  6:42     ` Jocelyn Falempe
  0 siblings, 0 replies; 11+ messages in thread
From: Jocelyn Falempe @ 2025-06-19  6:42 UTC (permalink / raw)
  To: Ryosuke Yasuoka
  Cc: kraxel, maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	virtualization, linux-kernel, dri-devel

On 19/06/2025 08:37, Ryosuke Yasuoka wrote:
> On Thu, Jun 19, 2025 at 3:12 PM Jocelyn Falempe <jfalempe@redhat.com> wrote:
>>
>> On 13/06/2025 15:20, Ryosuke Yasuoka wrote:
>>> Add drm_panic moudle for bochs drm so that panic screen can be displayed
>>> on panic.
>>
>> Thanks for the patch, it's simple and looks good to me.
>>
>> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
>>
>> If no objections, I will push it next Monday.
>>
>> Best regards,
>>
>> --
>>
>> Jocelyn
> 
> Thank you Jocelyn for reviewing my patch.
> Now I found a typo in the commit message; moudle -> module.

No need to send a v2 for that, I will fix it before pushing the patch.

Thanks,

-- 

Jocelyn

> 
> Let me fix it in v2.
> 
> Ryosuke
> 
>>>
>>> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
>>> ---
>>>    drivers/gpu/drm/tiny/bochs.c | 19 +++++++++++++++++++
>>>    1 file changed, 19 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
>>> index 8706763af8fb..ed42ad5c4927 100644
>>> --- a/drivers/gpu/drm/tiny/bochs.c
>>> +++ b/drivers/gpu/drm/tiny/bochs.c
>>> @@ -19,6 +19,7 @@
>>>    #include <drm/drm_gem_shmem_helper.h>
>>>    #include <drm/drm_managed.h>
>>>    #include <drm/drm_module.h>
>>> +#include <drm/drm_panic.h>
>>>    #include <drm/drm_plane_helper.h>
>>>    #include <drm/drm_probe_helper.h>
>>>
>>> @@ -469,10 +470,28 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
>>>        bochs_hw_setformat(bochs, fb->format);
>>>    }
>>>
>>> +static int bochs_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane,
>>> +                                                       struct drm_scanout_buffer *sb)
>>> +{
>>> +     struct bochs_device *bochs = to_bochs_device(plane->dev);
>>> +     struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map);
>>> +
>>> +     if (plane->state && plane->state->fb) {
>>> +             sb->format = plane->state->fb->format;
>>> +             sb->width = plane->state->fb->width;
>>> +             sb->height = plane->state->fb->height;
>>> +             sb->pitch[0] = plane->state->fb->pitches[0];
>>> +             sb->map[0] = map;
>>> +             return 0;
>>> +     }
>>> +     return -ENODEV;
>>> +}
>>> +
>>>    static const struct drm_plane_helper_funcs bochs_primary_plane_helper_funcs = {
>>>        DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
>>>        .atomic_check = bochs_primary_plane_helper_atomic_check,
>>>        .atomic_update = bochs_primary_plane_helper_atomic_update,
>>> +     .get_scanout_buffer = bochs_primary_plane_helper_get_scanout_buffer,
>>>    };
>>>
>>>    static const struct drm_plane_funcs bochs_primary_plane_funcs = {
>>>
>>> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
>>
> 


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-06-13 13:20 [PATCH drm-next] drm/bochs: Add support for drm_panic Ryosuke Yasuoka
  2025-06-19  6:12 ` Jocelyn Falempe
@ 2025-06-23 10:12 ` Jocelyn Falempe
  2025-07-14  0:04 ` Askar Safin
  2 siblings, 0 replies; 11+ messages in thread
From: Jocelyn Falempe @ 2025-06-23 10:12 UTC (permalink / raw)
  To: Ryosuke Yasuoka, kraxel, maarten.lankhorst, mripard, tzimmermann,
	airlied, simona
  Cc: virtualization, linux-kernel, dri-devel

On 13/06/2025 15:20, Ryosuke Yasuoka wrote:
> Add drm_panic moudle for bochs drm so that panic screen can be displayed
> on panic.

I just pushed it to drm-misc-next, with the typo in the commit message 
fixed.

Thanks,

-- 

Jocelyn

> 
> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> ---
>   drivers/gpu/drm/tiny/bochs.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> index 8706763af8fb..ed42ad5c4927 100644
> --- a/drivers/gpu/drm/tiny/bochs.c
> +++ b/drivers/gpu/drm/tiny/bochs.c
> @@ -19,6 +19,7 @@
>   #include <drm/drm_gem_shmem_helper.h>
>   #include <drm/drm_managed.h>
>   #include <drm/drm_module.h>
> +#include <drm/drm_panic.h>
>   #include <drm/drm_plane_helper.h>
>   #include <drm/drm_probe_helper.h>
>   
> @@ -469,10 +470,28 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
>   	bochs_hw_setformat(bochs, fb->format);
>   }
>   
> +static int bochs_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane,
> +							  struct drm_scanout_buffer *sb)
> +{
> +	struct bochs_device *bochs = to_bochs_device(plane->dev);
> +	struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map);
> +
> +	if (plane->state && plane->state->fb) {
> +		sb->format = plane->state->fb->format;
> +		sb->width = plane->state->fb->width;
> +		sb->height = plane->state->fb->height;
> +		sb->pitch[0] = plane->state->fb->pitches[0];
> +		sb->map[0] = map;
> +		return 0;
> +	}
> +	return -ENODEV;
> +}
> +
>   static const struct drm_plane_helper_funcs bochs_primary_plane_helper_funcs = {
>   	DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
>   	.atomic_check = bochs_primary_plane_helper_atomic_check,
>   	.atomic_update = bochs_primary_plane_helper_atomic_update,
> +	.get_scanout_buffer = bochs_primary_plane_helper_get_scanout_buffer,
>   };
>   
>   static const struct drm_plane_funcs bochs_primary_plane_funcs = {
> 
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-06-13 13:20 [PATCH drm-next] drm/bochs: Add support for drm_panic Ryosuke Yasuoka
  2025-06-19  6:12 ` Jocelyn Falempe
  2025-06-23 10:12 ` Jocelyn Falempe
@ 2025-07-14  0:04 ` Askar Safin
  2025-07-15  8:57   ` Jocelyn Falempe
  2 siblings, 1 reply; 11+ messages in thread
From: Askar Safin @ 2025-07-14  0:04 UTC (permalink / raw)
  To: ryasuoka
  Cc: airlied, dri-devel, jfalempe, kraxel, linux-kernel,
	maarten.lankhorst, mripard, simona, tzimmermann, virtualization

Are normal panics (i. e. not drm panics) still supposed to work with bochs?

If yes, then I want to point out that they, in fact, don't work since 2019.
I. e. panics are not shown in Qemu if:
1) bochs is used
2) we use "normal" panics (not drm panics)

I already reported this here: https://lore.kernel.org/regressions/197f290e30b.eaadc7bc7913.7315623184036672946@zohomail.com/T/#u ,
but nobody answered.

--
Askar Safin

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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-07-14  0:04 ` Askar Safin
@ 2025-07-15  8:57   ` Jocelyn Falempe
  2025-07-15 20:35     ` Askar Safin
  0 siblings, 1 reply; 11+ messages in thread
From: Jocelyn Falempe @ 2025-07-15  8:57 UTC (permalink / raw)
  To: Askar Safin, ryasuoka
  Cc: airlied, dri-devel, kraxel, linux-kernel, maarten.lankhorst,
	mripard, simona, tzimmermann, virtualization

On 14/07/2025 02:04, Askar Safin wrote:
> Are normal panics (i. e. not drm panics) still supposed to work with bochs?

"Normal panics", is just the console logs through fbcon. The problem is 
that this is not designed to work in a panic context, so on some driver 
it can work, but it's not reliable. Also depending on the panic source 
(Like if the panic occurs in IRQ context), you probably won't see anything.
I think the regression is likely because the driver switched to use a 
shadow buffer (ie: fbcon draws to a buffer in system memory, which is 
copied to the "VRAM" in a workqueue, and workqueues are disabled in a 
panic context). So there is no easy fix for the fbcon panic.

This patch series, only take care of DRM panic. You can get the same 
output as fbcon, by selecting CONFIG_DRM_PANIC_SCREEN"kmsg".

-- 

Jocelyn

> 
> If yes, then I want to point out that they, in fact, don't work since 2019.
> I. e. panics are not shown in Qemu if:
> 1) bochs is used
> 2) we use "normal" panics (not drm panics)
> 
> I already reported this here: https://lore.kernel.org/regressions/197f290e30b.eaadc7bc7913.7315623184036672946@zohomail.com/T/#u ,
> but nobody answered.
> 
> --
> Askar Safin
> 


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-07-15  8:57   ` Jocelyn Falempe
@ 2025-07-15 20:35     ` Askar Safin
  2025-07-15 22:00       ` Jocelyn Falempe
  0 siblings, 1 reply; 11+ messages in thread
From: Askar Safin @ 2025-07-15 20:35 UTC (permalink / raw)
  To: Jocelyn Falempe
  Cc: ryasuoka, airlied, dri-devel, kraxel, linux-kernel,
	maarten.lankhorst, mripard, simona, tzimmermann, virtualization

 ---- On Tue, 15 Jul 2025 12:57:04 +0400  Jocelyn Falempe <jfalempe@redhat.com> wrote --- 
 > "Normal panics", is just the console logs through fbcon. The problem is 

Thank you for answer! Is this possible to configure system such that fbcon works normally,
VTs work normally (i. e. via framebuffer), but when panic happens, it is displayed via drm_panic? This seems to
be solution to the problem.

--
Askar Safin
https://types.pl/@safinaskar


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-07-15 20:35     ` Askar Safin
@ 2025-07-15 22:00       ` Jocelyn Falempe
  2025-07-16 21:48         ` Askar Safin
  0 siblings, 1 reply; 11+ messages in thread
From: Jocelyn Falempe @ 2025-07-15 22:00 UTC (permalink / raw)
  To: Askar Safin
  Cc: ryasuoka, airlied, dri-devel, kraxel, linux-kernel,
	maarten.lankhorst, mripard, simona, tzimmermann, virtualization

On 15/07/2025 22:35, Askar Safin wrote:
>   ---- On Tue, 15 Jul 2025 12:57:04 +0400  Jocelyn Falempe <jfalempe@redhat.com> wrote ---
>   > "Normal panics", is just the console logs through fbcon. The problem is
> 
> Thank you for answer! Is this possible to configure system such that fbcon works normally,
> VTs work normally (i. e. via framebuffer), but when panic happens, it is displayed via drm_panic? This seems to
> be solution to the problem.

Yes, that's the default if you use a drm driver like bochs with fbdev 
emulation enabled. (Of course you can't have DRM panic on a pure fbdev 
driver).

There was a concurrency problem between fbcon and DRM panic, and I've 
solved it a year ago with:
https://patchwork.freedesktop.org/series/136182/

So make sure you have the following in your .config:

CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_DRM_FBDEV_EMULATION=y
CONFIG_DRM_PANIC=y
CONFIG_DRM_PANIC_SCREEN="kmsg"

Best regards,

-- 

Jocelyn

> 
> --
> Askar Safin
> https://types.pl/@safinaskar
> 


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-07-15 22:00       ` Jocelyn Falempe
@ 2025-07-16 21:48         ` Askar Safin
  2025-07-17  9:54           ` Jocelyn Falempe
  0 siblings, 1 reply; 11+ messages in thread
From: Askar Safin @ 2025-07-16 21:48 UTC (permalink / raw)
  To: Jocelyn Falempe
  Cc: ryasuoka, airlied, dri-devel, kraxel, linux-kernel,
	maarten.lankhorst, mripard, simona, tzimmermann, virtualization

 ---- On Wed, 16 Jul 2025 02:00:56 +0400  Jocelyn Falempe <jfalempe@redhat.com> wrote --- 
 > Yes, that's the default if you use a drm driver like bochs with fbdev 

Thank you for answer! I just tried kernel from drm-tip with this config with drm_panic in qemu. And panic works.
But I don't like result.
When drm panic happens, messages printed to /dev/console disappear. Only kernel messages remain.

Here are steps to reproduce. And then I will describe how this breaks my workflow.

Compile kernel from drm-tip ( https://gitlab.freedesktop.org/drm/tip ). I used commit b012f04b5be909a307ff629b297387e0ed55195a .
It seems to include this bochs patch (i. e. "drm/bochs: Add support for drm_panic").
Use this miniconfig:

$ cat mini
CONFIG_64BIT=y

CONFIG_EXPERT=y

CONFIG_PRINTK=y
CONFIG_PRINTK_TIME=y

CONFIG_PCI=y

CONFIG_TTY=y
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_DRM=y
CONFIG_DRM_FBDEV_EMULATION=y
CONFIG_DRM_BOCHS=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_PROC_FS=y

CONFIG_DRM_PANIC=y
CONFIG_DRM_PANIC_SCREEN="kmsg"

CONFIG_BLK_DEV_INITRD=y
CONFIG_RD_GZIP=y
CONFIG_BINFMT_ELF=y
CONFIG_BINFMT_SCRIPT=y
$ make KCONFIG_ALLCONFIG=mini allnoconfig

Create initramfs, which contains exactly these files:
$ find /tmp/i -ls
     2861      0 drwxrwxr-x   3 user     user           80 Jul 16 23:56 /tmp/i
     2891      0 drwxrwxr-x   2 user     user           80 Jul 16 23:56 /tmp/i/bin
     2893      0 lrwxrwxrwx   1 user     user            7 Jul 16 23:56 /tmp/i/bin/sh -> busybox
     2892   1980 -rwxr-xr-x   1 user     user      2024544 Jul 16 23:56 /tmp/i/bin/busybox
     2864      4 -rwxrwxr-x   1 user     user           43 Jul 16 23:18 /tmp/i/init

This is "init":
===
#!/bin/sh

set -e

echo hello
sleep 3
exit 0
===

Now boot this in Qemu. I used this command:
$ qemu-system-x86_64 -enable-kvm -m 1024  -kernel arch/x86/boot/bzImage -initrd /tmp/ini.cpio.gz

You will see word "hello", then after 3 seconds the system will fail into drm panic.

What I saw: word "hello" disappeared, when the system falled into panic
What I expected to see: word "hello" should remain.

Now let me describe how this breaks my workflow.

I often use hand-crafted shell scripts as PID 1. Both in Qemu and on real hardware.
I use them to reproduce and bisect various kernel bugs.
I always put "set -e" in the beginning of shell script. This means that script fails after first error.
And thus system fails into kernel panic.
I also sometimes put "set -x" to debug these scripts.
Thus, when script fails and panic happens, then faulty shell command will be last thing printed on screen before panic stacktrace.
But with drm_panic everything printed to /dev/console disappears.
This breaks my workflow.

In Qemu I can easily workaround this by using serial console.

But I cannot do this on real hardware.

And yes, I experience fbcon panic problems on real hardware, too, this is why I'm interested in drm panic: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14658

(I have not yet tested whether drm_panic fixes that fbcon i915 panic problem, but I assume it does.)

I can workaround this by using efi fb with fb panic as opposed to i915. But this will not work if I attempting to catch bug in i915 itself.
(And yes, I recently found another i915-related bug, and I'm trying to debug it using shell scripts running as PID 1.
Here it is: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14598 .)

I can workaround this by logging everything to disk.
But this will not work when everything is mounted read-only.
And this is exactly what happens, when I try to catch that kexec-related bug:
immediately before issuing "kexec -e" command I mount everything read-only.

The only remaining workaround is to redirect everything to /dev/kmsg.
I. e. put "exec > /dev/kmsg 2>&1" to the script.
This will work.
But I still don't like this.

--
Askar Safin
https://types.pl/@safinaskar


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

* Re: [PATCH drm-next] drm/bochs: Add support for drm_panic
  2025-07-16 21:48         ` Askar Safin
@ 2025-07-17  9:54           ` Jocelyn Falempe
  0 siblings, 0 replies; 11+ messages in thread
From: Jocelyn Falempe @ 2025-07-17  9:54 UTC (permalink / raw)
  To: Askar Safin
  Cc: ryasuoka, airlied, dri-devel, kraxel, linux-kernel,
	maarten.lankhorst, mripard, simona, tzimmermann, virtualization

On 16/07/2025 23:48, Askar Safin wrote:
>   ---- On Wed, 16 Jul 2025 02:00:56 +0400  Jocelyn Falempe <jfalempe@redhat.com> wrote ---
>   > Yes, that's the default if you use a drm driver like bochs with fbdev
> 
> Thank you for answer! I just tried kernel from drm-tip with this config with drm_panic in qemu. And panic works.
> But I don't like result.
> When drm panic happens, messages printed to /dev/console disappear. Only kernel messages remain.

Yes, that's the expected behavior. DRM panic only prints the kernel 
messages, and don't mix that with console output.

> 
> Here are steps to reproduce. And then I will describe how this breaks my workflow.
> 
> Compile kernel from drm-tip ( https://gitlab.freedesktop.org/drm/tip ). I used commit b012f04b5be909a307ff629b297387e0ed55195a .
> It seems to include this bochs patch (i. e. "drm/bochs: Add support for drm_panic").
> Use this miniconfig:
> 
> $ cat mini
> CONFIG_64BIT=y
> 
> CONFIG_EXPERT=y
> 
> CONFIG_PRINTK=y
> CONFIG_PRINTK_TIME=y
> 
> CONFIG_PCI=y
> 
> CONFIG_TTY=y
> CONFIG_VT=y
> CONFIG_VT_CONSOLE=y
> CONFIG_DRM=y
> CONFIG_DRM_FBDEV_EMULATION=y
> CONFIG_DRM_BOCHS=y
> CONFIG_FRAMEBUFFER_CONSOLE=y
> CONFIG_PROC_FS=y
> 
> CONFIG_DRM_PANIC=y
> CONFIG_DRM_PANIC_SCREEN="kmsg"
> 
> CONFIG_BLK_DEV_INITRD=y
> CONFIG_RD_GZIP=y
> CONFIG_BINFMT_ELF=y
> CONFIG_BINFMT_SCRIPT=y
> $ make KCONFIG_ALLCONFIG=mini allnoconfig
> 
> Create initramfs, which contains exactly these files:
> $ find /tmp/i -ls
>       2861      0 drwxrwxr-x   3 user     user           80 Jul 16 23:56 /tmp/i
>       2891      0 drwxrwxr-x   2 user     user           80 Jul 16 23:56 /tmp/i/bin
>       2893      0 lrwxrwxrwx   1 user     user            7 Jul 16 23:56 /tmp/i/bin/sh -> busybox
>       2892   1980 -rwxr-xr-x   1 user     user      2024544 Jul 16 23:56 /tmp/i/bin/busybox
>       2864      4 -rwxrwxr-x   1 user     user           43 Jul 16 23:18 /tmp/i/init
> 
> This is "init":
> ===
> #!/bin/sh
> 
> set -e
> 
> echo hello
> sleep 3
> exit 0
> ===
> 
> Now boot this in Qemu. I used this command:
> $ qemu-system-x86_64 -enable-kvm -m 1024  -kernel arch/x86/boot/bzImage -initrd /tmp/ini.cpio.gz
> 
> You will see word "hello", then after 3 seconds the system will fail into drm panic.
> 
> What I saw: word "hello" disappeared, when the system falled into panic
> What I expected to see: word "hello" should remain.

Even with fbcon, there is no guarantee that "hello" will remain visible, 
that depends on the screen size, and the amount of logs that the kernel 
panic will print.
> 
> Now let me describe how this breaks my workflow.
> 
> I often use hand-crafted shell scripts as PID 1. Both in Qemu and on real hardware.
> I use them to reproduce and bisect various kernel bugs.
> I always put "set -e" in the beginning of shell script. This means that script fails after first error.
> And thus system fails into kernel panic.
> I also sometimes put "set -x" to debug these scripts.
> Thus, when script fails and panic happens, then faulty shell command will be last thing printed on screen before panic stacktrace.
> But with drm_panic everything printed to /dev/console disappears.
> This breaks my workflow.
> 
> In Qemu I can easily workaround this by using serial console.
> 
> But I cannot do this on real hardware.
> 
> And yes, I experience fbcon panic problems on real hardware, too, this is why I'm interested in drm panic: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14658
> 
> (I have not yet tested whether drm_panic fixes that fbcon i915 panic problem, but I assume it does.)
> 
> I can workaround this by using efi fb with fb panic as opposed to i915. But this will not work if I attempting to catch bug in i915 itself.
> (And yes, I recently found another i915-related bug, and I'm trying to debug it using shell scripts running as PID 1.
> Here it is: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14598 .)
> 
> I can workaround this by logging everything to disk.
> But this will not work when everything is mounted read-only.
> And this is exactly what happens, when I try to catch that kexec-related bug:
> immediately before issuing "kexec -e" command I mount everything read-only.
> 
> The only remaining workaround is to redirect everything to /dev/kmsg.
> I. e. put "exec > /dev/kmsg 2>&1" to the script.
> This will work.
> But I still don't like this.

This is the workaround I would suggest, as DRM panic can only access the 
kmsg data, and has no knowledge of what fbcon was doing.

If the panic occurs because the PID 1 script exits, then the panic stack 
trace is not that relevant?

Another thing you can try, is to use DRM log instead of fbcon:

DRM_CLIENT_LOG=y
DRM_CLIENT_DEFAULT_LOG=y
DRM_FBDEV_EMULATION=n
DRM_CLIENT_DEFAULT="log"
DRM_PANIC=n

(and boot with console=drm_log)

drm-log doesn't scroll the whole screen, and use the non-blocking 
console API, so is less likely to make artifacts on the screen.

But in this case, you won't get the panic trace.

Best regards,

-- 

Jocelyn


> 
> --
> Askar Safin
> https://types.pl/@safinaskar
> 


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

end of thread, other threads:[~2025-07-17  9:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 13:20 [PATCH drm-next] drm/bochs: Add support for drm_panic Ryosuke Yasuoka
2025-06-19  6:12 ` Jocelyn Falempe
2025-06-19  6:37   ` Ryosuke Yasuoka
2025-06-19  6:42     ` Jocelyn Falempe
2025-06-23 10:12 ` Jocelyn Falempe
2025-07-14  0:04 ` Askar Safin
2025-07-15  8:57   ` Jocelyn Falempe
2025-07-15 20:35     ` Askar Safin
2025-07-15 22:00       ` Jocelyn Falempe
2025-07-16 21:48         ` Askar Safin
2025-07-17  9:54           ` Jocelyn Falempe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).