diff mbox series

fbcon: Defer AND delay console takeover

Message ID 8a114fab-7287-4bba-b66e-a067f7068a93@canonical.com
State New
Headers show
Series fbcon: Defer AND delay console takeover | expand

Commit Message

Daniel van Vugt Jan. 24, 2024, 6:51 a.m. UTC
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

Comments

Roxana Nicolescu Jan. 24, 2024, 10:06 a.m. UTC | #1
On 24-01-2024 07:51, Daniel van Vugt wrote:
> 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
>
Hi,

It is not clear which series are of interested here. They should be 
included in the subject.
This page <https://wiki.ubuntu.com/Kernel/Dev/StablePatchFormat> should 
explain the format we expect. TDLR you need to send 2 emails, one for 
the cover letter and one for the patch itself.
We expect the subject for the cover letter to be "[SRU][<series>][PATCH 
0/1] <Short description of what you want to solve>"
And then the patch should not be send as attachment, but as a separate 
email with subject "[SRU][<Series>][PATCH 1/1] fbcon: Defer AND delay 
console takeover".
Make sure you include the buglink in both. And also make sure the 
buglink addresses the series that need to be addressed.

Now, looking at the patch, this is not upstream, so it will be a SAUCE 
patch. I don't think the impact of this is big enough to deviate from 
upstream, therefore
I am inclined to not accept it. I would recommend proposing it to 
upstream first.

Roxana
Daniel van Vugt Jan. 25, 2024, 1:20 a.m. UTC | #2
Please update the wiki, because I did follow the published instructions but 
clearly there are steps missing:

https://wiki.ubuntu.com/Kernel/Dev/KernelPatches


On 24/1/24 18:06, Roxana Nicolescu wrote:
> 
> On 24-01-2024 07:51, Daniel van Vugt wrote:
>> 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
>>
> Hi,
> 
> It is not clear which series are of interested here. They should be included in 
> the subject.
> This page <https://wiki.ubuntu.com/Kernel/Dev/StablePatchFormat> should explain 
> the format we expect. TDLR you need to send 2 emails, one for the cover letter 
> and one for the patch itself.
> We expect the subject for the cover letter to be "[SRU][<series>][PATCH 0/1] 
> <Short description of what you want to solve>"
> And then the patch should not be send as attachment, but as a separate email 
> with subject "[SRU][<Series>][PATCH 1/1] fbcon: Defer AND delay console takeover".
> Make sure you include the buglink in both. And also make sure the buglink 
> addresses the series that need to be addressed.
> 
> Now, looking at the patch, this is not upstream, so it will be a SAUCE patch. I 
> don't think the impact of this is big enough to deviate from upstream, therefore
> I am inclined to not accept it. I would recommend proposing it to upstream first.
> 
> Roxana
Roxana Nicolescu Jan. 26, 2024, 9:54 a.m. UTC | #3
On 25/01/2024 02:20, Daniel van Vugt wrote:
> Please update the wiki, because I did follow the published 
> instructions but clearly there are steps missing:
>
> https://wiki.ubuntu.com/Kernel/Dev/KernelPatches
>
>
> On 24/1/24 18:06, Roxana Nicolescu wrote:
>>
>> On 24-01-2024 07:51, Daniel van Vugt wrote:
>>> 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
>>>
>> Hi,
>>
>> It is not clear which series are of interested here. They should be 
>> included in the subject.
>> This page <https://wiki.ubuntu.com/Kernel/Dev/StablePatchFormat> 
>> should explain the format we expect. TDLR you need to send 2 emails, 
>> one for the cover letter and one for the patch itself.
>> We expect the subject for the cover letter to be 
>> "[SRU][<series>][PATCH 0/1] <Short description of what you want to 
>> solve>"
>> And then the patch should not be send as attachment, but as a 
>> separate email with subject "[SRU][<Series>][PATCH 1/1] fbcon: Defer 
>> AND delay console takeover".
>> Make sure you include the buglink in both. And also make sure the 
>> buglink addresses the series that need to be addressed.
>>
>> Now, looking at the patch, this is not upstream, so it will be a 
>> SAUCE patch. I don't think the impact of this is big enough to 
>> deviate from upstream, therefore
>> I am inclined to not accept it. I would recommend proposing it to 
>> upstream first.
>>
>> Roxana
>
This is the page for stable patches 
https://wiki.ubuntu.com/Kernel/Dev/StablePatchFormat.
I will also add a link in to it in 
https://wiki.ubuntu.com/Kernel/Dev/KernelPatches.
diff mbox series

Patch

From 35be19e113dae19d9c86484620d57f628554afa9 Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
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 <daniel.van.vugt@canonical.com>
---
 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 <linux/crc32.h> /* For counting font checksums */
 #include <linux/uaccess.h>
 #include <asm/irq.h>
+#include <asm/cmdline.h>
 
 #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