Skip to contentSkip to conversation

add drm_panic_support for vmwgfx-stdu

PATCH In review Ryosuke Yasuoka 2 participants 4 messages Sep 19, 2025 – Oct 23, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover add drm_panic_support for vmwgfx-stdu

Add drm_panic support for stdu in vmwgfx. This patch was tested in a VM with VMSVGA on Virtual Box.

Based on the feedback for v2 patch, I've made the following updates in my v3 patch.
- Use MEMREMAP_WB | MEMREMAP_DEC flags for memremap
- Use vmw_priv->initial_height and initial_width for sb and VRAM
- Move all panic related functions to the vmwgfx_kms.c file
- Ensure if the current display unit is 0 in get_scanout_buffer()

I did not apply all of Ian's feedback in this v3 patch for the reasons outlined below.

Quoted 2 lines

1. You can call vmw_kms_write_svga directly in panic_flush. There is no need to mark the buffer as dirty or send any commands.

In my test environment (VirtualBox), the panic screen appears unstably without dirty command's submission. Without it, the screen sometimes appears immediately as expected, and at other times, there's a delay of 15 to 20 seconds. I've also observed that it sometimes only appears after switching between the VirtualBox console window and other windows.

With command submission, we can stably get a panic screen. Even if it fails, we may get the panic screen ultimately. Therefore, I think we should retain vmw_kms_panic_do_bo_dirty() to submit commands.

Quoted 2 lines

2. The format should be hardcoded to RGB565 to minimize the risk of overrunning VRAM. Adjust the pitch accordingly to 2x width.

While it's possible to output the panic screen with RGB565 by adjusting pitch and width, and BPP on the (virtual) hardware side, this approach causes debugfs to fail. It appears that the BPP must be reset after the panic screen is displayed, and there is no way to wait for the screen to be fully displayed within the drm_panic handler code.

In my test environment, as VRAM has enough space even when using XRGB8888 (32 bits), I think the risk of overruning VRAM is low. So I've kept the default format and CPP size.

v1:
https://lore.kernel.org/all/[email protected]/

v2:
https://lore.kernel.org/all/[email protected]/
- Map a scanout_buffer to VRAM in .get_scanout_buffer
- And then write to VRAM directly using fifo in legacy mode to avoid allocations or command submissions.

Ryosuke Yasuoka (1):
drm/vmwgfx: add drm_panic support for stdu mode

 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |   4 +
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 165 +++++++++++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |   2 +
 3 files changed, 171 insertions(+)

base-commit: d41c79838c47bc822534cd53628fe5e0f8ad2424

Signature · 1 line
2.51.0
#1 lore raw

PATCH v3 1/1 drm/vmwgfx: add drm_panic support for stdu mode

Add drm_panic module for vmwgfx stdu mode so that panic screen can be displayed on panic. Since implemented by writing to VRAM and switching back to legacy mode, it would expect to work in all DU modes.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |   4 +
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 165 +++++++++++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |   2 +
 3 files changed, 171 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +4 -0
index eda5b6f8f4c4..1259112ee2c2 100644
@@ -16,6 +16,7 @@
 #include <drm/drm_auth.h>
 #include <drm/drm_device.h>
 #include <drm/drm_file.h>
+#include <drm/drm_panic.h>
 #include <drm/drm_rect.h>
 
 #include <drm/ttm/ttm_execbuf_util.h>
@@ -1046,6 +1047,9 @@ void vmw_kms_lost_device(struct drm_device *dev);
 extern int vmw_resource_pin(struct vmw_resource *res, bool interruptible);
 extern void vmw_resource_unpin(struct vmw_resource *res);
 extern enum vmw_res_type vmw_res_type(const struct vmw_resource *res);
+int vmw_primary_plane_get_scanout_buffer(struct drm_plane *plane,
+					 struct drm_scanout_buffer *sb);
+void vmw_primary_plane_panic_flush(struct drm_plane *plane);
 
 /**
  * Overlay control - vmwgfx_overlay.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +165 -0

168 lines not on this page · raw message

drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +2 -0
index 20aab725e53a..93c02308d44b 100644
@@ -1506,6 +1506,8 @@ drm_plane_helper_funcs vmw_stdu_primary_plane_helper_funcs = {
 	.atomic_update = vmw_stdu_primary_plane_atomic_update,
 	.prepare_fb = vmw_stdu_primary_plane_prepare_fb,
 	.cleanup_fb = vmw_stdu_primary_plane_cleanup_fb,
+	.get_scanout_buffer = vmw_primary_plane_get_scanout_buffer,
+	.panic_flush = vmw_primary_plane_panic_flush,
 };
 
 static const struct drm_crtc_helper_funcs vmw_stdu_crtc_helper_funcs = {
Signature · 1 line
2.51.0
#2 lore raw
In reply to Ryosuke Yasuoka
Quoted 52 lines · Ryosuke Yasuoka

Add drm_panic support for stdu in vmwgfx. This patch was tested in a VM with VMSVGA on Virtual Box.

Based on the feedback for v2 patch, I've made the following updates in my v3 patch.
- Use MEMREMAP_WB | MEMREMAP_DEC flags for memremap
- Use vmw_priv->initial_height and initial_width for sb and VRAM
- Move all panic related functions to the vmwgfx_kms.c file
- Ensure if the current display unit is 0 in get_scanout_buffer()

I did not apply all of Ian's feedback in this v3 patch for the reasons outlined below.

Quoted 2 lines

1. You can call vmw_kms_write_svga directly in panic_flush. There is no need to mark the buffer as dirty or send any commands.

In my test environment (VirtualBox), the panic screen appears unstably without dirty command's submission. Without it, the screen sometimes appears immediately as expected, and at other times, there's a delay of 15 to 20 seconds. I've also observed that it sometimes only appears after switching between the VirtualBox console window and other windows.

With command submission, we can stably get a panic screen. Even if it fails, we may get the panic screen ultimately. Therefore, I think we should retain vmw_kms_panic_do_bo_dirty() to submit commands.

Quoted 2 lines

2. The format should be hardcoded to RGB565 to minimize the risk of overrunning VRAM. Adjust the pitch accordingly to 2x width.

While it's possible to output the panic screen with RGB565 by adjusting pitch and width, and BPP on the (virtual) hardware side, this approach causes debugfs to fail. It appears that the BPP must be reset after the panic screen is displayed, and there is no way to wait for the screen to be fully displayed within the drm_panic handler code.

In my test environment, as VRAM has enough space even when using XRGB8888 (32 bits), I think the risk of overruning VRAM is low. So I've kept the default format and CPP size.

v1:
https://lore.kernel.org/all/[email protected]/

v2:
https://lore.kernel.org/all/[email protected]/
- Map a scanout_buffer to VRAM in .get_scanout_buffer
- And then write to VRAM directly using fifo in legacy mode to avoid allocations or command submissions.

Ryosuke Yasuoka (1):
drm/vmwgfx: add drm_panic support for stdu mode

Quoted 9 lines
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |   4 +
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 165 +++++++++++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |   2 +
 3 files changed, 171 insertions(+)

base-commit: d41c79838c47bc822534cd53628fe5e0f8ad2424

Signature · 1 line
2.51.0

Hi all,

This is a gentle reminder for this v3 patch.
I would appreciate any feedback when you have a chance.

Ian, your feedback on v1 and v2 were very helpful. I would appreciate it if you could take another look when you have a moment.

Any comments are welcome.

Thank you
Ryosuke

#3 lore raw

If it doesn't work on vbox that's not really our problem. I've sent my version [1] that works on Workstation and ESXI.
Since it has less code it has a much higher chance of succeeding in a panic situation which is what we care about.
Feel free to add whatever tags you feel are appropriate on that patch review.

[1] https://lore.kernel.org/dri-devel/[email protected]/T/#u

Ian,

Quoted 77 lines · Ryosuke Yasuoka
Quoted 58 lines · Ryosuke Yasuoka

Add drm_panic support for stdu in vmwgfx. This patch was tested in a VM with VMSVGA on Virtual Box.

Based on the feedback for v2 patch, I've made the following updates in my v3 patch.
- Use MEMREMAP_WB | MEMREMAP_DEC flags for memremap
- Use vmw_priv->initial_height and initial_width for sb and VRAM
- Move all panic related functions to the vmwgfx_kms.c file
- Ensure if the current display unit is 0 in get_scanout_buffer()

I did not apply all of Ian's feedback in this v3 patch for the reasons outlined below.

Quoted 2 lines

1. You can call vmw_kms_write_svga directly in panic_flush. There is no need to mark the buffer as dirty or send any commands.

In my test environment (VirtualBox), the panic screen appears unstably without dirty command's submission. Without it, the screen sometimes appears immediately as expected, and at other times, there's a delay of 15 to 20 seconds. I've also observed that it sometimes only appears after switching between the VirtualBox console window and other windows.

With command submission, we can stably get a panic screen. Even if it fails, we may get the panic screen ultimately. Therefore, I think we should retain vmw_kms_panic_do_bo_dirty() to submit commands.

Quoted 2 lines

2. The format should be hardcoded to RGB565 to minimize the risk of overrunning VRAM. Adjust the pitch accordingly to 2x width.

While it's possible to output the panic screen with RGB565 by adjusting pitch and width, and BPP on the (virtual) hardware side, this approach causes debugfs to fail. It appears that the BPP must be reset after the panic screen is displayed, and there is no way to wait for the screen to be fully displayed within the drm_panic handler code.

In my test environment, as VRAM has enough space even when using XRGB8888 (32 bits), I think the risk of overruning VRAM is low. So I've kept the default format and CPP size.

v1:
https://lore.kernel.org/all/[email protected]/

v2:
https://lore.kernel.org/all/[email protected]/
- Map a scanout_buffer to VRAM in .get_scanout_buffer
- And then write to VRAM directly using fifo in legacy mode to avoid allocations or command submissions.

Ryosuke Yasuoka (1):
drm/vmwgfx: add drm_panic support for stdu mode

 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |   4 +
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 165 +++++++++++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |   2 +
 3 files changed, 171 insertions(+)
Quoted 3 lines

base-commit: d41c79838c47bc822534cd53628fe5e0f8ad2424 --
2.51.0

Hi all,

This is a gentle reminder for this v3 patch.
I would appreciate any feedback when you have a chance.

Ian, your feedback on v1 and v2 were very helpful. I would appreciate it if you could take another look when you have a moment.

Any comments are welcome.

Thank you
Ryosuke