On failed output of QR codes and kmsg buffers, fall back to a user
message. QR-code output already did this internally, but now formally
support it in drm_panic_dispatch(). Streamlines the existing logic.

Also pass module parameter drm_panic_type as a parameter to
drm_panic_dispatch(). This simpifies the implementation. It will later
allow for moving the function into a helper library.

With the implicit fallback removed from QR-code support, the tests
cases fail for thr smallest output size (300x200). This is because the
QR code requires a minimal output size. Increase the size to 494x494,
which is the minimum supported size for QR output.

v2:
- fix minimum test size (Sashiko)

Signed-off-by: Thomas Zimmermann <[email protected]>
Reviewed-by: Jocelyn Falempe <[email protected]>
---
 drivers/gpu/drm/drm_panic.c            | 24 ++++++++++++------------
 drivers/gpu/drm/tests/drm_panic_test.c |  2 +-
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
index f597ef04c5bc..bc7c096c4236 100644
--- a/drivers/gpu/drm/drm_panic.c
+++ b/drivers/gpu/drm/drm_panic.c
@@ -740,9 +740,9 @@ static int drm_panic_get_qr_code(u8 **qr_image, unsigned 
int qr_version)
 /*
  * Draw the panic message at the center of the screen, with a QR Code
  */
-static int _draw_panic_screen_qr_code(struct drm_scanout_buffer *sb,
-                                     u32 fg_color, u32 bg_color,
-                                     unsigned int qr_version)
+static int draw_panic_screen_qr_code(struct drm_scanout_buffer *sb,
+                                    u32 fg_color, u32 bg_color,
+                                    unsigned int qr_version)
 {
        const struct font_desc *font = get_default_font(sb->width, sb->height, 
NULL, NULL);
        struct drm_rect r_screen, r_logo, r_msg, r_qr, r_qr_canvas;
@@ -812,15 +812,6 @@ static int _draw_panic_screen_qr_code(struct 
drm_scanout_buffer *sb,
        drm_panic_blit(sb, &r_qr, qr_image, qr_pitch, scale, fg_color);
        return 0;
 }
-
-static int draw_panic_screen_qr_code(struct drm_scanout_buffer *sb,
-                                    u32 fg_color, u32 bg_color,
-                                    unsigned int qr_version)
-{
-       if (_draw_panic_screen_qr_code(sb, fg_color, bg_color, qr_version))
-               return draw_panic_screen_user(sb, fg_color, bg_color);
-       return 0;
-}
 #else
 static void drm_panic_qr_init(void) {};
 static void drm_panic_qr_exit(void) {};
@@ -895,13 +886,22 @@ static int draw_panic_dispatch(struct drm_scanout_buffer 
*sb, enum drm_panic_typ
 {
        int ret;
 
+retry:
        switch (panic_type) {
        case DRM_PANIC_TYPE_KMSG:
                ret = draw_panic_screen_kmsg(sb, fg_color, bg_color);
+               if (ret) {
+                       panic_type = DRM_PANIC_TYPE_USER;
+                       goto retry;
+               }
                break;
 #if IS_ENABLED(CONFIG_DRM_PANIC_SCREEN_QR_CODE)
        case DRM_PANIC_TYPE_QR:
                ret = draw_panic_screen_qr_code(sb, fg_color, bg_color, 
qr_version);
+               if (ret) {
+                       panic_type = DRM_PANIC_TYPE_USER;
+                       goto retry;
+               }
                break;
 #endif
        case DRM_PANIC_TYPE_USER:
diff --git a/drivers/gpu/drm/tests/drm_panic_test.c 
b/drivers/gpu/drm/tests/drm_panic_test.c
index 196496238d23..55d77bc203df 100644
--- a/drivers/gpu/drm/tests/drm_panic_test.c
+++ b/drivers/gpu/drm/tests/drm_panic_test.c
@@ -32,7 +32,7 @@ struct drm_test_mode {
  */
 #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(494, 494, 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) \
-- 
2.55.0

Reply via email to