Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH RFC drm-next 0/1] Add support for drm_panic
@ 2025-04-02  8:43 Ryosuke Yasuoka
  2025-04-02  8:43 ` [PATCH RFC drm-next 1/1] drm/hyperv: " Ryosuke Yasuoka
  2025-04-02  9:45 ` [PATCH RFC drm-next 0/1] " Thomas Zimmermann
  0 siblings, 2 replies; 5+ messages in thread
From: Ryosuke Yasuoka @ 2025-04-02  8:43 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	drawat.floss, jfalempe
  Cc: Ryosuke Yasuoka, dri-devel, linux-kernel, linux-hyperv

This patch adds drm_panic support for hyperv-drm driver. This function
works but it's still needed to brush up. Let me hear your opinions.

Once kernel panic occurs we expect to see a panic screen. However, to
see the screen, I need to close/re-open the graphic console client
window. As the panic screen shows correctly in the small preview
window in Hyper-V manager and debugfs API for drm_panic works correctly,
I think kernel needs to send signal to Hyper-V host that the console
client refreshes, but I have no idea what kind of signal is needed.

This patch is tested on Hyper-V 2022.

Ryosuke Yasuoka (1):
  drm/hyperv: Add support for drm_panic

 drivers/gpu/drm/drm_simple_kms_helper.c     | 26 +++++++++++++
 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 42 +++++++++++++++++++++
 include/drm/drm_simple_kms_helper.h         | 22 +++++++++++
 3 files changed, 90 insertions(+)


base-commit: cf05922d63e2ae6a9b1b52ff5236a44c3b29f78c
-- 
2.48.1


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

* [PATCH RFC drm-next 1/1] drm/hyperv: Add support for drm_panic
  2025-04-02  8:43 [PATCH RFC drm-next 0/1] Add support for drm_panic Ryosuke Yasuoka
@ 2025-04-02  8:43 ` Ryosuke Yasuoka
  2025-04-02  9:45 ` [PATCH RFC drm-next 0/1] " Thomas Zimmermann
  1 sibling, 0 replies; 5+ messages in thread
From: Ryosuke Yasuoka @ 2025-04-02  8:43 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	drawat.floss, jfalempe
  Cc: Ryosuke Yasuoka, dri-devel, linux-kernel, linux-hyperv

Add drm_panic module supports for hyperv drm so that panic screen can be
displayed on panic.

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
 drivers/gpu/drm/drm_simple_kms_helper.c     | 26 +++++++++++++
 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 42 +++++++++++++++++++++
 include/drm/drm_simple_kms_helper.h         | 22 +++++++++++
 3 files changed, 90 insertions(+)

diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
index 250819fbc5ce..508a5961d2b0 100644
--- a/drivers/gpu/drm/drm_simple_kms_helper.c
+++ b/drivers/gpu/drm/drm_simple_kms_helper.c
@@ -14,6 +14,7 @@
 #include <drm/drm_managed.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
+#include <drm/drm_panic.h>
 
 /**
  * DOC: overview
@@ -316,6 +317,29 @@ static bool drm_simple_kms_format_mod_supported(struct drm_plane *plane,
 	return modifier == DRM_FORMAT_MOD_LINEAR;
 }
 
+static int drm_simple_kms_plane_get_scanout_buffer(struct drm_plane *plane,
+						   struct drm_scanout_buffer *sb)
+{
+	struct drm_simple_display_pipe *pipe;
+
+	pipe = container_of(plane, struct drm_simple_display_pipe, plane);
+	if (!pipe->funcs || !pipe->funcs->get_scanout_buffer)
+		return -EINVAL;
+
+	return pipe->funcs->get_scanout_buffer(pipe, sb);
+}
+
+static void drm_simple_kms_plane_panic_flush(struct drm_plane *plane)
+{
+	struct drm_simple_display_pipe *pipe;
+
+	pipe = container_of(plane, struct drm_simple_display_pipe, plane);
+	if (!pipe->funcs || !pipe->funcs->panic_flush)
+		return;
+
+	pipe->funcs->panic_flush(pipe);
+}
+
 static const struct drm_plane_helper_funcs drm_simple_kms_plane_helper_funcs = {
 	.prepare_fb = drm_simple_kms_plane_prepare_fb,
 	.cleanup_fb = drm_simple_kms_plane_cleanup_fb,
@@ -323,6 +347,8 @@ static const struct drm_plane_helper_funcs drm_simple_kms_plane_helper_funcs = {
 	.end_fb_access = drm_simple_kms_plane_end_fb_access,
 	.atomic_check = drm_simple_kms_plane_atomic_check,
 	.atomic_update = drm_simple_kms_plane_atomic_update,
+	.get_scanout_buffer = drm_simple_kms_plane_get_scanout_buffer,
+	.panic_flush = drm_simple_kms_plane_panic_flush,
 };
 
 static void drm_simple_kms_plane_reset(struct drm_plane *plane)
diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
index 6c6b57298797..8e8eacb0d07f 100644
--- a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
+++ b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
@@ -16,6 +16,7 @@
 #include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
+#include <drm/drm_panic.h>
 
 #include "hyperv_drm.h"
 
@@ -146,10 +147,51 @@ static void hyperv_pipe_update(struct drm_simple_display_pipe *pipe,
 	}
 }
 
+static int hyperv_pipe_get_scanout_buffer(struct drm_simple_display_pipe *pipe,
+					  struct drm_scanout_buffer *sb)
+{
+	struct drm_plane_state *state = pipe->plane.state;
+	struct hyperv_drm_device *hv;
+	struct drm_framebuffer *fb;
+
+	if (!state || !state->fb || !state->visible)
+		return -ENODEV;
+
+	fb = state->fb;
+	hv = to_hv(fb->dev);
+
+	iosys_map_set_vaddr_iomem(&sb->map[0], hv->vram);
+	sb->format = fb->format;
+	sb->height = fb->height;
+	sb->width = fb->width;
+	sb->pitch[0] = fb->pitches[0];
+	return 0;
+}
+
+static void hyperv_pipe_panic_flush(struct drm_simple_display_pipe *pipe)
+{
+	struct drm_plane_state *state = pipe->plane.state;
+	struct hyperv_drm_device *hv;
+	struct drm_rect rect;
+
+	if (!state || !state->fb)
+		return;
+
+	rect.x1 = 0;
+	rect.y1 = 0;
+	rect.x2 = state->fb->width;
+	rect.y2 = state->fb->height;
+
+	hv = to_hv(state->fb->dev);
+	hyperv_update_dirt(hv->hdev, &rect);
+}
+
 static const struct drm_simple_display_pipe_funcs hyperv_pipe_funcs = {
 	.enable	= hyperv_pipe_enable,
 	.check = hyperv_pipe_check,
 	.update	= hyperv_pipe_update,
+	.get_scanout_buffer = hyperv_pipe_get_scanout_buffer,
+	.panic_flush = hyperv_pipe_panic_flush,
 	DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS,
 };
 
diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h
index b2486d073763..126d0d170e81 100644
--- a/include/drm/drm_simple_kms_helper.h
+++ b/include/drm/drm_simple_kms_helper.h
@@ -10,6 +10,7 @@
 #include <drm/drm_encoder.h>
 #include <drm/drm_plane.h>
 
+struct drm_scanout_buffer;
 struct drm_simple_display_pipe;
 
 /**
@@ -226,6 +227,27 @@ struct drm_simple_display_pipe_funcs {
 	 */
 	void (*destroy_plane_state)(struct drm_simple_display_pipe *pipe,
 				    struct drm_plane_state *plane_state);
+
+	/**
+	 * @get_scanout_buffer:
+	 *
+	 * Optional, called by &drm_plane_funcs.get_scanout_buffer. Please
+	 * read the documentation for the &drm_plane_funcs.get_scanout_buffer
+	 * hook for more details.
+	 *
+	 */
+	int (*get_scanout_buffer)(struct drm_simple_display_pipe *pipe,
+				  struct drm_scanout_buffer *sb);
+
+	/**
+	 * @panic_flush:
+	 *
+	 * Optional, called by &drm_plane_funcs.panic_flush. Please read the
+	 * documentation for the &drm_plane_funcs.get_scanout_buffer hook for
+	 * more details.
+	 *
+	 */
+	void (*panic_flush)(struct drm_simple_display_pipe *pipe);
 };
 
 /**
-- 
2.48.1


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

* Re: [PATCH RFC drm-next 0/1] Add support for drm_panic
  2025-04-02  8:43 [PATCH RFC drm-next 0/1] Add support for drm_panic Ryosuke Yasuoka
  2025-04-02  8:43 ` [PATCH RFC drm-next 1/1] drm/hyperv: " Ryosuke Yasuoka
@ 2025-04-02  9:45 ` Thomas Zimmermann
  2025-04-02 13:52   ` Ryosuke Yasuoka
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Zimmermann @ 2025-04-02  9:45 UTC (permalink / raw)
  To: Ryosuke Yasuoka, maarten.lankhorst, mripard, airlied, simona,
	drawat.floss, jfalempe
  Cc: dri-devel, linux-kernel, linux-hyperv

Hi

Am 02.04.25 um 10:43 schrieb Ryosuke Yasuoka:
> This patch adds drm_panic support for hyperv-drm driver. This function
> works but it's still needed to brush up. Let me hear your opinions.
>
> Once kernel panic occurs we expect to see a panic screen. However, to
> see the screen, I need to close/re-open the graphic console client
> window. As the panic screen shows correctly in the small preview
> window in Hyper-V manager and debugfs API for drm_panic works correctly,
> I think kernel needs to send signal to Hyper-V host that the console
> client refreshes, but I have no idea what kind of signal is needed.
>
> This patch is tested on Hyper-V 2022.
>
> Ryosuke Yasuoka (1):
>    drm/hyperv: Add support for drm_panic
>
>   drivers/gpu/drm/drm_simple_kms_helper.c     | 26 +++++++++++++
>   drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 42 +++++++++++++++++++++
>   include/drm/drm_simple_kms_helper.h         | 22 +++++++++++

No changes to simple_kms_helper please. This is obsolete and should go 
away. Just put everything into hyperv_drm.

Best regards
Thomas

>   3 files changed, 90 insertions(+)
>
>
> base-commit: cf05922d63e2ae6a9b1b52ff5236a44c3b29f78c

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


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

* Re: [PATCH RFC drm-next 0/1] Add support for drm_panic
  2025-04-02  9:45 ` [PATCH RFC drm-next 0/1] " Thomas Zimmermann
@ 2025-04-02 13:52   ` Ryosuke Yasuoka
  2025-04-03  7:23     ` Thomas Zimmermann
  0 siblings, 1 reply; 5+ messages in thread
From: Ryosuke Yasuoka @ 2025-04-02 13:52 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: maarten.lankhorst, mripard, airlied, simona, drawat.floss,
	jfalempe, dri-devel, linux-kernel, linux-hyperv

On Wed, Apr 2, 2025 at 6:45 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 02.04.25 um 10:43 schrieb Ryosuke Yasuoka:
> > This patch adds drm_panic support for hyperv-drm driver. This function
> > works but it's still needed to brush up. Let me hear your opinions.
> >
> > Once kernel panic occurs we expect to see a panic screen. However, to
> > see the screen, I need to close/re-open the graphic console client
> > window. As the panic screen shows correctly in the small preview
> > window in Hyper-V manager and debugfs API for drm_panic works correctly,
> > I think kernel needs to send signal to Hyper-V host that the console
> > client refreshes, but I have no idea what kind of signal is needed.
> >
> > This patch is tested on Hyper-V 2022.
> >
> > Ryosuke Yasuoka (1):
> >    drm/hyperv: Add support for drm_panic
> >
> >   drivers/gpu/drm/drm_simple_kms_helper.c     | 26 +++++++++++++
> >   drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 42 +++++++++++++++++++++
> >   include/drm/drm_simple_kms_helper.h         | 22 +++++++++++
>
> No changes to simple_kms_helper please. This is obsolete and should go
> away. Just put everything into hyperv_drm.

OK. Maybe it will work without any modification in simple_kms_helper if we can
call the pipe->funcs from draw_panic_plane() like drm_plane_helper_funcs.

Currently, the hyperv_drm is implemented with a simple display pipeline.
The pipeline control functions are in pipe->funcs and they will call via
drm_simple_kms_palne_helper_funcs. And these helper functions will
be called by drm_panic_plane().

Thank you for your comment.
Ryosuke

> Best regards
> Thomas
>
> >   3 files changed, 90 insertions(+)
> >
> >
> > base-commit: cf05922d63e2ae6a9b1b52ff5236a44c3b29f78c
>
> --
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Frankenstrasse 146, 90461 Nuernberg, Germany
> GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
> HRB 36809 (AG Nuernberg)
>


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

* Re: [PATCH RFC drm-next 0/1] Add support for drm_panic
  2025-04-02 13:52   ` Ryosuke Yasuoka
@ 2025-04-03  7:23     ` Thomas Zimmermann
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Zimmermann @ 2025-04-03  7:23 UTC (permalink / raw)
  To: Ryosuke Yasuoka
  Cc: maarten.lankhorst, mripard, airlied, simona, drawat.floss,
	jfalempe, dri-devel, linux-kernel, linux-hyperv

Hi

Am 02.04.25 um 15:52 schrieb Ryosuke Yasuoka:
> On Wed, Apr 2, 2025 at 6:45 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>> Hi
>>
>> Am 02.04.25 um 10:43 schrieb Ryosuke Yasuoka:
>>> This patch adds drm_panic support for hyperv-drm driver. This function
>>> works but it's still needed to brush up. Let me hear your opinions.
>>>
>>> Once kernel panic occurs we expect to see a panic screen. However, to
>>> see the screen, I need to close/re-open the graphic console client
>>> window. As the panic screen shows correctly in the small preview
>>> window in Hyper-V manager and debugfs API for drm_panic works correctly,
>>> I think kernel needs to send signal to Hyper-V host that the console
>>> client refreshes, but I have no idea what kind of signal is needed.
>>>
>>> This patch is tested on Hyper-V 2022.
>>>
>>> Ryosuke Yasuoka (1):
>>>     drm/hyperv: Add support for drm_panic
>>>
>>>    drivers/gpu/drm/drm_simple_kms_helper.c     | 26 +++++++++++++
>>>    drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 42 +++++++++++++++++++++
>>>    include/drm/drm_simple_kms_helper.h         | 22 +++++++++++
>> No changes to simple_kms_helper please. This is obsolete and should go
>> away. Just put everything into hyperv_drm.
> OK. Maybe it will work without any modification in simple_kms_helper if we can
> call the pipe->funcs from draw_panic_plane() like drm_plane_helper_funcs.

No problem about that. Feel free to open-code everything that you need 
in the hyperv driver.

>
> Currently, the hyperv_drm is implemented with a simple display pipeline.
> The pipeline control functions are in pipe->funcs and they will call via
> drm_simple_kms_palne_helper_funcs. And these helper functions will
> be called by drm_panic_plane().

Someone should update the hyperv driver to not use simple pipe.

Best regards
Thomas

>
> Thank you for your comment.
> Ryosuke
>
>> Best regards
>> Thomas
>>
>>>    3 files changed, 90 insertions(+)
>>>
>>>
>>> base-commit: cf05922d63e2ae6a9b1b52ff5236a44c3b29f78c
>> --
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Frankenstrasse 146, 90461 Nuernberg, Germany
>> GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
>> HRB 36809 (AG Nuernberg)
>>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


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

end of thread, other threads:[~2025-04-03  7:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02  8:43 [PATCH RFC drm-next 0/1] Add support for drm_panic Ryosuke Yasuoka
2025-04-02  8:43 ` [PATCH RFC drm-next 1/1] drm/hyperv: " Ryosuke Yasuoka
2025-04-02  9:45 ` [PATCH RFC drm-next 0/1] " Thomas Zimmermann
2025-04-02 13:52   ` Ryosuke Yasuoka
2025-04-03  7:23     ` Thomas Zimmermann

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