author: John Ogness <john.ogness@linutronix.de> 2020-11-30 01:42:09 +0106
committer: Minda Chen <minda.chen@starfivetech.com> 2023-11-06 19:24:37 +0800
commit: 6c65488ffd95ca0a1aa66070281da3508c1a3897
parent: 5c17a5c18154f25e16336b4127f8d14916d5d028
Commit Summary:
Diffstat:
2 files changed, 13 insertions, 2 deletions
diff --git a/include/linux/console.h b/include/linux/console.h
index ba2949608417..dedbcf82fa0f 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -143,6 +143,7 @@ static inline int con_debug_leave(void)
#define CON_ANYTIME (16) /* Safe to call when cpu is offline */
#define CON_BRL (32) /* Used for a braille device */
#define CON_EXTENDED (64) /* Use the extended output format a la /dev/kmsg */
+#define CON_HANDOVER (128) /* Device was previously a boot console. */
struct console {
char name[16];
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index d49fd4f6499a..e3633917440d 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1746,6 +1746,8 @@ static bool console_may_sync(struct console *con)
return false;
if (con->write_atomic && kernel_sync_mode())
return true;
+ if (con->write_atomic && (con->flags & CON_HANDOVER) && !con->thread)
+ return true;
if (con->write && (con->flags & CON_BOOT) && !con->thread)
return true;
return false;
@@ -1761,7 +1763,14 @@ static bool call_sync_console_driver(struct console *con, const char *text, size
return true;
}
- if (con->write && (con->flags & CON_BOOT) && !con->thread) {
+ if (con->write_atomic && (con->flags & CON_HANDOVER) && !con->thread) {
+ if (console_trylock()) {
+ con->write_atomic(con, text, text_len);
+ console_unlock();
+ return true;
+ }
+
+ } else if (con->write && (con->flags & CON_BOOT) && !con->thread) {
if (console_trylock()) {
con->write(con, text, text_len);
console_unlock();
@@ -2891,8 +2900,10 @@ void register_console(struct console *newcon)
* the real console are the same physical device, it's annoying to
* see the beginning boot messages twice
*/
- if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV))
+ if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV)) {
newcon->flags &= ~CON_PRINTBUFFER;
+ newcon->flags |= CON_HANDOVER;
+ }
/*
* Put this console in the list - keep the