drm/panic: Add a kmsg dump screen
Subsystems (3)
Jocelyn Falempe
maintainercover drm/panic: Add a kmsg dump screen
Add a kmsg dump option, which will display the last lines of kmsg, and should be similar to fbcon.
Add a Kconfig choice for the panic screen, so that the user can choose between this new kmsg dump, or the userfriendly option.
Patch 1-2 are the same as https://patchwork.freedesktop.org/series/133963/
and are here to avoid conflicts.
Jocelyn Falempe (3):
drm/panic: only draw the foreground color in drm_panic_blit() drm/panic: Add a set_pixel() callback to drm_scanout_buffer drm/panic: Add a kmsg dump screen
drivers/gpu/drm/Kconfig | 21 +++ drivers/gpu/drm/drm_panic.c | 322 +++++++++++++++++++++++------------- include/drm/drm_panic.h | 9 + 3 files changed, 241 insertions(+), 111 deletions(-)
base-commit: 86266829ea755f737762ebda614c59b136c8feac
Signature · 1 line
2.45.1
Jocelyn Falempe
maintainerPATCH 1/3 drm/panic: only draw the foreground color in drm_panic_blit()
The whole framebuffer is cleared, so it's useless to rewrite the background colored pixels. It allows to simplify the drawing functions, and prepare the work for the set_pixel() callback.
--- drivers/gpu/drm/drm_panic.c | 63 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 37 deletions(-)
drivers/gpu/drm/drm_panic.c +26 -37
@@ -197,37 +197,33 @@ static u32 convert_from_xrgb8888(u32 color, u32 format)static void drm_panic_blit16 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u16 fg16,u16 bg16) +u16 color) {unsigned int y, x; -u16 val16; -for (y =0 ; y < height; y++) { -for (x =0 ; x < width; x++) { - val16 = (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) ? fg16 : bg16; -iosys_map_wr (dmap, y * dpitch + x *sizeof (u16), u16, val16); - } - } +for (y =0 ; y < height; y++) +for (x =0 ; x < width; x++) +if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) +iosys_map_wr (dmap, y * dpitch + x *sizeof (u16), u16, color); }static void drm_panic_blit24 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u32 fg32,u32 bg32) +u32 color) {unsigned int y, x; -u32 val32;for (y =0 ; y < height; y++) {for (x =0 ; x < width; x++) {u32 off = y * dpitch + x *3 ; - val32 = (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) ? fg32 : bg32; - -/* write blue-green-red to output in little endianness */ -iosys_map_wr (dmap, off, u8, (val32 &0x000000FF ) >>0 ); -iosys_map_wr (dmap, off +1 , u8, (val32 &0x0000FF00 ) >>8 ); -iosys_map_wr (dmap, off +2 , u8, (val32 &0x00FF0000 ) >>16 ); +if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) { +/* write blue-green-red to output in little endianness */ +iosys_map_wr (dmap, off, u8, (color &0x000000FF ) >>0 ); +iosys_map_wr (dmap, off +1 , u8, (color &0x0000FF00 ) >>8 ); +iosys_map_wr (dmap, off +2 , u8, (color &0x00FF0000 ) >>16 ); + } } } }
@@ -235,17 +231,14 @@ static void drm_panic_blit24(struct iosys_map *dmap, unsigned int dpitch,static void drm_panic_blit32 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u32 fg32,u32 bg32) +u32 color) {unsigned int y, x; -u32 val32; -for (y =0 ; y < height; y++) { -for (x =0 ; x < width; x++) { - val32 = (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) ? fg32 : bg32; -iosys_map_wr (dmap, y * dpitch + x *sizeof (u32), u32, val32); - } - } +for (y =0 ; y < height; y++) +for (x =0 ; x < width; x++) +if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) +iosys_map_wr (dmap, y * dpitch + x *sizeof (u32), u32, color); }/*
@@ -256,8 +249,7 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,* @spitch: source pitch in bytes * @height: height of the image to copy, in pixels * @width: width of the image to copy, in pixels -* @fg_color: foreground color, in destination format -* @bg_color: background color, in destination format +* @color: foreground color, in destination format * @pixel_width: pixel width in bytes. * * This can be used to draw a font character, which is a monochrome image, to a
@@ -266,21 +258,20 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,static void drm_panic_blit (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u32 fg_color,u32 bg_color, -unsigned int pixel_width) +u32 color,unsigned int pixel_width) {switch (pixel_width) {case 2 :drm_panic_blit16 (dmap, dpitch, sbuf8, spitch, - height, width, fg_color, bg_color); + height, width, color);break ;case 3 :drm_panic_blit24 (dmap, dpitch, sbuf8, spitch, - height, width, fg_color, bg_color); + height, width, color);break ;case 4 :drm_panic_blit32 (dmap, dpitch, sbuf8, spitch, - height, width, fg_color, bg_color); + height, width, color);break ;default :WARN_ONCE (1 ,"Can't blit with pixel width %d\n" , pixel_width);
@@ -381,8 +372,7 @@ static void draw_txt_rectangle(struct drm_scanout_buffer *sb,unsigned int msg_lines, bool centered, struct drm_rect *clip, - u32 fg_color, - u32 bg_color) + u32 color) { int i, j;const u8 *src;
@@ -404,8 +394,7 @@ static void draw_txt_rectangle(struct drm_scanout_buffer *sb,for (j =0 ; j < line_len; j++) { src =get_char_bitmap (font, msg[i].txt[j], font_pitch);drm_panic_blit (&dst, sb->pitch[0 ], src, font_pitch, - font->height, font->width, - fg_color, bg_color, px_width); + font->height, font->width, color, px_width);iosys_map_incr (&dst, font->width * px_width); } }
@@ -445,9 +434,9 @@ static void draw_panic_static(struct drm_scanout_buffer *sb)if ((r_msg.x1 >=drm_rect_width (&r_logo) || r_msg.y1 >=drm_rect_height (&r_logo)) &&drm_rect_width (&r_logo) < sb->width &&drm_rect_height (&r_logo) < sb->height) { -draw_txt_rectangle (sb, font, logo, logo_lines, false, &r_logo, fg_color, bg_color); +draw_txt_rectangle (sb, font, logo, logo_lines, false, &r_logo, fg_color); } -draw_txt_rectangle (sb, font, panic_msg, msg_lines, true, &r_msg, fg_color, bg_color); +draw_txt_rectangle (sb, font, panic_msg, msg_lines, true, &r_msg, fg_color); }/*
Signature · 1 line
2.45.1
Re: [PATCH 1/3] drm/panic: only draw the foreground color in drm_panic_blit()
Jocelyn Falempe <[email protected]> writes:
Hello Jocelyn,
Quoted 14 lines
The whole framebuffer is cleared, so it's useless to rewrite the background colored pixels. It allows to simplify the drawing functions, and prepare the work for the
set_pixel()callback.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_panic.c | 63 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 37 deletions(-)drivers/gpu/drm/drm_panic.c +0
-0
drivers/gpu/drm/drm_panic.c static u32 convert_from_xrgb8888(u32 color, u32 format) · line 200
Quoted 5 lines
drivers/gpu/drm/drm_panic.c +1
-1@@ -197,37 +197,33 @@ static u32 convert_from_xrgb8888(u32 color, u32 format)static void drm_panic_blit16 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u16 fg16,u16 bg16) +u16 color)
What about calling this fg16 instead of color? That way is clear that only the fb is written and not the background ?
drivers/gpu/drm/drm_panic.c static u32 convert_from_xrgb8888(u32 color, u32 format) · line 205
Quoted 12 lines
drivers/gpu/drm/drm_panic.c +2
-7{unsigned int y, x; -u16 val16; -for (y =0 ; y < height; y++) { -for (x =0 ; x < width; x++) { - val16 = (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) ? fg16 : bg16; -iosys_map_wr (dmap, y * dpitch + x *sizeof (u16), u16, val16); - } - } +for (y =0 ; y < height; y++) +for (x =0 ; x < width; x++)
I would add here a comment that this check is about determining if a color is suitable for foreground or background, depending on the luminance threshold (which I understand is the 0x80 value?).
drivers/gpu/drm/drm_panic.c static u32 convert_from_xrgb8888(u32 color, u32 format) · line 216
Quoted 13 lines
drivers/gpu/drm/drm_panic.c +3
-2+if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) +iosys_map_wr (dmap, y * dpitch + x *sizeof (u16), u16, color); }static void drm_panic_blit24 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u32 fg32,u32 bg32) +u32 color) {unsigned int y, x; -u32 val32;
Same here, I would left the variable name as fg32.
[...]
and also here would add a comment or use a variable to make it more readable.
Same comments for drm_panic_blit32().
[...]
drivers/gpu/drm/drm_panic.c static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch, · line 252
Quoted 8 lines
drivers/gpu/drm/drm_panic.c +1
-2/* @@ -256,8 +249,7 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,* @spitch: source pitch in bytes * @height: height of the image to copy, in pixels * @width: width of the image to copy, in pixels -* @fg_color: foreground color, in destination format -* @bg_color: background color, in destination format +* @color: foreground color, in destination format
Leaving as fg_color would even be consistent with your comment.
Feel free to ignore my comments though if you disagree, the patch looks good to me regardless.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Jocelyn Falempe
maintainerRe: [PATCH 1/3] drm/panic: only draw the foreground color in drm_panic_blit()
Quoted 13 lines · Javier Martinez Canillas
Jocelyn Falempe <[email protected]> writes:
Hello Jocelyn,
Quoted 9 lines
The whole framebuffer is cleared, so it's useless to rewrite the background colored pixels. It allows to simplify the drawing functions, and prepare the work for the
set_pixel()callback.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_panic.c | 63 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 37 deletions(-)
Quoted 13 lines
drivers/gpu/drm/drm_panic.c static u32 convert_from_xrgb8888(u32 color, u32 format) · line 200
Quoted 10 lines
drivers/gpu/drm/drm_panic.c +1
-1@@ -197,37 +197,33 @@ static u32 convert_from_xrgb8888(u32 color, u32 format)static void drm_panic_blit16 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u16 fg16,u16 bg16) +u16 color)What about calling this fg16 instead of color? That way is clear that only the fb is written and not the background ?
Yes I can keep the fg16 name.
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_panic.c +0
-1{unsigned int y, x; -u16 val16;
Quoted 12 lines
drivers/gpu/drm/drm_panic.c static u32 convert_from_xrgb8888(u32 color, u32 format) · line 205
Quoted 8 lines
drivers/gpu/drm/drm_panic.c +2
-6-for (y =0 ; y < height; y++) { -for (x =0 ; x < width; x++) { - val16 = (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) ? fg16 : bg16; -iosys_map_wr (dmap, y * dpitch + x *sizeof (u16), u16, val16); - } - } +for (y =0 ; y < height; y++) +for (x =0 ; x < width; x++)I would add here a comment that this check is about determining if a color is suitable for foreground or background, depending on the luminance threshold (which I understand is the
0x80value?).
The source buffer is monochrome, so store 8 pixels per byte.
the (0x80 >> (x % 8)) is a bit mask, to check if the source pixel is foreground or background. I will add a comment about this, to make it clear.
Quoted 36 lines
Quoted 4 lines
drivers/gpu/drm/drm_panic.c +2
-0+if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) +iosys_map_wr (dmap, y * dpitch + x *sizeof (u16), u16, color); }drivers/gpu/drm/drm_panic.c static u32 convert_from_xrgb8888(u32 color, u32 format) · line 216
Quoted 10 lines
drivers/gpu/drm/drm_panic.c +1
-2static void drm_panic_blit24 (struct iosys_map *dmap,unsigned int dpitch,const u8 *sbuf8,unsigned int spitch,unsigned int height,unsigned int width, -u32 fg32,u32 bg32) +u32 color) {unsigned int y, x; -u32 val32;Same here, I would left the variable name as fg32.
[...]
and also here would add a comment or use a variable to make it more readable.
Same comments for
drm_panic_blit32().[...]
drivers/gpu/drm/drm_panic.c static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch, · line 252
Quoted 8 lines
drivers/gpu/drm/drm_panic.c +1
-2/* @@ -256,8 +249,7 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,* @spitch: source pitch in bytes * @height: height of the image to copy, in pixels * @width: width of the image to copy, in pixels -* @fg_color: foreground color, in destination format -* @bg_color: background color, in destination format +* @color: foreground color, in destination format Leaving as
fg_colorwould even be consistent with your comment.
Quoted 2 lines
Feel free to ignore my comments though if you disagree, the patch looks good to me regardless.
sure I will keep the fg_* name
Quoted 3 lines
Reviewed-by Javier Martinez Canillas <[email protected]>
Thanks for the reviews,
--
Jocelyn
Jocelyn Falempe
maintainerPATCH 2/3 drm/panic: Add a set_pixel() callback to drm_scanout_buffer
In reply to Jocelyn FalempeThis allows drivers to draw the pixel, and handle tiling, or specific color formats.
--- drivers/gpu/drm/drm_panic.c | 120 +++++++++++++++++++++++------------- include/drm/drm_panic.h | 9 +++ 2 files changed, 85 insertions(+), 44 deletions(-)
drivers/gpu/drm/drm_panic.c +76 -44
@@ -241,40 +241,54 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,iosys_map_wr (dmap, y * dpitch + x *sizeof (u32), u32, color); } +static void drm_panic_blit_pixel (struct drm_scanout_buffer *sb,struct drm_rect *clip, +const u8 *sbuf8,unsigned int spitch,u32 color) +{ +unsigned int y, x; + +for (y =0 ; y <drm_rect_height (clip); y++) +for (x =0 ; x <drm_rect_width (clip); x++) +if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 ))) + sb->set_pixel (sb, clip->x1 + x, clip->y1 + y, color); +} +/* * drm_panic_blit - convert a monochrome image to a linear framebuffer -* @dmap: destination iosys_map -* @dpitch: destination pitch in bytes +* @sb: destination scanout buffer +* @clip: destination rectangle * @sbuf8: source buffer, in monochrome format, 8 pixels per byte. * @spitch: source pitch in bytes -* @height: height of the image to copy, in pixels -* @width: width of the image to copy, in pixels * @color: foreground color, in destination format -* @pixel_width: pixel width in bytes. * * This can be used to draw a font character, which is a monochrome image, to a * framebuffer in other supported format. */ -static void drm_panic_blit (struct iosys_map *dmap,unsigned int dpitch, -const u8 *sbuf8,unsigned int spitch, -unsigned int height,unsigned int width, -u32 color,unsigned int pixel_width) +static void drm_panic_blit (struct drm_scanout_buffer *sb,struct drm_rect *clip, +const u8 *sbuf8,unsigned int spitch,u32 color) { -switch (pixel_width) { +struct iosys_map map; + +if (sb->set_pixel) +return drm_panic_blit_pixel (sb, clip, sbuf8, spitch, color); + + map = sb->map[0 ]; +iosys_map_incr (&map, clip->y1 * sb->pitch[0 ] + clip->x1 * sb->format->cpp[0 ]); + +switch (sb->format->cpp[0 ]) {case 2 : -drm_panic_blit16 (dmap, dpitch, sbuf8, spitch, - height, width, color); +drm_panic_blit16 (&map, sb->pitch[0 ], sbuf8, spitch, +drm_rect_height (clip),drm_rect_width (clip), color);break ;case 3 : -drm_panic_blit24 (dmap, dpitch, sbuf8, spitch, - height, width, color); +drm_panic_blit24 (&map, sb->pitch[0 ], sbuf8, spitch, +drm_rect_height (clip),drm_rect_width (clip), color);break ;case 4 : -drm_panic_blit32 (dmap, dpitch, sbuf8, spitch, - height, width, color); +drm_panic_blit32 (&map, sb->pitch[0 ], sbuf8, spitch, +drm_rect_height (clip),drm_rect_width (clip), color);break ;default : -WARN_ONCE (1 ,"Can't blit with pixel width %d\n" , pixel_width); +WARN_ONCE (1 ,"Can't blit with pixel width %d\n" , sb->format->cpp[0 ]); } }
@@ -318,33 +332,51 @@ static void drm_panic_fill32(struct iosys_map *dmap, unsigned int dpitch,iosys_map_wr (dmap, y * dpitch + x *sizeof (u32), u32, color); } +static void drm_panic_fill_pixel (struct drm_scanout_buffer *sb, +struct drm_rect *clip, +u32 color) +{ +unsigned int y, x; + +for (y =0 ; y <drm_rect_height (clip); y++) +for (x =0 ; x <drm_rect_width (clip); x++) + sb->set_pixel (sb, clip->x1 + x, clip->y1 + y, color); +} +/* * drm_panic_fill - Fill a rectangle with a color -* @dmap: destination iosys_map, pointing to the top left corner of the rectangle -* @dpitch: destination pitch in bytes -* @height: height of the rectangle, in pixels -* @width: width of the rectangle, in pixels -* @color: color to fill the rectangle. -* @pixel_width: pixel width in bytes +* @sb: destination scanout buffer +* @clip: destination rectangle +* @color: foreground color, in destination format * * Fill a rectangle with a color, in a linear framebuffer. */ -static void drm_panic_fill (struct iosys_map *dmap,unsigned int dpitch, -unsigned int height,unsigned int width, -u32 color,unsigned int pixel_width) +static void drm_panic_fill (struct drm_scanout_buffer *sb,struct drm_rect *clip, +u32 color) { -switch (pixel_width) { +struct iosys_map map; + +if (sb->set_pixel) +return drm_panic_fill_pixel (sb, clip, color); + + map = sb->map[0 ]; +iosys_map_incr (&map, clip->y1 * sb->pitch[0 ] + clip->x1 * sb->format->cpp[0 ]); + +switch (sb->format->cpp[0 ]) {case 2 : -drm_panic_fill16 (dmap, dpitch, height, width, color); +drm_panic_fill16 (&map, sb->pitch[0 ],drm_rect_height (clip), +drm_rect_width (clip), color);break ;case 3 : -drm_panic_fill24 (dmap, dpitch, height, width, color); +drm_panic_fill24 (&map, sb->pitch[0 ],drm_rect_height (clip), +drm_rect_width (clip), color);break ;case 4 : -drm_panic_fill32 (dmap, dpitch, height, width, color); +drm_panic_fill32 (&map, sb->pitch[0 ],drm_rect_height (clip), +drm_rect_width (clip), color);break ;default : -WARN_ONCE (1 ,"Can't fill with pixel width %d\n" , pixel_width); +WARN_ONCE (1 ,"Can't fill with pixel width %d\n" , sb->format->cpp[0 ]); } }
@@ -377,25 +409,24 @@ static void draw_txt_rectangle(struct drm_scanout_buffer *sb,int i, j;const u8 *src;size_t font_pitch =DIV_ROUND_UP (font->width,8 ); -struct iosys_map dst; -unsigned int px_width = sb->format->cpp[0 ]; -int left =0 ; +struct drm_rect rec; msg_lines =min (msg_lines,drm_rect_height (clip) / font->height);for (i =0 ; i < msg_lines; i++) {size_t line_len =min (msg[i].len,drm_rect_width (clip) / font->width); + rec.y1 = clip->y1 + i * font->height; + rec.y2 = rec.y1 + font->height; + rec.x1 = clip->x1; +if (centered) - left = (drm_rect_width (clip) - (line_len * font->width)) /2 ; + rec.x1 += (drm_rect_width (clip) - (line_len * font->width)) /2 ; - dst = sb->map[0 ]; -iosys_map_incr (&dst, (clip->y1 + i * font->height) * sb->pitch[0 ] + - (clip->x1 + left) * px_width);for (j =0 ; j < line_len; j++) { src =get_char_bitmap (font, msg[i].txt[j], font_pitch); -drm_panic_blit (&dst, sb->pitch[0 ], src, font_pitch, - font->height, font->width, color, px_width); -iosys_map_incr (&dst, font->width * px_width); + rec.x2 = rec.x1 + font->width; +drm_panic_blit (sb, &rec, src, font_pitch, color); + rec.x1 += font->width; } } }
@@ -410,7 +441,7 @@ static void draw_panic_static(struct drm_scanout_buffer *sb)u32 fg_color =CONFIG_DRM_PANIC_FOREGROUND_COLOR ;u32 bg_color =CONFIG_DRM_PANIC_BACKGROUND_COLOR ;const struct font_desc *font =get_default_font (sb->width, sb->height,NULL ,NULL ); -struct drm_rect r_logo, r_msg; +struct drm_rect r_screen, r_logo, r_msg;if (!font)return ;
@@ -418,6 +449,8 @@ static void draw_panic_static(struct drm_scanout_buffer *sb) fg_color =convert_from_xrgb8888 (fg_color, sb->format->format); bg_color =convert_from_xrgb8888 (bg_color, sb->format->format); + r_screen =DRM_RECT_INIT (0 ,0 , sb->width, sb->height); + r_logo =DRM_RECT_INIT (0 ,0 ,get_max_line_len (logo, logo_lines) * font->width, logo_lines * font->height);
@@ -429,8 +462,7 @@ static void draw_panic_static(struct drm_scanout_buffer *sb)drm_rect_translate (&r_msg, (sb->width - r_msg.x2) /2 , (sb->height - r_msg.y2) /2 );/* Fill with the background color, and draw text on top */ -drm_panic_fill (&sb->map[0 ], sb->pitch[0 ], sb->height, sb->width, - bg_color, sb->format->cpp[0 ]); +drm_panic_fill (sb, &r_screen, bg_color);if ((r_msg.x1 >=drm_rect_width (&r_logo) || r_msg.y1 >=drm_rect_height (&r_logo)) &&drm_rect_width (&r_logo) < sb->width &&drm_rect_height (&r_logo) < sb->height) {
include/drm/drm_panic.h +9 -0
@@ -50,6 +50,15 @@ struct drm_scanout_buffer {* @pitch: Length in bytes between the start of two consecutive lines. */ unsigned int pitch[DRM_FORMAT_MAX_PLANES ]; + +/** +* @set_pixel: Optional function, to set a pixel color on the +* framebuffer. It allows to handle special tiling format inside the +* driver. +*/ +void (*set_pixel)(struct drm_scanout_buffer *sb,unsigned int x, +unsigned int y,u32 color); + };/**
Signature · 1 line
2.45.1
Re: [PATCH 2/3] drm/panic: Add a set_pixel() callback to drm_scanout_buffer
Quoted 15 lines · Jocelyn Falempe
This allows drivers to draw the pixel, and handle tiling, or specific color formats.
Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_panic.c | 120 +++++++++++++++++++++++------------- include/drm/drm_panic.h | 9 +++ 2 files changed, 85 insertions(+), 44 deletions(-)drivers/gpu/drm/drm_panic.c +0
-0@@ -241,40 +241,54 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,iosys_map_wr (dmap, y * dpitch + x *sizeof (u32), u32, color);
drivers/gpu/drm/drm_panic.c static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch, · line 251
Quoted 10 lines
drivers/gpu/drm/drm_panic.c +8
-0} +static void drm_panic_blit_pixel (struct drm_scanout_buffer *sb,struct drm_rect *clip, +const u8 *sbuf8,unsigned int spitch,u32 color) +{ +unsigned int y, x; + +for (y =0 ; y <drm_rect_height (clip); y++) +for (x =0 ; x <drm_rect_width (clip); x++) +if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 )))
You have the same check for fb vs bg in all your blit helpers, so maybe this can be a macro or static inline function instead ? That would also help with the issue I mentioned about making the logic easier to read.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Jocelyn Falempe
maintainerRe: [PATCH 2/3] drm/panic: Add a set_pixel() callback to drm_scanout_buffer
Quoted 19 lines · Javier Martinez Canillas
Quoted 17 lines · Jocelyn Falempe
This allows drivers to draw the pixel, and handle tiling, or specific color formats.
Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_panic.c | 120 +++++++++++++++++++++++------------- include/drm/drm_panic.h | 9 +++ 2 files changed, 85 insertions(+), 44 deletions(-)drivers/gpu/drm/drm_panic.c +0
-0@@ -241,40 +241,54 @@ static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch,iosys_map_wr (dmap, y * dpitch + x *sizeof (u32), u32, color); }
Quoted 12 lines
drivers/gpu/drm/drm_panic.c static void drm_panic_blit32(struct iosys_map *dmap, unsigned int dpitch, · line 251
Quoted 8 lines
drivers/gpu/drm/drm_panic.c +8
-0+static void drm_panic_blit_pixel (struct drm_scanout_buffer *sb,struct drm_rect *clip, +const u8 *sbuf8,unsigned int spitch,u32 color) +{ +unsigned int y, x; + +for (y =0 ; y <drm_rect_height (clip); y++) +for (x =0 ; x <drm_rect_width (clip); x++) +if (sbuf8[(y * spitch) + x /8 ] & (0x80 >> (x %8 )))You have the same check for fb vs bg in all your blit helpers, so maybe this can be a macro or static inline function instead ? That would also help with the issue I mentioned about making the logic easier to read.
Sure, I can do a v2, or send an additional patch for that.
Quoted 3 lines
Reviewed-by Javier Martinez Canillas <[email protected]>
Thanks,
Signature · 1 line
Jocelyn
Jocelyn Falempe
maintainerPATCH 3/3 drm/panic: Add a kmsg dump screen
In reply to Jocelyn FalempeAdd a kmsg dump option, which will display the last lines of kmsg, and should be similar to fbcon.
Add a Kconfig choice for the panic screen, so that the user can choose between this new kmsg dump, or the userfriendly option.
--- drivers/gpu/drm/Kconfig | 21 +++++ drivers/gpu/drm/drm_panic.c | 151 +++++++++++++++++++++++++++--------- 2 files changed, 136 insertions(+), 36 deletions(-)
drivers/gpu/drm/Kconfig +21 -0
@@ -137,6 +137,27 @@ config DRM_PANIC_DEBUG This is unsafe and should not be enabled on a production build. If in doubt, say "N". +choice + prompt "Panic screen formater" + default DRM_PANIC_SCREEN_USERFRIENDLY + depends on DRM_PANIC + help + This option enable to choose what will be displayed when a kernel + panic occurs. + + config DRM_PANIC_SCREEN_USERFRIENDLY + bool "Default user friendly message" + help + Only a short message telling the user to reboot the system. + + config DRM_PANIC_SCREEN_KMSG + bool "Display the last lines of kmsg" + help + Display kmsg last lines on panic. + Enable if you are a kernel developer, and want to debug a + kernel panic. +endchoice + config DRM_DEBUG_DP_MST_TOPOLOGY_REFS bool "Enable refcount backtrace history in the DP MST helpers" depends on STACKTRACE_SUPPORT
drivers/gpu/drm/drm_panic.c +115 -36
185 lines not on this page · raw message
Signature · 1 line
2.45.1
Quoted 29 lines · Jocelyn Falempe
Add a kmsg dump option, which will display the last lines of kmsg, and should be similar to fbcon.
Add aKconfigchoice for the panic screen, so that the user can choose between this new kmsg dump, or the userfriendly option.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/Kconfig | 21 +++++ drivers/gpu/drm/drm_panic.c | 151 +++++++++++++++++++++++++++--------- 2 files changed, 136 insertions(+), 36 deletions(-)drivers/gpu/drm/Kconfig +10
-0@@ -137,6 +137,27 @@ config DRM_PANIC_DEBUG This is unsafe and should not be enabled on a production build. If in doubt, say "N". +choice + prompt "Panic screen formater" + default DRM_PANIC_SCREEN_USERFRIENDLY + depends on DRM_PANIC + help + This option enable to choose what will be displayed when a kernel + panic occurs. + + config DRM_PANIC_SCREEN_USERFRIENDLY + bool "Default user friendly message"
drivers/gpu/drm/Kconfig config DRM_PANIC_DEBUG · line 159
Quoted 10 lines
drivers/gpu/drm/Kconfig +10
-0+ help + Only a short message telling the user to reboot the system. + + config DRM_PANIC_SCREEN_KMSG + bool "Display the last lines of kmsg" + help + Display kmsg last lines on panic. + Enable if you are a kernel developer, and want to debug a + kernel panic. +endchoice
Why having it as a compile time option and not a runtime option ? AFAICT this could be a drm.panic_format= kernel command line parameter instead.
[...]
drivers/gpu/drm/Kconfig config DRM_PANIC_DEBUG · line 161
Quoted 5 lines
drivers/gpu/drm/Kconfig +2
-3-/* - * Draw the panic message at the center of the screen - */ +#if defined(CONFIG_DRM_PANIC_SCREEN_USERFRIENDLY) +
And that could avoid ifdefery in the C file.
[...]
drivers/gpu/drm/Kconfig config DRM_PANIC_DEBUG
Quoted 5 lines
drivers/gpu/drm/Kconfig +5
-0+#elif defined(CONFIG_DRM_PANIC_SCREEN_KMSG) + +#include <linux/kmsg_dump.h> +#include <linux/printk.h> +
I would add these even if guarded by DRM_PANIC_SCREEN_KMSG, to the start of the C file where are the other headers include directives.
The patch looks good to me though, so if you prefer to keep it as a build time option:
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Jocelyn Falempe
maintainerQuoted 36 lines · Javier Martinez Canillas
Quoted 34 lines · Jocelyn Falempe
Add a kmsg dump option, which will display the last lines of kmsg, and should be similar to fbcon.
Add aKconfigchoice for the panic screen, so that the user can choose between this new kmsg dump, or the userfriendly option.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/Kconfig | 21 +++++ drivers/gpu/drm/drm_panic.c | 151 +++++++++++++++++++++++++++--------- 2 files changed, 136 insertions(+), 36 deletions(-)drivers/gpu/drm/Kconfig +15
-0@@ -137,6 +137,27 @@ config DRM_PANIC_DEBUG This is unsafe and should not be enabled on a production build. If in doubt, say "N". +choice + prompt "Panic screen formater" + default DRM_PANIC_SCREEN_USERFRIENDLY + depends on DRM_PANIC + help + This option enable to choose what will be displayed when a kernel + panic occurs. + + config DRM_PANIC_SCREEN_USERFRIENDLY + bool "Default user friendly message" + help + Only a short message telling the user to reboot the system. + + config DRM_PANIC_SCREEN_KMSG + bool "Display the last lines of kmsg"
Quoted 8 lines
drivers/gpu/drm/Kconfig config DRM_PANIC_DEBUG · line 159
Quoted 5 lines
drivers/gpu/drm/Kconfig +5
-0+ help + Display kmsg last lines on panic. + Enable if you are a kernel developer, and want to debug a + kernel panic. +endchoiceWhy having it as a compile time option and not a runtime option ? AFAICT this could be a drm.panic_format= kernel command line parameter instead.
Yes, I didn't think about it. That would allow to get more debug information from a user without rebuilding the kernel.
I'll prepare a v2 with that.
I prefer to use a drm.panic_screen=, as "format" might be confusing with the color format ?
Quoted 27 lines
[...]
drivers/gpu/drm/Kconfig
Quoted 5 lines
drivers/gpu/drm/Kconfig +2
-3-/* - * Draw the panic message at the center of the screen - */ +#if defined(CONFIG_DRM_PANIC_SCREEN_USERFRIENDLY) +And that could avoid ifdefery in the C file.
[...]
drivers/gpu/drm/Kconfig
Quoted 5 lines
drivers/gpu/drm/Kconfig +5
-0+#elif defined(CONFIG_DRM_PANIC_SCREEN_KMSG) + +#include <linux/kmsg_dump.h> +#include <linux/printk.h> +I would add these even if guarded by
DRM_PANIC_SCREEN_KMSG, to the start of the C file where are the other headers include directives.The patch looks good to me though, so if you prefer to keep it as a build time option:
Reviewed-by Javier Martinez Canillas <[email protected]>
Javier Martinez Canillas
maintainerQuoted 46 lines · Jocelyn Falempe
Quoted 36 lines · Javier Martinez Canillas
Quoted 34 lines · Jocelyn Falempe
Add a kmsg dump option, which will display the last lines of kmsg, and should be similar to fbcon.
Add aKconfigchoice for the panic screen, so that the user can choose between this new kmsg dump, or the userfriendly option.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/Kconfig | 21 +++++ drivers/gpu/drm/drm_panic.c | 151 +++++++++++++++++++++++++++--------- 2 files changed, 136 insertions(+), 36 deletions(-)drivers/gpu/drm/Kconfig +15
-0@@ -137,6 +137,27 @@ config DRM_PANIC_DEBUG This is unsafe and should not be enabled on a production build. If in doubt, say "N". +choice + prompt "Panic screen formater" + default DRM_PANIC_SCREEN_USERFRIENDLY + depends on DRM_PANIC + help + This option enable to choose what will be displayed when a kernel + panic occurs. + + config DRM_PANIC_SCREEN_USERFRIENDLY + bool "Default user friendly message" + help + Only a short message telling the user to reboot the system. + + config DRM_PANIC_SCREEN_KMSG + bool "Display the last lines of kmsg"Quoted 8 lines
drivers/gpu/drm/Kconfig config DRM_PANIC_DEBUG · line 159
Quoted 5 lines
drivers/gpu/drm/Kconfig +5
-0+ help + Display kmsg last lines on panic. + Enable if you are a kernel developer, and want to debug a + kernel panic. +endchoiceWhy having it as a compile time option and not a runtime option ? AFAICT this could be a drm.panic_format= kernel command line parameter instead.
Quoted 5 lines
Yes, I didn't think about it. That would allow to get more debug information from a user without rebuilding the kernel.
I'll prepare a v2 with that.
Awesome, thanks!
Quoted 3 lines
I prefer to use a drm.panic_screen=, as "format" might be confusing with the color format ?
Indeed. I named _format because your prompt had "formater" in it, but agree that _screen makes more sense and is easier to understand.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat