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

drm/{i915,xe}/panic: split out intel_panic.[ch]

intel_bo.[ch] is not the appropriate location for the panic
functionality. Split out intel_panic.[ch] and xe_panic.c in i915 and
xe. Keep the function names for now.

Cc: Jocelyn Falempe <jfalempe@redhat.com>
Cc: Maarten Lankhorst <dev@lankhorst.se>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/d98b831a011a028ffd33ce99b0ba62be061ee235.1756835342.git.jani.nikula@intel.com

+136 -110
+1
drivers/gpu/drm/i915/Makefile
··· 280 280 display/intel_modeset_setup.o \ 281 281 display/intel_modeset_verify.o \ 282 282 display/intel_overlay.o \ 283 + display/intel_panic.o \ 283 284 display/intel_pch.o \ 284 285 display/intel_pch_display.o \ 285 286 display/intel_pch_refclk.o \
+1
drivers/gpu/drm/i915/display/i9xx_plane.c
··· 22 22 #include "intel_fb.h" 23 23 #include "intel_fbc.h" 24 24 #include "intel_frontbuffer.h" 25 + #include "intel_panic.h" 25 26 #include "intel_plane.h" 26 27 #include "intel_sprite.h" 27 28
-15
drivers/gpu/drm/i915/display/intel_bo.c
··· 59 59 { 60 60 i915_debugfs_describe_obj(m, to_intel_bo(obj)); 61 61 } 62 - 63 - struct intel_framebuffer *intel_bo_alloc_framebuffer(void) 64 - { 65 - return i915_gem_object_alloc_framebuffer(); 66 - } 67 - 68 - int intel_bo_panic_setup(struct drm_scanout_buffer *sb) 69 - { 70 - return i915_gem_object_panic_setup(sb); 71 - } 72 - 73 - void intel_bo_panic_finish(struct intel_framebuffer *fb) 74 - { 75 - return i915_gem_object_panic_finish(fb); 76 - }
-3
drivers/gpu/drm/i915/display/intel_bo.h
··· 25 25 struct intel_frontbuffer *front); 26 26 27 27 void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj); 28 - struct intel_framebuffer *intel_bo_alloc_framebuffer(void); 29 - int intel_bo_panic_setup(struct drm_scanout_buffer *sb); 30 - void intel_bo_panic_finish(struct intel_framebuffer *fb); 31 28 32 29 #endif /* __INTEL_BO__ */
+1
drivers/gpu/drm/i915/display/intel_fb.c
··· 20 20 #include "intel_fb.h" 21 21 #include "intel_fb_bo.h" 22 22 #include "intel_frontbuffer.h" 23 + #include "intel_panic.h" 23 24 #include "intel_plane.h" 24 25 25 26 #define check_array_bounds(display, a, i) drm_WARN_ON((display)->drm, (i) >= ARRAY_SIZE(a))
+20
drivers/gpu/drm/i915/display/intel_panic.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #include "gem/i915_gem_object.h" 5 + #include "intel_panic.h" 6 + 7 + struct intel_framebuffer *intel_bo_alloc_framebuffer(void) 8 + { 9 + return i915_gem_object_alloc_framebuffer(); 10 + } 11 + 12 + int intel_bo_panic_setup(struct drm_scanout_buffer *sb) 13 + { 14 + return i915_gem_object_panic_setup(sb); 15 + } 16 + 17 + void intel_bo_panic_finish(struct intel_framebuffer *fb) 18 + { 19 + return i915_gem_object_panic_finish(fb); 20 + }
+14
drivers/gpu/drm/i915/display/intel_panic.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #ifndef __INTEL_PANIC_H__ 5 + #define __INTEL_PANIC_H__ 6 + 7 + struct drm_scanout_buffer; 8 + struct intel_framebuffer; 9 + 10 + struct intel_framebuffer *intel_bo_alloc_framebuffer(void); 11 + int intel_bo_panic_setup(struct drm_scanout_buffer *sb); 12 + void intel_bo_panic_finish(struct intel_framebuffer *fb); 13 + 14 + #endif /* __INTEL_PANIC_H__ */
+1 -1
drivers/gpu/drm/i915/display/intel_plane.c
··· 47 47 #include "gem/i915_gem_object.h" 48 48 #include "i915_scheduler_types.h" 49 49 #include "i9xx_plane_regs.h" 50 - #include "intel_bo.h" 51 50 #include "intel_cdclk.h" 52 51 #include "intel_cursor.h" 53 52 #include "intel_display_rps.h" ··· 55 56 #include "intel_fb.h" 56 57 #include "intel_fb_pin.h" 57 58 #include "intel_fbdev.h" 59 + #include "intel_panic.h" 58 60 #include "intel_plane.h" 59 61 #include "intel_psr.h" 60 62 #include "skl_scaler.h"
+1
drivers/gpu/drm/i915/display/skl_universal_plane.c
··· 20 20 #include "intel_fb.h" 21 21 #include "intel_fbc.h" 22 22 #include "intel_frontbuffer.h" 23 + #include "intel_panic.h" 23 24 #include "intel_plane.h" 24 25 #include "intel_psr.h" 25 26 #include "intel_psr_regs.h"
+1
drivers/gpu/drm/xe/Makefile
··· 192 192 display/xe_dsb_buffer.o \ 193 193 display/xe_fb_pin.o \ 194 194 display/xe_hdcp_gsc.o \ 195 + display/xe_panic.o \ 195 196 display/xe_plane_initial.o \ 196 197 display/xe_tdf.o 197 198
-91
drivers/gpu/drm/xe/display/intel_bo.c
··· 1 1 // SPDX-License-Identifier: MIT 2 2 /* Copyright © 2024 Intel Corporation */ 3 3 4 - #include <drm/drm_cache.h> 5 4 #include <drm/drm_gem.h> 6 - #include <drm/drm_panic.h> 7 - 8 - #include "intel_fb.h" 9 - #include "intel_display_types.h" 10 5 11 6 #include "xe_bo.h" 12 7 #include "intel_bo.h" ··· 58 63 void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj) 59 64 { 60 65 /* FIXME */ 61 - } 62 - 63 - struct xe_panic_data { 64 - struct page **pages; 65 - int page; 66 - void *vaddr; 67 - }; 68 - 69 - struct xe_framebuffer { 70 - struct intel_framebuffer base; 71 - struct xe_panic_data panic; 72 - }; 73 - 74 - static inline struct xe_panic_data *to_xe_panic_data(struct intel_framebuffer *fb) 75 - { 76 - return &container_of_const(fb, struct xe_framebuffer, base)->panic; 77 - } 78 - 79 - static void xe_panic_kunmap(struct xe_panic_data *panic) 80 - { 81 - if (panic->vaddr) { 82 - drm_clflush_virt_range(panic->vaddr, PAGE_SIZE); 83 - kunmap_local(panic->vaddr); 84 - panic->vaddr = NULL; 85 - } 86 - } 87 - 88 - /* 89 - * The scanout buffer pages are not mapped, so for each pixel, 90 - * use kmap_local_page_try_from_panic() to map the page, and write the pixel. 91 - * Try to keep the map from the previous pixel, to avoid too much map/unmap. 92 - */ 93 - static void xe_panic_page_set_pixel(struct drm_scanout_buffer *sb, unsigned int x, 94 - unsigned int y, u32 color) 95 - { 96 - struct intel_framebuffer *fb = (struct intel_framebuffer *)sb->private; 97 - struct xe_panic_data *panic = to_xe_panic_data(fb); 98 - struct xe_bo *bo = gem_to_xe_bo(intel_fb_bo(&fb->base)); 99 - unsigned int new_page; 100 - unsigned int offset; 101 - 102 - if (fb->panic_tiling) 103 - offset = fb->panic_tiling(sb->width, x, y); 104 - else 105 - offset = y * sb->pitch[0] + x * sb->format->cpp[0]; 106 - 107 - new_page = offset >> PAGE_SHIFT; 108 - offset = offset % PAGE_SIZE; 109 - if (new_page != panic->page) { 110 - xe_panic_kunmap(panic); 111 - panic->page = new_page; 112 - panic->vaddr = ttm_bo_kmap_try_from_panic(&bo->ttm, 113 - panic->page); 114 - } 115 - if (panic->vaddr) { 116 - u32 *pix = panic->vaddr + offset; 117 - *pix = color; 118 - } 119 - } 120 - 121 - struct intel_framebuffer *intel_bo_alloc_framebuffer(void) 122 - { 123 - struct xe_framebuffer *xe_fb; 124 - 125 - xe_fb = kzalloc(sizeof(*xe_fb), GFP_KERNEL); 126 - if (xe_fb) 127 - return &xe_fb->base; 128 - return NULL; 129 - } 130 - 131 - int intel_bo_panic_setup(struct drm_scanout_buffer *sb) 132 - { 133 - struct intel_framebuffer *fb = (struct intel_framebuffer *)sb->private; 134 - struct xe_panic_data *panic = to_xe_panic_data(fb); 135 - 136 - panic->page = -1; 137 - sb->set_pixel = xe_panic_page_set_pixel; 138 - return 0; 139 - } 140 - 141 - void intel_bo_panic_finish(struct intel_framebuffer *fb) 142 - { 143 - struct xe_panic_data *panic = to_xe_panic_data(fb); 144 - 145 - xe_panic_kunmap(panic); 146 - panic->page = -1; 147 66 }
+96
drivers/gpu/drm/xe/display/xe_panic.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #include <drm/drm_cache.h> 5 + #include <drm/drm_panic.h> 6 + 7 + #include "intel_display_types.h" 8 + #include "intel_fb.h" 9 + #include "intel_panic.h" 10 + #include "xe_bo.h" 11 + 12 + struct xe_panic_data { 13 + struct page **pages; 14 + int page; 15 + void *vaddr; 16 + }; 17 + 18 + struct xe_framebuffer { 19 + struct intel_framebuffer base; 20 + struct xe_panic_data panic; 21 + }; 22 + 23 + static inline struct xe_panic_data *to_xe_panic_data(struct intel_framebuffer *fb) 24 + { 25 + return &container_of_const(fb, struct xe_framebuffer, base)->panic; 26 + } 27 + 28 + static void xe_panic_kunmap(struct xe_panic_data *panic) 29 + { 30 + if (panic->vaddr) { 31 + drm_clflush_virt_range(panic->vaddr, PAGE_SIZE); 32 + kunmap_local(panic->vaddr); 33 + panic->vaddr = NULL; 34 + } 35 + } 36 + 37 + /* 38 + * The scanout buffer pages are not mapped, so for each pixel, 39 + * use kmap_local_page_try_from_panic() to map the page, and write the pixel. 40 + * Try to keep the map from the previous pixel, to avoid too much map/unmap. 41 + */ 42 + static void xe_panic_page_set_pixel(struct drm_scanout_buffer *sb, unsigned int x, 43 + unsigned int y, u32 color) 44 + { 45 + struct intel_framebuffer *fb = (struct intel_framebuffer *)sb->private; 46 + struct xe_panic_data *panic = to_xe_panic_data(fb); 47 + struct xe_bo *bo = gem_to_xe_bo(intel_fb_bo(&fb->base)); 48 + unsigned int new_page; 49 + unsigned int offset; 50 + 51 + if (fb->panic_tiling) 52 + offset = fb->panic_tiling(sb->width, x, y); 53 + else 54 + offset = y * sb->pitch[0] + x * sb->format->cpp[0]; 55 + 56 + new_page = offset >> PAGE_SHIFT; 57 + offset = offset % PAGE_SIZE; 58 + if (new_page != panic->page) { 59 + xe_panic_kunmap(panic); 60 + panic->page = new_page; 61 + panic->vaddr = ttm_bo_kmap_try_from_panic(&bo->ttm, 62 + panic->page); 63 + } 64 + if (panic->vaddr) { 65 + u32 *pix = panic->vaddr + offset; 66 + *pix = color; 67 + } 68 + } 69 + 70 + struct intel_framebuffer *intel_bo_alloc_framebuffer(void) 71 + { 72 + struct xe_framebuffer *xe_fb; 73 + 74 + xe_fb = kzalloc(sizeof(*xe_fb), GFP_KERNEL); 75 + if (xe_fb) 76 + return &xe_fb->base; 77 + return NULL; 78 + } 79 + 80 + int intel_bo_panic_setup(struct drm_scanout_buffer *sb) 81 + { 82 + struct intel_framebuffer *fb = (struct intel_framebuffer *)sb->private; 83 + struct xe_panic_data *panic = to_xe_panic_data(fb); 84 + 85 + panic->page = -1; 86 + sb->set_pixel = xe_panic_page_set_pixel; 87 + return 0; 88 + } 89 + 90 + void intel_bo_panic_finish(struct intel_framebuffer *fb) 91 + { 92 + struct xe_panic_data *panic = to_xe_panic_data(fb); 93 + 94 + xe_panic_kunmap(panic); 95 + panic->page = -1; 96 + }