[PATCH v3 0/2] drm/panic: Add support to scanout buffer as array of pages

Jocelyn Falempe jfalempe at redhat.com
Mon Apr 7 13:42:24 UTC 2025


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.
As kmap_local_page() is not safe to call from a panic handler,
introduce a kmap_local_page_try_from_panic() that will avoid unsafe
operations.

[1] https://lore.kernel.org/dri-devel/20250305152555.318159-1-ryasuoka@redhat.com/

v2:
 * Add kmap_local_page_try_from_panic() (Simona Vetter)
 * Correctly handle the case if kmap_local_page_try_from_panic()
   returns NULL
 * Check that the current page is not NULL before trying to map it.
 * Add a comment in struct drm_scanout_buffer, that the array of
   pages shouldn't be allocated in the get_scanout_buffer() callback.

v3:
 * Replace DRM_WARN_ONCE with pr_debug_once (Simona Vetter)
 * Add a comment in kmap_local_page_try_from_panic() (Thomas Gleixner)

Jocelyn Falempe (2):
  mm/kmap: Add kmap_local_page_try_from_panic()
  drm/panic: Add support to scanout buffer as array of pages

 drivers/gpu/drm/drm_panic.c      | 142 +++++++++++++++++++++++++++++--
 include/drm/drm_panic.h          |  12 ++-
 include/linux/highmem-internal.h |  13 +++
 3 files changed, 160 insertions(+), 7 deletions(-)


base-commit: fbe43810d563a293e3de301141d33caf1f5d5c5a
-- 
2.49.0



More information about the dri-devel mailing list