mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-02-12 18:00:45 +01:00
70 lines
2.4 KiB
Diff
70 lines
2.4 KiB
Diff
From 5704d4e1efa542678fc9b9e57e01175202358237 Mon Sep 17 00:00:00 2001
|
|
From: John Ogness <john.ogness@linutronix.de>
|
|
Date: Mon, 11 Dec 2023 09:34:16 +0000
|
|
Subject: [PATCH 161/195] printk: Avoid false positive lockdep report for
|
|
legacy driver.
|
|
|
|
printk may invoke the legacy console driver from atomic context. This leads to
|
|
a lockdep splat because the console driver will acquire a sleeping lock and the
|
|
caller may also hold a spinning lock. This is noticed by lockdep on !PREEMPT_RT
|
|
configurations because it will also lead to a problem on PREEMPT_RT.
|
|
|
|
On PREEMPT_RT the atomic path is always avoided and the console driver is
|
|
always invoked from a dedicated thread. Thus the lockdep splat is a false
|
|
positive.
|
|
|
|
Override the lock-context before invoking the console driver.
|
|
|
|
Signed-off-by: John Ogness <john.ogness@linutronix.de>
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
---
|
|
kernel/printk/printk.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
|
|
index afc044632dec..ddf79752c80c 100644
|
|
--- a/kernel/printk/printk.c
|
|
+++ b/kernel/printk/printk.c
|
|
@@ -2817,6 +2817,8 @@ static void __console_unlock(void)
|
|
up_console_sem();
|
|
}
|
|
|
|
+static DEFINE_WAIT_OVERRIDE_MAP(printk_legacy_map, LD_WAIT_SLEEP);
|
|
+
|
|
#ifdef CONFIG_PRINTK
|
|
|
|
/*
|
|
@@ -2985,7 +2987,7 @@ static bool console_emit_next_record(struct console *con, bool *handover, int co
|
|
/*
|
|
* On PREEMPT_RT this function is either in a thread or
|
|
* panic context. So there is no need for concern about
|
|
- * printk reentrance or handovers.
|
|
+ * printk reentrance, handovers, or lockdep complaints.
|
|
*/
|
|
|
|
con->write(con, outbuf, pmsg.outbuf_len);
|
|
@@ -3007,7 +3009,9 @@ static bool console_emit_next_record(struct console *con, bool *handover, int co
|
|
/* Do not trace print latency. */
|
|
stop_critical_timings();
|
|
|
|
+ lock_map_acquire_try(&printk_legacy_map);
|
|
con->write(con, outbuf, pmsg.outbuf_len);
|
|
+ lock_map_release(&printk_legacy_map);
|
|
|
|
start_critical_timings();
|
|
|
|
@@ -3084,7 +3088,10 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
|
|
any_usable = true;
|
|
|
|
if (flags & CON_NBCON) {
|
|
+
|
|
+ lock_map_acquire_try(&printk_legacy_map);
|
|
progress = nbcon_atomic_emit_next_record(con, handover, cookie);
|
|
+ lock_map_release(&printk_legacy_map);
|
|
|
|
printk_seq = nbcon_seq_read(con);
|
|
} else {
|
|
--
|
|
2.43.0
|
|
|