From c9ff2808790f0fd4ca16f30f63abe70914a5a292 Mon Sep 17 00:00:00 2001 From: Jocelyn Falempe Date: Mon, 7 Apr 2025 15:42:26 +0200 Subject: drm/panic: Add support to scanout buffer as array of pages Some drivers like virtio-gpu, don't map the scanout buffer in the kernel. Calling vmap() in a panic handler is not safe, and writing an atomic_vmap() API is more complex than expected [1]. So instead, pass the array of pages of the scanout buffer to the panic handler, and map only one page at a time to draw the pixels. This is obviously slow, but acceptable for a panic handler. [1] https://lore.kernel.org/dri-devel/20250305152555.318159-1-ryasuoka@redhat.com/ Acked-by: Thomas Zimmermann Acked-by: Simona Vetter Signed-off-by: Jocelyn Falempe Link: https://lore.kernel.org/r/20250407140138.162383-3-jfalempe@redhat.com --- include/drm/drm_panic.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/drm/drm_panic.h b/include/drm/drm_panic.h index ff78d00c3da5..310c88c4d336 100644 --- a/include/drm/drm_panic.h +++ b/include/drm/drm_panic.h @@ -39,6 +39,16 @@ struct drm_scanout_buffer { */ struct iosys_map map[DRM_FORMAT_MAX_PLANES]; + /** + * @pages: Optional, if the scanout buffer is not mapped, set this field + * to the array of pages of the scanout buffer. The panic code will use + * kmap_local_page_try_from_panic() to map one page at a time to write + * all the pixels. This array shouldn't be allocated from the + * get_scanoutbuffer() callback. + * The scanout buffer should be in linear format. + */ + struct page **pages; + /** * @width: Width of the scanout buffer, in pixels. */ @@ -57,7 +67,7 @@ struct drm_scanout_buffer { /** * @set_pixel: Optional function, to set a pixel color on the * framebuffer. It allows to handle special tiling format inside the - * driver. + * driver. It takes precedence over the @map and @pages fields. */ void (*set_pixel)(struct drm_scanout_buffer *sb, unsigned int x, unsigned int y, u32 color); -- cgit v1.2.3