Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/fb_dma: Add generic get_scanout_buffer() for drm_panic

This was initialy done for imx6, but should work on most drivers
using drm_fb_dma_helper.

v8:
* Replace get_scanout_buffer() logic with drm_panic_set_buffer()
(Thomas Zimmermann)

v9:
* go back to get_scanout_buffer()
* move get_scanout_buffer() to plane helper functions

v12:
* Rename drm_panic_gem_get_scanout_buffer to drm_fb_dma_get_scanout_buffer
(Thomas Zimmermann)
* Remove the #ifdef CONFIG_DRM_PANIC, and build it unconditionnaly, as
it's a small function. (Thomas Zimmermann)

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240409163432.352518-6-jfalempe@redhat.com
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

+46
+42
drivers/gpu/drm/drm_fb_dma_helper.c
··· 15 15 #include <drm/drm_framebuffer.h> 16 16 #include <drm/drm_gem_dma_helper.h> 17 17 #include <drm/drm_gem_framebuffer_helper.h> 18 + #include <drm/drm_panic.h> 18 19 #include <drm/drm_plane.h> 19 20 #include <linux/dma-mapping.h> 20 21 #include <linux/module.h> ··· 149 148 } 150 149 } 151 150 EXPORT_SYMBOL_GPL(drm_fb_dma_sync_non_coherent); 151 + 152 + /** 153 + * drm_fb_dma_get_scanout_buffer - Provide a scanout buffer in case of panic 154 + * @plane: DRM primary plane 155 + * @drm_scanout_buffer: scanout buffer for the panic handler 156 + * Returns: 0 or negative error code 157 + * 158 + * Generic get_scanout_buffer() implementation, for drivers that uses the 159 + * drm_fb_dma_helper. It won't call vmap in the panic context, so the driver 160 + * should make sure the primary plane is vmapped, otherwise the panic screen 161 + * won't get displayed. 162 + */ 163 + int drm_fb_dma_get_scanout_buffer(struct drm_plane *plane, 164 + struct drm_scanout_buffer *sb) 165 + { 166 + struct drm_gem_dma_object *dma_obj; 167 + struct drm_framebuffer *fb; 168 + 169 + fb = plane->state->fb; 170 + /* Only support linear modifier */ 171 + if (fb->modifier != DRM_FORMAT_MOD_LINEAR) 172 + return -ENODEV; 173 + 174 + dma_obj = drm_fb_dma_get_gem_obj(fb, 0); 175 + 176 + /* Buffer should be accessible from the CPU */ 177 + if (dma_obj->base.import_attach) 178 + return -ENODEV; 179 + 180 + /* Buffer should be already mapped to CPU */ 181 + if (!dma_obj->vaddr) 182 + return -ENODEV; 183 + 184 + iosys_map_set_vaddr(&sb->map[0], dma_obj->vaddr); 185 + sb->format = fb->format; 186 + sb->height = fb->height; 187 + sb->width = fb->width; 188 + sb->pitch[0] = fb->pitches[0]; 189 + return 0; 190 + } 191 + EXPORT_SYMBOL(drm_fb_dma_get_scanout_buffer);
+4
include/drm/drm_fb_dma_helper.h
··· 7 7 struct drm_device; 8 8 struct drm_framebuffer; 9 9 struct drm_plane_state; 10 + struct drm_scanout_buffer; 10 11 11 12 struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb, 12 13 unsigned int plane); ··· 19 18 void drm_fb_dma_sync_non_coherent(struct drm_device *drm, 20 19 struct drm_plane_state *old_state, 21 20 struct drm_plane_state *state); 21 + 22 + int drm_panic_gem_get_scanout_buffer(struct drm_plane *plane, 23 + struct drm_scanout_buffer *sb); 22 24 23 25 #endif 24 26