From patchwork Wed Jan 24 06:51:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel van Vugt X-Patchwork-Id: 1890094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TKcZL52c8z23dy for ; Wed, 24 Jan 2024 19:29:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rSYdF-00078S-77; Wed, 24 Jan 2024 08:29:13 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rSX6q-0005yU-La for kernel-team@lists.ubuntu.com; Wed, 24 Jan 2024 06:51:40 +0000 Received: from [192.168.178.2] (unknown [58.7.187.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 449773FB77 for ; Wed, 24 Jan 2024 06:51:38 +0000 (UTC) Message-ID: <8a114fab-7287-4bba-b66e-a067f7068a93@canonical.com> Date: Wed, 24 Jan 2024 14:51:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: kernel-team@lists.ubuntu.com From: Daniel van Vugt Subject: [PATCH] fbcon: Defer AND delay console takeover X-Mailman-Approved-At: Wed, 24 Jan 2024 08:29:10 +0000 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Hello Kernel Team, Please find attached a patch for a particularly visible bug LP: #1970069. And please be gentle, I haven't touched the kernel in over a decade. - Daniel From 35be19e113dae19d9c86484620d57f628554afa9 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Fri, 19 Jan 2024 21:42:57 +0800 Subject: [PATCH] fbcon: Defer AND delay console takeover While the existing deferred takeover means to wait until there are messages to display, we add an additional delay here to prevent even those from appearing in the first N seconds. If "splash" is present then N is 10 seconds, otherwise it's zero. You can override the delay value with: fbcon=delay:N[:M] M is a secondary (default 1 second) delay which starts at primary framebuffer registration and overrides N. This ensures fbcon takes over the console quick enough that even a fast typer won't find their VTs are missing, but M provides a slight delay so as to ensure it doesn't win a race with Plymouth that's also waiting on primary (DRM) framebuffer registration. We prefer Plymouth takes over the framebuffer first. This patch exists to work around the limitations of Plymouth which refuses to display until DRM has started. And Plymouth will wait up to 8 seconds for that. TL;DR - This patch makes fbcon takeover happen one second after Plymouth has started animating, or 10 seconds after init in case that didn't happen, or if "splash" is removed then immediately on init. After SimpleDRM is enabled, this patch *might* not be necessary, and the current design is very Plymouth-centric (it works out of the box with no other system changes required) so isn't being proposed upstream just yet. Bug-Ubuntu: https://launchpad.net/bugs/1970069 Signed-off-by: Daniel van Vugt --- drivers/video/fbdev/core/fbcon.c | 50 +++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 63af6ab03..1994cca81 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -76,6 +76,7 @@ #include /* For counting font checksums */ #include #include +#include #include "fbcon.h" #include "fb_internal.h" @@ -146,6 +147,8 @@ static inline void fbcon_map_override(void) #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER static bool deferred_takeover = true; +static int start_delay = -1; /* seconds from init */ +static int primary_fb_takeover_delay = 1; /* seconds from FB registration */ #else #define deferred_takeover false #endif @@ -470,6 +473,17 @@ static int __init fb_console_setup(char *this_opt) deferred_takeover = false; continue; } + + if (!strncmp(options, "delay:", 6)) { + options += 6; + if (*options) + start_delay = simple_strtol(options, &options, 0); + if (*options == ':') { + options++; + primary_fb_takeover_delay = simple_strtol(options, &options, 0); + } + continue; + } #endif #ifdef CONFIG_LOGO @@ -2973,6 +2987,19 @@ module_param_named_unsafe(lockless_register_fb, lockless_register_fb, bool, 0400 MODULE_PARM_DESC(lockless_register_fb, "Lockless framebuffer registration for debugging [default=off]"); +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER +static void fbcon_start(void); + +static void fbcon_delayed_start(struct work_struct *work) +{ + console_lock(); + fbcon_start(); + console_unlock(); +} + +static DECLARE_DELAYED_WORK(fbcon_delayed_start_work, fbcon_delayed_start); +#endif + /* called with console_lock held */ static int do_fb_registered(struct fb_info *info) { @@ -2986,10 +3013,17 @@ static int do_fb_registered(struct fb_info *info) idx = info->node; fbcon_select_primary(info); +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER if (deferred_takeover) { - pr_info("fbcon: Deferring console take-over\n"); + if (start_delay > 0 && primary_device >= 0) { + mod_delayed_work(system_wq, &fbcon_delayed_start_work, primary_fb_takeover_delay * HZ); + pr_info("fbcon: Delayed console takeover reduced to %ds after primary framebuffer registration\n", primary_fb_takeover_delay); + } else { + pr_info("fbcon: Deferring console takeover\n"); + } return 0; } +#endif if (info_idx == -1) { for (i = first_fb_vc; i <= last_fb_vc; i++) { @@ -3395,6 +3429,20 @@ void __init fb_console_init(void) for (i = 0; i < MAX_NR_CONSOLES; i++) con2fb_map[i] = -1; +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER + if (!deferred_takeover) + start_delay = 0; + else if (start_delay < 0) + start_delay = cmdline_find_option_bool(boot_command_line, "splash") ? 10 : 0; + + if (start_delay > 0) { + pr_info("fbcon: Delaying console takeover by up to %ds\n", start_delay); + schedule_delayed_work(&fbcon_delayed_start_work, start_delay * HZ); + console_unlock(); + return; + } +#endif + fbcon_start(); console_unlock(); } -- 2.43.0