Re: [PATCH 2/2] fbcon: Defer console takeover for splash screens to first switch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/2/2024 02:53, Daniel van Vugt wrote:
Until now, deferred console takeover only meant defer until there is
output. But that risks stepping on the toes of userspace splash screens,
as console messages may appear before the splash screen. So check for the
"splash" parameter (as used by Plymouth) and if present then extend the
deferral until the first switch.

Closes: https://bugs.launchpad.net/bugs/1970069
Cc: Mario Limonciello <mario.limonciello@xxxxxxx>
Signed-off-by: Daniel van Vugt <daniel.van.vugt@xxxxxxxxxxxxx>
---
  drivers/video/fbdev/core/fbcon.c | 32 +++++++++++++++++++++++++++++---
  1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 63af6ab034..5b9f7635f7 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,7 @@ static inline void fbcon_map_override(void)
#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
  static bool deferred_takeover = true;
+static int initial_console = -1;
  #else
  #define deferred_takeover false
  #endif
@@ -3341,7 +3343,7 @@ static void fbcon_register_existing_fbs(struct work_struct *work)
  	console_unlock();
  }
-static struct notifier_block fbcon_output_nb;
+static struct notifier_block fbcon_output_nb, fbcon_switch_nb;
  static DECLARE_WORK(fbcon_deferred_takeover_work, fbcon_register_existing_fbs);
static int fbcon_output_notifier(struct notifier_block *nb,
@@ -3358,6 +3360,21 @@ static int fbcon_output_notifier(struct notifier_block *nb,
return NOTIFY_OK;
  }
+
+static int fbcon_switch_notifier(struct notifier_block *nb,
+				 unsigned long action, void *data)
+{
+	struct vc_data *vc = data;
+
+	WARN_CONSOLE_UNLOCKED();
+
+	if (vc->vc_num != initial_console) {
+		dummycon_unregister_switch_notifier(&fbcon_switch_nb);
+		dummycon_register_output_notifier(&fbcon_output_nb);
+	}
+
+	return NOTIFY_OK;
+}
  #endif
static void fbcon_start(void)
@@ -3370,7 +3387,14 @@ static void fbcon_start(void)
if (deferred_takeover) {
  		fbcon_output_nb.notifier_call = fbcon_output_notifier;
-		dummycon_register_output_notifier(&fbcon_output_nb);
+		fbcon_switch_nb.notifier_call = fbcon_switch_notifier;
+		initial_console = fg_console;
+
+		if (cmdline_find_option_bool(boot_command_line, "splash"))
+			dummycon_register_switch_notifier(&fbcon_switch_nb);

So there is a problem here that this would only apply if the distro happened to use "splash" which some distros use something different.

I looked at the matching plymouth code [1] and they have a bunch of variations of what they accept and what it does.

[1] https://gitlab.freedesktop.org/plymouth/plymouth/-/blob/main/src/main.c?ref_type=heads#L888

If from the kernel side we're going to have code that caters to the userspace behavior of plymouth we probably need to match all those cases they do too.

Another alternative could be to make it a kernel configuration option for which string to look for to activate this behavior.

+		else
+			dummycon_register_output_notifier(&fbcon_output_nb);
+
  		return;
  	}
  #endif
@@ -3417,8 +3441,10 @@ void __exit fb_console_exit(void)
  {
  #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
  	console_lock();
-	if (deferred_takeover)
+	if (deferred_takeover) {
  		dummycon_unregister_output_notifier(&fbcon_output_nb);
+		dummycon_unregister_switch_notifier(&fbcon_switch_nb);
+	}
  	console_unlock();
cancel_work_sync(&fbcon_deferred_takeover_work);




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux