summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0035-printk-nbcon-Add-context-to-console_is_usable.patch
blob: bd434ec3260eb07ff962e75641f562b728bd7b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 26 Sep 2023 14:43:30 +0000
Subject: [PATCH 35/48] printk: nbcon: Add context to console_is_usable()
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.8/older/patches-6.8.2-rt11.tar.xz

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(-)

--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -98,7 +98,7 @@ void nbcon_kthread_create(struct console
  * 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;
@@ -107,10 +107,13 @@ static inline bool console_is_usable(str
 		return false;
 
 	if (flags & CON_NBCON) {
-		if (!con->write_atomic)
-			return false;
-		if (!con->write_thread)
-			return false;
+		if (use_atomic) {
+			if (!con->write_atomic)
+				return false;
+		} else {
+			if (!con->write_thread)
+				return false;
+		}
 	} else {
 		if (!con->write)
 			return false;
@@ -175,7 +178,8 @@ static inline void nbcon_atomic_flush_pe
 static inline bool nbcon_legacy_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 */
 
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -968,7 +968,7 @@ static bool nbcon_kthread_should_wakeup(
 	cookie = console_srcu_read_lock();
 
 	flags = console_srcu_read_flags(con);
-	if (console_is_usable(con, flags)) {
+	if (console_is_usable(con, flags, false)) {
 		/* Bring the sequence in @ctxt up to date */
 		ctxt->seq = nbcon_seq_read(con);
 
@@ -1026,7 +1026,7 @@ static int nbcon_kthread_func(void *__co
 
 		con_flags = console_srcu_read_flags(con);
 
-		if (console_is_usable(con, con_flags)) {
+		if (console_is_usable(con, con_flags, false)) {
 			con->device_lock(con, &flags);
 
 			/*
@@ -1246,7 +1246,7 @@ static void __nbcon_atomic_flush_pending
 			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)
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3056,7 +3056,7 @@ static bool console_flush_all(bool do_co
 			if ((flags & CON_NBCON) && con->kthread)
 				continue;
 
-			if (!console_is_usable(con, flags))
+			if (!console_is_usable(con, flags, true))
 				continue;
 			any_usable = true;
 
@@ -3991,8 +3991,10 @@ static bool __pr_flush(struct console *c
 			 * 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);