diff options
Diffstat (limited to '')
-rw-r--r-- | debian/patches-rt/0022-printk-nbcon-Use-nbcon-consoles-in-console_flush_all.patch (renamed from debian/patches-rt/0026-printk-nbcon-Use-nbcon-consoles-in-console_flush_all.patch) | 109 |
1 files changed, 68 insertions, 41 deletions
diff --git a/debian/patches-rt/0026-printk-nbcon-Use-nbcon-consoles-in-console_flush_all.patch b/debian/patches-rt/0022-printk-nbcon-Use-nbcon-consoles-in-console_flush_all.patch index 512310071b..02c868a001 100644 --- a/debian/patches-rt/0026-printk-nbcon-Use-nbcon-consoles-in-console_flush_all.patch +++ b/debian/patches-rt/0022-printk-nbcon-Use-nbcon-consoles-in-console_flush_all.patch @@ -1,14 +1,15 @@ From: John Ogness <john.ogness@linutronix.de> Date: Tue, 19 Sep 2023 14:33:27 +0000 -Subject: [PATCH 26/50] printk: nbcon: Use nbcon consoles in +Subject: [PATCH 22/48] printk: nbcon: Use nbcon consoles in console_flush_all() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.7/older/patches-6.7-rt6.tar.xz +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.8/older/patches-6.8.2-rt11.tar.xz -Allow nbcon consoles to print messages in the printk() caller -context by integrating them into console_flush_all(). The -write_atomic() callback is used for printing. +Allow nbcon consoles to print messages in the legacy printk() +caller context (printing via unlock) by integrating them into +console_flush_all(). The write_atomic() callback is used for +printing. -Provide nbcon_console_emit_next_record(), which acts as the +Provide nbcon_legacy_emit_next_record(), which acts as the nbcon variant of console_emit_next_record(). Call this variant within console_flush_all() for nbcon consoles. Since nbcon consoles use their own @nbcon_seq variable to track the next @@ -17,14 +18,14 @@ record to print, this also must be appropriately handled. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- - kernel/printk/internal.h | 5 ++++ - kernel/printk/nbcon.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ - kernel/printk/printk.c | 19 +++++++++++++---- - 3 files changed, 69 insertions(+), 5 deletions(-) + kernel/printk/internal.h | 6 +++ + kernel/printk/nbcon.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ + kernel/printk/printk.c | 17 +++++++--- + 3 files changed, 95 insertions(+), 5 deletions(-) --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h -@@ -71,6 +71,8 @@ void defer_console_output(void); +@@ -78,6 +78,8 @@ void defer_console_output(void); u16 printk_parse_prefix(const char *text, int *level, enum printk_info_flags *flags); @@ -33,26 +34,27 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> u64 nbcon_seq_read(struct console *con); void nbcon_seq_force(struct console *con, u64 seq); -@@ -78,6 +80,7 @@ bool nbcon_alloc(struct console *con); +@@ -85,6 +87,8 @@ bool nbcon_alloc(struct console *con); void nbcon_init(struct console *con); void nbcon_free(struct console *con); - void nbcon_atomic_flush_all(void); -+bool nbcon_atomic_emit_next_record(struct console *con, bool *handover, int cookie); + void nbcon_atomic_flush_pending(void); ++bool nbcon_legacy_emit_next_record(struct console *con, bool *handover, ++ int cookie); /* * Check if the given console is currently capable and allowed to print -@@ -133,6 +136,8 @@ static inline bool nbcon_alloc(struct co +@@ -140,6 +144,8 @@ static inline bool nbcon_alloc(struct co static inline void nbcon_init(struct console *con) { } static inline void nbcon_free(struct console *con) { } - static inline void nbcon_atomic_flush_all(void) { } -+static inline bool nbcon_atomic_emit_next_record(struct console *con, bool *handover, + static inline void nbcon_atomic_flush_pending(void) { } ++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; } --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c -@@ -532,6 +532,7 @@ static struct printk_buffers panic_nbcon +@@ -541,6 +541,7 @@ static struct printk_buffers panic_nbcon * nbcon_context_try_acquire - Try to acquire nbcon console * @ctxt: The context of the caller * @@ -60,12 +62,43 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> * Return: True if the console was acquired. False otherwise. * * If the caller allowed an unsafe hostile takeover, on success the -@@ -961,6 +962,55 @@ static bool nbcon_atomic_emit_one(struct +@@ -936,6 +937,82 @@ static bool nbcon_emit_next_record(struc } /** -+ * nbcon_atomic_emit_next_record - Print one record for an nbcon console -+ * using the write_atomic() callback ++ * nbcon_atomic_emit_one - Print one record for an nbcon console using the ++ * write_atomic() callback ++ * @wctxt: An initialized write context struct to use for this context ++ * ++ * Return: False if it is known there are no more records to print, ++ * otherwise true. ++ * ++ * This is an internal helper to handle the locking of the console before ++ * calling nbcon_emit_next_record(). ++ */ ++static bool nbcon_atomic_emit_one(struct nbcon_write_context *wctxt) ++{ ++ struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt); ++ ++ if (!nbcon_context_try_acquire(ctxt)) ++ return true; ++ ++ /* ++ * nbcon_emit_next_record() returns false when the console was ++ * handed over or taken over. In both cases the context is no ++ * longer valid. ++ */ ++ if (!nbcon_emit_next_record(wctxt)) ++ return true; ++ ++ nbcon_context_release(ctxt); ++ ++ return ctxt->backlog; ++} ++ ++/** ++ * nbcon_legacy_emit_next_record - Print one record for an nbcon console ++ * in legacy contexts + * @con: The console to print on + * @handover: Will be set to true if a printk waiter has taken over the + * console_lock, in which case the caller is no longer holding @@ -73,38 +106,34 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + * is set to false. + * @cookie: The cookie from the SRCU read lock. + * -+ * Context: Any context which could not be migrated to another CPU. -+ * Return: True if a record could be printed, otherwise false. ++ * Context: Any context except NMI. ++ * Return: False if the given console has no next record to print, ++ * otherwise true. + * + * This function is meant to be called by console_flush_all() to print records -+ * on nbcon consoles using the write_atomic() callback. Essentially it is the -+ * nbcon version of console_emit_next_record(). ++ * on nbcon consoles from legacy context (printing via console unlocking). ++ * Essentially it is the nbcon version of console_emit_next_record(). + */ -+bool nbcon_atomic_emit_next_record(struct console *con, bool *handover, int cookie) ++bool nbcon_legacy_emit_next_record(struct console *con, bool *handover, ++ int cookie) +{ + struct nbcon_write_context wctxt = { }; + struct nbcon_context *ctxt = &ACCESS_PRIVATE(&wctxt, ctxt); -+ unsigned long driver_flags; -+ bool progress = false; + unsigned long flags; ++ bool progress; + + *handover = false; + -+ /* Use the same locking order as console_emit_next_record(). */ ++ /* Use the same procedure as console_emit_next_record(). */ + printk_safe_enter_irqsave(flags); + console_lock_spinning_enable(); + stop_critical_timings(); + -+ con->driver_enter(con, &driver_flags); -+ cant_migrate(); -+ + ctxt->console = con; + ctxt->prio = NBCON_PRIO_NORMAL; + + progress = nbcon_atomic_emit_one(&wctxt); + -+ con->driver_exit(con, driver_flags); -+ + start_critical_timings(); + *handover = console_lock_spinning_disable_and_check(cookie); + printk_safe_exit_irqrestore(flags); @@ -113,9 +142,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +} + +/** - * __nbcon_atomic_flush_all - Flush all nbcon consoles using their + * __nbcon_atomic_flush_pending_con - Flush specified nbcon console using its * write_atomic() callback - * @stop_seq: Flush up until this record + * @con: The nbcon console to flush --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1871,7 +1871,7 @@ static bool console_waiter; @@ -136,7 +165,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> { int waiter; -@@ -2956,13 +2956,22 @@ static bool console_flush_all(bool do_co +@@ -2956,13 +2956,20 @@ static bool console_flush_all(bool do_co cookie = console_srcu_read_lock(); for_each_console_srcu(con) { short flags = console_srcu_read_flags(con); @@ -149,18 +178,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - progress = console_emit_next_record(con, handover, cookie); + if (flags & CON_NBCON) { -+ progress = nbcon_atomic_emit_next_record(con, handover, cookie); -+ ++ progress = nbcon_legacy_emit_next_record(con, handover, cookie); + printk_seq = nbcon_seq_read(con); + } else { + progress = console_emit_next_record(con, handover, cookie); -+ + printk_seq = con->seq; + } /* * If a handover has occurred, the SRCU read lock -@@ -2972,8 +2981,8 @@ static bool console_flush_all(bool do_co +@@ -2972,8 +2979,8 @@ static bool console_flush_all(bool do_co return false; /* Track the next of the highest seq flushed. */ |