drivers/gpu/drm/tests/drm_panic_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_panic_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_panic_test.c- Extension
.c- Size
- 5921 bytes
- Lines
- 222
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
drm/drm_fourcc.hdrm/drm_panic.hkunit/test.hlinux/units.hlinux/vmalloc.h
Detected Declarations
struct drm_test_modefunction Copyrightfunction drm_panic_check_color_bytefunction drm_test_panic_initfunction drm_test_panic_screen_user_mapfunction drm_test_panic_screen_user_pagefunction drm_test_panic_set_pixelfunction set_pixelfunction drm_test_panic_desc
Annotated Snippet
struct drm_test_mode {
const int width;
const int height;
const u32 format;
void (*draw_screen)(struct drm_scanout_buffer *sb);
const char *fname;
};
/*
* Run all tests for the 3 panic screens: user, kmsg and qr_code
*/
#define DRM_TEST_MODE_LIST(func) \
DRM_PANIC_TEST_MODE(1024, 768, DRM_FORMAT_XRGB8888, func) \
DRM_PANIC_TEST_MODE(300, 200, DRM_FORMAT_XRGB8888, func) \
DRM_PANIC_TEST_MODE(1920, 1080, DRM_FORMAT_XRGB8888, func) \
DRM_PANIC_TEST_MODE(1024, 768, DRM_FORMAT_RGB565, func) \
DRM_PANIC_TEST_MODE(1024, 768, DRM_FORMAT_RGB888, func) \
#define DRM_PANIC_TEST_MODE(w, h, f, name) { \
.width = w, \
.height = h, \
.format = f, \
.draw_screen = draw_panic_screen_##name, \
.fname = #name, \
}, \
static const struct drm_test_mode drm_test_modes_cases[] = {
DRM_TEST_MODE_LIST(user)
DRM_TEST_MODE_LIST(kmsg)
#if IS_ENABLED(CONFIG_DRM_PANIC_SCREEN_QR_CODE)
DRM_TEST_MODE_LIST(qr_code)
#endif
};
#undef DRM_PANIC_TEST_MODE
static int drm_test_panic_init(struct kunit *test)
{
struct drm_scanout_buffer *priv;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, priv);
test->priv = priv;
drm_panic_set_description("Kunit testing");
return 0;
}
/*
* Test drawing the panic screen, using a memory mapped framebuffer
* Set the whole buffer to 0xa5, and then check that all pixels have been
* written.
*/
static void drm_test_panic_screen_user_map(struct kunit *test)
{
struct drm_scanout_buffer *sb = test->priv;
const struct drm_test_mode *params = test->param_value;
char *fb;
int fb_size;
int i;
sb->format = drm_format_info(params->format);
fb_size = params->width * params->height * sb->format->cpp[0];
fb = vmalloc(fb_size);
KUNIT_ASSERT_NOT_NULL(test, fb);
memset(fb, 0xa5, fb_size);
iosys_map_set_vaddr(&sb->map[0], fb);
sb->width = params->width;
sb->height = params->height;
sb->pitch[0] = params->width * sb->format->cpp[0];
params->draw_screen(sb);
for (i = 0; i < fb_size; i++)
drm_panic_check_color_byte(test, fb[i]);
vfree(fb);
}
/*
* Test drawing the panic screen, using a list of pages framebuffer
* Set the whole buffer to 0xa5, and then check that all pixels have been
* written.
*/
static void drm_test_panic_screen_user_page(struct kunit *test)
Annotation
- Immediate include surface: `drm/drm_fourcc.h`, `drm/drm_panic.h`, `kunit/test.h`, `linux/units.h`, `linux/vmalloc.h`.
- Detected declarations: `struct drm_test_mode`, `function Copyright`, `function drm_panic_check_color_byte`, `function drm_test_panic_init`, `function drm_test_panic_screen_user_map`, `function drm_test_panic_screen_user_page`, `function drm_test_panic_set_pixel`, `function set_pixel`, `function drm_test_panic_desc`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.