1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00
Files
OpenVoiceOS/buildroot-external/patches/linux/0148-printk-nbcon-Add-context-to-console_is_usable.patch
2024-04-11 07:47:59 +00:00

121 lines
4.1 KiB
Diff

From 39df1f6eb49929f6d1565234ecd082e5f4669139 Mon Sep 17 00:00:00 2001
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 26 Sep 2023 14:43:30 +0000
Subject: [PATCH 148/198] printk: nbcon: Add context to console_is_usable()
The nbcon consoles have two callbacks to be used for different
contexts. In order to determine if an nbcon console is usable,
console_is_usable() needs to know if it is a context that will
use the write_atomic() callback or the write_thread() callback.
Add an extra parameter @use_atomic to specify this.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
kernel/printk/internal.h | 16 ++++++++++------
kernel/printk/nbcon.c | 6 +++---
kernel/printk/printk.c | 6 ++++--
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 4de36691009b..e5eb7dc25e0a 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -100,7 +100,7 @@ void nbcon_kthread_create(struct console *con);
* which can also play a role in deciding if @con can be used to print
* records.
*/
-static inline bool console_is_usable(struct console *con, short flags)
+static inline bool console_is_usable(struct console *con, short flags, bool use_atomic)
{
if (!(flags & CON_ENABLED))
return false;
@@ -109,10 +109,13 @@ static inline bool console_is_usable(struct console *con, short flags)
return false;
if (flags & CON_NBCON) {
- if (!con->write_atomic)
- return false;
- if (!con->write_thread || !con->kthread)
- return false;
+ if (use_atomic) {
+ if (!con->write_atomic)
+ return false;
+ } else {
+ if (!con->write_thread || !con->kthread)
+ return false;
+ }
} else {
if (!con->write)
return false;
@@ -178,7 +181,8 @@ static inline void nbcon_atomic_flush_all(void) { }
static inline bool nbcon_atomic_emit_next_record(struct console *con, bool *handover,
int cookie) { return false; }
-static inline bool console_is_usable(struct console *con, short flags) { return false; }
+static inline bool console_is_usable(struct console *con, short flags,
+ bool use_atomic) { return false; }
#endif /* CONFIG_PRINTK */
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 1becdfc7772c..bb071193ab6e 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -963,7 +963,7 @@ static bool nbcon_kthread_should_wakeup(struct console *con, struct nbcon_contex
cookie = console_srcu_read_lock();
flags = console_srcu_read_flags(con);
- is_usable = console_is_usable(con, flags);
+ is_usable = console_is_usable(con, flags, false);
console_srcu_read_unlock(cookie);
if (!is_usable)
@@ -1022,7 +1022,7 @@ static int nbcon_kthread_func(void *__console)
con_flags = console_srcu_read_flags(con);
- if (console_is_usable(con, con_flags)) {
+ if (console_is_usable(con, con_flags, false)) {
con->driver_enter(con, &flags);
/*
@@ -1203,7 +1203,7 @@ static void __nbcon_atomic_flush_all(u64 stop_seq, bool allow_unsafe_takeover)
if (!(flags & CON_NBCON))
continue;
- if (!console_is_usable(con, flags))
+ if (!console_is_usable(con, flags, true))
continue;
if (nbcon_seq_read(con) >= stop_seq)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 2a77a4ad5619..3863e3dc3816 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3046,7 +3046,7 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
if ((flags & CON_NBCON) && con->kthread)
continue;
- if (!console_is_usable(con, flags))
+ if (!console_is_usable(con, flags, true))
continue;
any_usable = true;
@@ -3966,8 +3966,10 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
* that they make forward progress, so only increment
* @diff for usable consoles.
*/
- if (!console_is_usable(c, flags))
+ if (!console_is_usable(c, flags, true) &&
+ !console_is_usable(c, flags, false)) {
continue;
+ }
if (flags & CON_NBCON) {
printk_seq = nbcon_seq_read(c);
--
2.44.0