drivers/gpu/drm/drm_panic.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_panic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_panic.c- Extension
.c- Size
- 30679 bytes
- Lines
- 1094
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/font.hlinux/highmem.hlinux/init.hlinux/iosys-map.hlinux/kdebug.hlinux/kmsg_dump.hlinux/linux_logo.hlinux/list.hlinux/math.hlinux/module.hlinux/overflow.hlinux/printk.hlinux/types.hlinux/utsname.hlinux/zlib.hdrm/drm_drv.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_modeset_helper_vtables.hdrm/drm_panic.hdrm/drm_plane.hdrm/drm_print.hdrm/drm_rect.hdrm_crtc_internal.hdrm_draw_internal.hlinux/debugfs.htests/drm_panic_test.c
Detected Declarations
struct drm_panic_lineenum drm_panic_typefunction drm_panic_setup_logofunction drm_panic_blit_pixelfunction drm_panic_write_pixel16function drm_panic_write_pixel24function drm_panic_write_pixel24_xpagefunction drm_panic_write_pixel32function drm_panic_write_pixelfunction kmap_local_page_try_from_panicfunction drm_panic_blitfunction drm_panic_fill_pixelfunction drm_panic_fill_pagefunction drm_panic_fillfunction get_max_line_lenfunction draw_txt_rectanglefunction drm_panic_logo_rectfunction drm_panic_logo_drawfunction draw_panic_screen_userfunction draw_line_with_wrapfunction draw_panic_screen_kmsgfunction drm_panic_qr_initfunction drm_panic_qr_exitfunction drm_panic_get_qr_code_urlfunction drm_panic_get_qr_code_rawfunction drm_panic_get_qr_codefunction _draw_panic_screen_qr_codefunction draw_panic_screen_qr_codefunction drm_panic_qr_initfunction drm_panic_qr_exitfunction drm_panic_type_setfunction drm_panic_type_getfunction drm_panic_is_format_supportedfunction draw_panic_dispatchfunction drm_panic_set_descriptionfunction drm_panic_clear_descriptionfunction draw_panic_planefunction drm_panicfunction debugfs_trigger_writefunction debugfs_register_planefunction debugfs_register_planefunction drm_panic_registerfunction drm_for_each_planefunction drm_panic_unregisterfunction drm_for_each_planefunction drm_panic_initfunction drm_panic_exitmodule init drm_panic_setup_logo
Annotated Snippet
static const struct file_operations dbg_drm_panic_ops = {
.owner = THIS_MODULE,
.write = debugfs_trigger_write,
.open = simple_open,
};
static void debugfs_register_plane(struct drm_plane *plane, int index)
{
char fname[32];
snprintf(fname, 32, "drm_panic_plane_%d", index);
debugfs_create_file(fname, 0200, plane->dev->debugfs_root,
plane, &dbg_drm_panic_ops);
}
#else
static void debugfs_register_plane(struct drm_plane *plane, int index) {}
#endif /* CONFIG_DRM_PANIC_DEBUG */
/**
* drm_panic_is_enabled
* @dev: the drm device that may supports drm_panic
*
* returns true if the drm device supports drm_panic
*/
bool drm_panic_is_enabled(struct drm_device *dev)
{
struct drm_plane *plane;
if (!dev->mode_config.num_total_plane)
return false;
drm_for_each_plane(plane, dev)
if (plane->helper_private && plane->helper_private->get_scanout_buffer)
return true;
return false;
}
EXPORT_SYMBOL(drm_panic_is_enabled);
/**
* drm_panic_register() - Initialize DRM panic for a device
* @dev: the drm device on which the panic screen will be displayed.
*/
void drm_panic_register(struct drm_device *dev)
{
struct drm_plane *plane;
int registered_plane = 0;
if (!dev->mode_config.num_total_plane)
return;
drm_for_each_plane(plane, dev) {
if (!plane->helper_private || !plane->helper_private->get_scanout_buffer)
continue;
plane->kmsg_panic.dump = drm_panic;
plane->kmsg_panic.max_reason = KMSG_DUMP_PANIC;
if (kmsg_dump_register(&plane->kmsg_panic))
drm_warn(dev, "Failed to register panic handler\n");
else {
debugfs_register_plane(plane, registered_plane);
registered_plane++;
}
}
if (registered_plane)
drm_info(dev, "Registered %d planes with drm panic\n", registered_plane);
}
/**
* drm_panic_unregister()
* @dev: the drm device previously registered.
*/
void drm_panic_unregister(struct drm_device *dev)
{
struct drm_plane *plane;
if (!dev->mode_config.num_total_plane)
return;
drm_for_each_plane(plane, dev) {
if (!plane->helper_private || !plane->helper_private->get_scanout_buffer)
continue;
kmsg_dump_unregister(&plane->kmsg_panic);
}
}
/**
* drm_panic_init() - initialize DRM panic.
*/
void __init drm_panic_init(void)
{
if (drm_panic_type == -1 && drm_panic_type_set(CONFIG_DRM_PANIC_SCREEN, NULL)) {
Annotation
- Immediate include surface: `linux/export.h`, `linux/font.h`, `linux/highmem.h`, `linux/init.h`, `linux/iosys-map.h`, `linux/kdebug.h`, `linux/kmsg_dump.h`, `linux/linux_logo.h`.
- Detected declarations: `struct drm_panic_line`, `enum drm_panic_type`, `function drm_panic_setup_logo`, `function drm_panic_blit_pixel`, `function drm_panic_write_pixel16`, `function drm_panic_write_pixel24`, `function drm_panic_write_pixel24_xpage`, `function drm_panic_write_pixel32`, `function drm_panic_write_pixel`, `function kmap_local_page_try_from_panic`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.