public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/5] Handle NBCON consoles on KDB
@ 2025-10-16 14:47 Marcos Paulo de Souza
  2025-10-16 14:47 ` [PATCH v6 1/5] printk: nbcon: Export console_is_usable Marcos Paulo de Souza
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-16 14:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Petr Mladek, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson
  Cc: linux-kernel, kgdb-bugreport, Marcos Paulo de Souza

In v6 the patches were rebased on top of v6.18-rc1, added Reviewed-by tags from
John and did some small changes suggested by him as well.

As usual, how I tested the changes:

Testing
-------

I did the tests using qemu and reapplying commit f79b163c4231
('Revert "serial: 8250: Switch to nbcon console"') created originally by
John, just to exercise the common 8250 serial from qemu. The commit can
be checked on [1]. I had to solve some conflicts since the code has been
reworked after the commit was reverted.

Then I would create three different serial entries on qemu:
-serial mon:stdio -serial pty -serial pty

And for the kernel command line I added:
earlyprintk=serial,ttyS2 console=ttyS2 console=ttyS1 console=ttyS1 kgdboc=ttyS1,115200

Without the last patch on this patchset, when KDB is triggered, the mirroring
only worked on the earlyprintk console, since it's using the legacy console.

With the last patch applied, KDB mirroring works on legacy and nbcon
console. For debugging I added some messages to be printed by KDB, showing
also the console->name and console->index, and I was able to see both
->write and ->write_atomic being called, and it all working together.

[1]: https://github.com/marcosps/linux/commit/618bd49f8533db85d9c322f9ad1cb0da22aca9ee
[2]: https://lore.kernel.org/lkml/20250825022947.1596226-1-wangjinchao600@gmail.com/

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
Changes in v6:
- Rebased on top opf v6.18-rc1
- Changed some includes, as suggedted by John
- Reworked comments as suggested by John

Changes in v5:
- Added review tags from Petr
- Changes the way we detect if a CPU is running KDB.
- Link to v4: https://lore.kernel.org/r/20250915-nbcon-kgdboc-v4-0-e2b6753bb566@suse.com

Changes in v4:
- Added ifdefs to only check for KGDB if KGDB was enabled, suggested by John Ogness
- Updated comments about KDB on acquire_direct, suggested by Petr and John
- Added a new patch to export nbcon_write_context_set_buf, suggested by Petr and John
- Link to v3: https://lore.kernel.org/r/20250902-nbcon-kgdboc-v3-0-cd30a8106f1c@suse.com

Changes in v3:
- Only call nbcon_context_release if nbcon_context_exit_unsafe returns true (John Ogness)
- Dropped the prototype of console_is_usable from kernel/printk/internal. (Petr Mladek)
- Add comments to the new functions introduced (Petr Mladek)
- Flush KDB console on nbcon_kdb_release (Petr Mladek)
- Add an exception for KDB on nbcon_context_try_acquire_direct (John Ogness and Petr Mladek)
- Link to v2: https://lore.kernel.org/r/20250811-nbcon-kgdboc-v2-0-c7c72bcdeaf6@suse.com

Changes in v2:
- Set by mistake ..
- Link to v1: https://lore.kernel.org/r/20250713-nbcon-kgdboc-v1-0-51eccd9247a8@suse.com

---
Marcos Paulo de Souza (5):
      printk: nbcon: Export console_is_usable
      printk: nbcon: Introduce KDB helpers
      printk: nbcon: Allow KDB to acquire the NBCON context
      printk: nbcon: Export nbcon_write_context_set_buf
      kdb: Adapt kdb_msg_write to work with NBCON consoles

 include/linux/console.h   | 55 ++++++++++++++++++++++++++++++++++++
 include/linux/kdb.h       | 16 +++++++++++
 kernel/debug/kdb/kdb_io.c | 47 +++++++++++++++++++++----------
 kernel/printk/internal.h  | 45 ------------------------------
 kernel/printk/nbcon.c     | 71 +++++++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 171 insertions(+), 63 deletions(-)
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20250713-nbcon-kgdboc-efcfc37fde46

Best regards,
--  
Marcos Paulo de Souza <mpdesouza@suse.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v6 1/5] printk: nbcon: Export console_is_usable
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
@ 2025-10-16 14:47 ` Marcos Paulo de Souza
  2025-10-16 14:47 ` [PATCH v6 2/5] printk: nbcon: Introduce KDB helpers Marcos Paulo de Souza
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-16 14:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Petr Mladek, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson
  Cc: linux-kernel, kgdb-bugreport, Marcos Paulo de Souza

The helper will be used on KDB code in the next commits.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 include/linux/console.h  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 kernel/printk/internal.h | 45 ---------------------------------------------
 2 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/include/linux/console.h b/include/linux/console.h
index 031a58dc2b91..1fda485ec2fa 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -19,6 +19,7 @@
 #include <linux/irq_work.h>
 #include <linux/rculist.h>
 #include <linux/rcuwait.h>
+#include <linux/smp.h>
 #include <linux/types.h>
 #include <linux/vesa.h>
 
@@ -605,6 +606,48 @@ extern bool nbcon_can_proceed(struct nbcon_write_context *wctxt);
 extern bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt);
 extern bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt);
 extern void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt);
+
+/*
+ * Check if the given console is currently capable and allowed to print
+ * records. Note that this function does not consider the current context,
+ * 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, bool use_atomic)
+{
+	if (!(flags & CON_ENABLED))
+		return false;
+
+	if ((flags & CON_SUSPENDED))
+		return false;
+
+	if (flags & CON_NBCON) {
+		/* The write_atomic() callback is optional. */
+		if (use_atomic && !con->write_atomic)
+			return false;
+
+		/*
+		 * For the !use_atomic case, @printk_kthreads_running is not
+		 * checked because the write_thread() callback is also used
+		 * via the legacy loop when the printer threads are not
+		 * available.
+		 */
+	} else {
+		if (!con->write)
+			return false;
+	}
+
+	/*
+	 * Console drivers may assume that per-cpu resources have been
+	 * allocated. So unless they're explicitly marked as being able to
+	 * cope (CON_ANYTIME) don't call them until this CPU is officially up.
+	 */
+	if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
+		return false;
+
+	return true;
+}
+
 #else
 static inline void nbcon_cpu_emergency_enter(void) { }
 static inline void nbcon_cpu_emergency_exit(void) { }
@@ -612,6 +655,8 @@ static inline bool nbcon_can_proceed(struct nbcon_write_context *wctxt) { return
 static inline bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt) { return false; }
 static inline bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt) { return false; }
 static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { }
+static inline bool console_is_usable(struct console *con, short flags,
+				     bool use_atomic) { return false; }
 #endif
 
 extern int console_set_on_cmdline;
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index f72bbfa266d6..7e3128ec9336 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -3,7 +3,6 @@
  * internal.h - printk internal definitions
  */
 #include <linux/console.h>
-#include <linux/percpu.h>
 #include <linux/types.h>
 
 #if defined(CONFIG_PRINTK) && defined(CONFIG_SYSCTL)
@@ -112,47 +111,6 @@ bool nbcon_kthread_create(struct console *con);
 void nbcon_kthread_stop(struct console *con);
 void nbcon_kthreads_wake(void);
 
-/*
- * Check if the given console is currently capable and allowed to print
- * records. Note that this function does not consider the current context,
- * 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, bool use_atomic)
-{
-	if (!(flags & CON_ENABLED))
-		return false;
-
-	if ((flags & CON_SUSPENDED))
-		return false;
-
-	if (flags & CON_NBCON) {
-		/* The write_atomic() callback is optional. */
-		if (use_atomic && !con->write_atomic)
-			return false;
-
-		/*
-		 * For the !use_atomic case, @printk_kthreads_running is not
-		 * checked because the write_thread() callback is also used
-		 * via the legacy loop when the printer threads are not
-		 * available.
-		 */
-	} else {
-		if (!con->write)
-			return false;
-	}
-
-	/*
-	 * Console drivers may assume that per-cpu resources have been
-	 * allocated. So unless they're explicitly marked as being able to
-	 * cope (CON_ANYTIME) don't call them until this CPU is officially up.
-	 */
-	if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
-		return false;
-
-	return true;
-}
-
 /**
  * nbcon_kthread_wake - Wake up a console printing thread
  * @con:	Console to operate on
@@ -204,9 +162,6 @@ static inline bool nbcon_legacy_emit_next_record(struct console *con, bool *hand
 static inline void nbcon_kthread_wake(struct console *con) { }
 static inline void nbcon_kthreads_wake(void) { }
 
-static inline bool console_is_usable(struct console *con, short flags,
-				     bool use_atomic) { return false; }
-
 #endif /* CONFIG_PRINTK */
 
 extern bool have_boot_console;

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 2/5] printk: nbcon: Introduce KDB helpers
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
  2025-10-16 14:47 ` [PATCH v6 1/5] printk: nbcon: Export console_is_usable Marcos Paulo de Souza
@ 2025-10-16 14:47 ` Marcos Paulo de Souza
  2025-10-17 10:16   ` Petr Mladek
  2025-10-16 14:47 ` [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context Marcos Paulo de Souza
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-16 14:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Petr Mladek, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson
  Cc: linux-kernel, kgdb-bugreport, Marcos Paulo de Souza

These helpers will be used when calling console->write_atomic on
KDB code in the next patch. It's basically the same implementation
as nbcon_device_try_acquire, but using NBCON_PRIO_EMERGENCY when
acquiring the context.

If the acquire succeeds, the message and message length are assigned to
nbcon_write_context so ->write_atomic can print the message.

After release try to flush the console since there may be a backlog of
messages in the ringbuffer. The kthread console printers do not get a
chance to run while kdb is active.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 include/linux/console.h |  6 +++++
 kernel/printk/nbcon.c   | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/include/linux/console.h b/include/linux/console.h
index 1fda485ec2fa..0d589a933b6b 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -606,6 +606,9 @@ extern bool nbcon_can_proceed(struct nbcon_write_context *wctxt);
 extern bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt);
 extern bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt);
 extern void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt);
+extern bool nbcon_kdb_try_acquire(struct console *con,
+				  struct nbcon_write_context *wctxt);
+extern void nbcon_kdb_release(struct nbcon_write_context *wctxt);
 
 /*
  * Check if the given console is currently capable and allowed to print
@@ -655,6 +658,9 @@ static inline bool nbcon_can_proceed(struct nbcon_write_context *wctxt) { return
 static inline bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt) { return false; }
 static inline bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt) { return false; }
 static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { }
+static inline bool nbcon_kdb_try_acquire(struct console *con,
+					 struct nbcon_write_context *wctxt) { return false; }
+static inline void nbcon_kdb_release(struct console *con) { }
 static inline bool console_is_usable(struct console *con, short flags,
 				     bool use_atomic) { return false; }
 #endif
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 558ef3177976..e1bf5409cb6b 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1855,3 +1855,64 @@ void nbcon_device_release(struct console *con)
 	console_srcu_read_unlock(cookie);
 }
 EXPORT_SYMBOL_GPL(nbcon_device_release);
+
+/**
+ * nbcon_kdb_try_acquire - Try to acquire nbcon console and enter unsafe
+ *			   section
+ * @con:	The nbcon console to acquire
+ * @wctxt:	The nbcon write context to be used on success
+ *
+ * Context:	Under console_srcu_read_lock() for emitting a single kdb message
+ *		using the given con->write_atomic() callback. Can be called
+ *		only when the console is usable at the moment.
+ *
+ * Return:	True if the console was acquired. False otherwise.
+ *
+ * kdb emits messages on consoles registered for printk() without
+ * storing them into the ring buffer. It has to acquire the console
+ * ownerhip so that it could call con->write_atomic() callback a safe way.
+ *
+ * This function acquires the nbcon console using priority NBCON_PRIO_EMERGENCY
+ * and marks it unsafe for handover/takeover.
+ */
+bool nbcon_kdb_try_acquire(struct console *con,
+			   struct nbcon_write_context *wctxt)
+{
+	struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt);
+
+	memset(ctxt, 0, sizeof(*ctxt));
+	ctxt->console = con;
+	ctxt->prio    = NBCON_PRIO_EMERGENCY;
+
+	if (!nbcon_context_try_acquire(ctxt, false))
+		return false;
+
+	if (!nbcon_context_enter_unsafe(ctxt))
+		return false;
+
+	return true;
+}
+
+/**
+ * nbcon_kdb_release - Exit unsafe section and release the nbcon console
+ *
+ * @wctxt:	The nbcon write context initialized by a successful
+ *		nbcon_kdb_try_acquire()
+ */
+void nbcon_kdb_release(struct nbcon_write_context *wctxt)
+{
+	struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt);
+
+	if (!nbcon_context_exit_unsafe(ctxt))
+		return;
+
+	nbcon_context_release(ctxt);
+
+	/*
+	 * Flush any new printk() messages added when the console was blocked.
+	 * Only the console used by the given write context was	blocked.
+	 * The console was locked only when the write_atomic() callback
+	 * was usable.
+	 */
+	__nbcon_atomic_flush_pending_con(ctxt->console, prb_next_reserve_seq(prb), false);
+}

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
  2025-10-16 14:47 ` [PATCH v6 1/5] printk: nbcon: Export console_is_usable Marcos Paulo de Souza
  2025-10-16 14:47 ` [PATCH v6 2/5] printk: nbcon: Introduce KDB helpers Marcos Paulo de Souza
@ 2025-10-16 14:47 ` Marcos Paulo de Souza
  2025-10-17  1:25   ` kernel test robot
  2025-10-17  9:22   ` Petr Mladek
  2025-10-16 14:47 ` [PATCH v6 4/5] printk: nbcon: Export nbcon_write_context_set_buf Marcos Paulo de Souza
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-16 14:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Petr Mladek, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson
  Cc: linux-kernel, kgdb-bugreport, Marcos Paulo de Souza

KDB can interrupt any console to execute the "mirrored printing" at any
time, so add an exception to nbcon_context_try_acquire_direct to allow
to get the context if the current CPU is the same as kdb_printf_cpu.

This change will be necessary for the next patch, which fixes
kdb_msg_write to work with NBCON consoles by calling ->write_atomic on
such consoles. But to print it first needs to acquire the ownership of
the console, so nbcon_context_try_acquire_direct is fixed here.

Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 include/linux/kdb.h   | 16 ++++++++++++++++
 kernel/printk/nbcon.c |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index ecbf819deeca..db9d73b12a1a 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -14,6 +14,7 @@
  */
 
 #include <linux/list.h>
+#include <linux/smp.h>
 
 /* Shifted versions of the command enable bits are be used if the command
  * has no arguments (see kdb_check_flags). This allows commands, such as
@@ -207,11 +208,26 @@ static inline const char *kdb_walk_kallsyms(loff_t *pos)
 /* Dynamic kdb shell command registration */
 extern int kdb_register(kdbtab_t *cmd);
 extern void kdb_unregister(kdbtab_t *cmd);
+
+/* Return true when KDB as locked for printing a message on this CPU. */
+static inline
+bool kdb_printf_on_this_cpu(void)
+{
+	/*
+	 * We can use raw_smp_processor_id() here because the task could
+	 * not get migrated when KDB has locked for printing on this CPU.
+	 */
+	return unlikely(READ_ONCE(kdb_printf_cpu) == raw_smp_processor_id());
+}
+
 #else /* ! CONFIG_KGDB_KDB */
 static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
 static inline void kdb_init(int level) {}
 static inline int kdb_register(kdbtab_t *cmd) { return 0; }
 static inline void kdb_unregister(kdbtab_t *cmd) {}
+
+static inline bool kdb_printf_on_this_cpu(void) { return false };
+
 #endif	/* CONFIG_KGDB_KDB */
 enum {
 	KDB_NOT_INITIALIZED,
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index e1bf5409cb6b..5be018493909 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -10,6 +10,7 @@
 #include <linux/export.h>
 #include <linux/init.h>
 #include <linux/irqflags.h>
+#include <linux/kdb.h>
 #include <linux/kthread.h>
 #include <linux/minmax.h>
 #include <linux/panic.h>
@@ -249,13 +250,16 @@ static int nbcon_context_try_acquire_direct(struct nbcon_context *ctxt,
 		 * since all non-panic CPUs are stopped during panic(), it
 		 * is safer to have them avoid gaining console ownership.
 		 *
-		 * If this acquire is a reacquire (and an unsafe takeover
+		 * One exception is when kdb has locked for printing on this CPU.
+		 *
+		 * Second exception is a reacquire (and an unsafe takeover
 		 * has not previously occurred) then it is allowed to attempt
 		 * a direct acquire in panic. This gives console drivers an
 		 * opportunity to perform any necessary cleanup if they were
 		 * interrupted by the panic CPU while printing.
 		 */
 		if (panic_on_other_cpu() &&
+		    !kdb_printf_on_this_cpu() &&
 		    (!is_reacquire || cur->unsafe_takeover)) {
 			return -EPERM;
 		}

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 4/5] printk: nbcon: Export nbcon_write_context_set_buf
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
                   ` (2 preceding siblings ...)
  2025-10-16 14:47 ` [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context Marcos Paulo de Souza
@ 2025-10-16 14:47 ` Marcos Paulo de Souza
  2025-10-16 14:47 ` [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles Marcos Paulo de Souza
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-16 14:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Petr Mladek, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson
  Cc: linux-kernel, kgdb-bugreport, Marcos Paulo de Souza

This function will be used in the next patch to allow a driver to set
both the message and message length of a nbcon_write_context. This is
necessary because the function also initializes the ->unsafe_takeover
struct member. By using this helper we ensure that the struct is
initialized correctly.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 include/linux/console.h | 4 ++++
 kernel/printk/nbcon.c   | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/console.h b/include/linux/console.h
index 0d589a933b6b..81d2c247c01f 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -603,6 +603,8 @@ static inline bool console_is_registered(const struct console *con)
 extern void nbcon_cpu_emergency_enter(void);
 extern void nbcon_cpu_emergency_exit(void);
 extern bool nbcon_can_proceed(struct nbcon_write_context *wctxt);
+extern void nbcon_write_context_set_buf(struct nbcon_write_context *wctxt,
+					char *buf, unsigned int len);
 extern bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt);
 extern bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt);
 extern void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt);
@@ -655,6 +657,8 @@ static inline bool console_is_usable(struct console *con, short flags, bool use_
 static inline void nbcon_cpu_emergency_enter(void) { }
 static inline void nbcon_cpu_emergency_exit(void) { }
 static inline bool nbcon_can_proceed(struct nbcon_write_context *wctxt) { return false; }
+static inline void nbcon_write_context_set_buf(struct nbcon_write_context *wctxt,
+					       char *buf, unsigned int len) { }
 static inline bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt) { return false; }
 static inline bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt) { return false; }
 static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { }
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 5be018493909..fdd1cbebe77d 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -854,8 +854,8 @@ static bool __nbcon_context_update_unsafe(struct nbcon_context *ctxt, bool unsaf
 	return nbcon_context_can_proceed(ctxt, &cur);
 }
 
-static void nbcon_write_context_set_buf(struct nbcon_write_context *wctxt,
-					char *buf, unsigned int len)
+void nbcon_write_context_set_buf(struct nbcon_write_context *wctxt,
+				 char *buf, unsigned int len)
 {
 	struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt);
 	struct console *con = ctxt->console;

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
                   ` (3 preceding siblings ...)
  2025-10-16 14:47 ` [PATCH v6 4/5] printk: nbcon: Export nbcon_write_context_set_buf Marcos Paulo de Souza
@ 2025-10-16 14:47 ` Marcos Paulo de Souza
  2025-10-17  2:17   ` kernel test robot
  2025-10-17  7:14   ` kernel test robot
  2025-10-17 11:34 ` [PATCH v6 0/5] Handle NBCON consoles on KDB Petr Mladek
  2025-10-24 11:52 ` Petr Mladek
  6 siblings, 2 replies; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-16 14:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Petr Mladek, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson
  Cc: linux-kernel, kgdb-bugreport, Marcos Paulo de Souza

Function kdb_msg_write was calling con->write for any found console,
but it won't work on NBCON consoles. In this case we should acquire the
ownership of the console using NBCON_PRIO_EMERGENCY, since printing
kdb messages should only be interrupted by a panic.

At this point, the console is required to use the atomic callback. The
console is skipped if the write_atomic callback is not set or if the
context could not be acquired. The validation of NBCON is done by the
console_is_usable helper. The context is released right after
write_atomic finishes.

The oops_in_progress handling is only needed in the legacy consoles,
so it was moved around the con->write callback.

Suggested-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 kernel/debug/kdb/kdb_io.c | 47 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index b12b9db75c1d..61c1690058ed 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -589,24 +589,41 @@ static void kdb_msg_write(const char *msg, int msg_len)
 	 */
 	cookie = console_srcu_read_lock();
 	for_each_console_srcu(c) {
-		if (!(console_srcu_read_flags(c) & CON_ENABLED))
+		short flags = console_srcu_read_flags(c);
+
+		if (!console_is_usable(c, flags, true))
 			continue;
 		if (c == dbg_io_ops->cons)
 			continue;
-		if (!c->write)
-			continue;
-		/*
-		 * Set oops_in_progress to encourage the console drivers to
-		 * disregard their internal spin locks: in the current calling
-		 * context the risk of deadlock is a bigger problem than risks
-		 * due to re-entering the console driver. We operate directly on
-		 * oops_in_progress rather than using bust_spinlocks() because
-		 * the calls bust_spinlocks() makes on exit are not appropriate
-		 * for this calling context.
-		 */
-		++oops_in_progress;
-		c->write(c, msg, msg_len);
-		--oops_in_progress;
+
+		if (flags & CON_NBCON) {
+			struct nbcon_write_context wctxt = { };
+
+			/*
+			 * Do not continue if the console is NBCON and the context
+			 * can't be acquired.
+			 */
+			if (!nbcon_kdb_try_acquire(c, &wctxt))
+				continue;
+
+			nbcon_write_context_set_buf(&wctxt, (char *)msg, msg_len);
+
+			c->write_atomic(c, &wctxt);
+			nbcon_kdb_release(&wctxt);
+		} else {
+			/*
+			 * Set oops_in_progress to encourage the console drivers to
+			 * disregard their internal spin locks: in the current calling
+			 * context the risk of deadlock is a bigger problem than risks
+			 * due to re-entering the console driver. We operate directly on
+			 * oops_in_progress rather than using bust_spinlocks() because
+			 * the calls bust_spinlocks() makes on exit are not appropriate
+			 * for this calling context.
+			 */
+			++oops_in_progress;
+			c->write(c, msg, msg_len);
+			--oops_in_progress;
+		}
 		touch_nmi_watchdog();
 	}
 	console_srcu_read_unlock(cookie);

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context
  2025-10-16 14:47 ` [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context Marcos Paulo de Souza
@ 2025-10-17  1:25   ` kernel test robot
  2025-10-17  9:19     ` Petr Mladek
  2025-10-17  9:22   ` Petr Mladek
  1 sibling, 1 reply; 16+ messages in thread
From: kernel test robot @ 2025-10-17  1:25 UTC (permalink / raw)
  To: Marcos Paulo de Souza, Greg Kroah-Hartman, Petr Mladek,
	Steven Rostedt, John Ogness, Sergey Senozhatsky, Jason Wessel,
	Daniel Thompson, Douglas Anderson
  Cc: oe-kbuild-all, linux-kernel, kgdb-bugreport,
	Marcos Paulo de Souza

Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 3a8660878839faadb4f1a6dd72c3179c1df56787]

url:    https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-nbcon-Export-console_is_usable/20251016-225503
base:   3a8660878839faadb4f1a6dd72c3179c1df56787
patch link:    https://lore.kernel.org/r/20251016-nbcon-kgdboc-v6-3-866aac60a80e%40suse.com
patch subject: [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context
config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20251017/202510170949.NTx9lt0p-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251017/202510170949.NTx9lt0p-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510170949.NTx9lt0p-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from kernel/kallsyms.c:19:
   include/linux/kdb.h: In function 'kdb_printf_on_this_cpu':
>> include/linux/kdb.h:229:63: error: expected ';' before '}' token
     229 | static inline bool kdb_printf_on_this_cpu(void) { return false };
         |                                                               ^~
         |                                                               ;


vim +229 include/linux/kdb.h

   228	
 > 229	static inline bool kdb_printf_on_this_cpu(void) { return false };
   230	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
  2025-10-16 14:47 ` [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles Marcos Paulo de Souza
@ 2025-10-17  2:17   ` kernel test robot
  2025-10-17 10:12     ` Petr Mladek
  2025-10-17  7:14   ` kernel test robot
  1 sibling, 1 reply; 16+ messages in thread
From: kernel test robot @ 2025-10-17  2:17 UTC (permalink / raw)
  To: Marcos Paulo de Souza, Greg Kroah-Hartman, Petr Mladek,
	Steven Rostedt, John Ogness, Sergey Senozhatsky, Jason Wessel,
	Daniel Thompson, Douglas Anderson
  Cc: llvm, oe-kbuild-all, linux-kernel, kgdb-bugreport,
	Marcos Paulo de Souza

Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 3a8660878839faadb4f1a6dd72c3179c1df56787]

url:    https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-nbcon-Export-console_is_usable/20251016-225503
base:   3a8660878839faadb4f1a6dd72c3179c1df56787
patch link:    https://lore.kernel.org/r/20251016-nbcon-kgdboc-v6-5-866aac60a80e%40suse.com
patch subject: [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
config: i386-buildonly-randconfig-006-20251017 (https://download.01.org/0day-ci/archive/20251017/202510171023.YREXxhMK-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251017/202510171023.YREXxhMK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510171023.YREXxhMK-lkp@intel.com/

All errors (new ones prefixed by >>):

>> kernel/debug/kdb/kdb_io.c:612:22: error: incompatible pointer types passing 'struct nbcon_write_context *' to parameter of type 'struct console *' [-Werror,-Wincompatible-pointer-types]
     612 |                         nbcon_kdb_release(&wctxt);
         |                                           ^~~~~~
   include/linux/console.h:667:54: note: passing argument to parameter 'con' here
     667 | static inline void nbcon_kdb_release(struct console *con) { }
         |                                                      ^
   1 error generated.


vim +612 kernel/debug/kdb/kdb_io.c

   560	
   561	static void kdb_msg_write(const char *msg, int msg_len)
   562	{
   563		struct console *c;
   564		const char *cp;
   565		int cookie;
   566		int len;
   567	
   568		if (msg_len == 0)
   569			return;
   570	
   571		cp = msg;
   572		len = msg_len;
   573	
   574		while (len--) {
   575			dbg_io_ops->write_char(*cp);
   576			cp++;
   577		}
   578	
   579		/*
   580		 * The console_srcu_read_lock() only provides safe console list
   581		 * traversal. The use of the ->write() callback relies on all other
   582		 * CPUs being stopped at the moment and console drivers being able to
   583		 * handle reentrance when @oops_in_progress is set.
   584		 *
   585		 * There is no guarantee that every console driver can handle
   586		 * reentrance in this way; the developer deploying the debugger
   587		 * is responsible for ensuring that the console drivers they
   588		 * have selected handle reentrance appropriately.
   589		 */
   590		cookie = console_srcu_read_lock();
   591		for_each_console_srcu(c) {
   592			short flags = console_srcu_read_flags(c);
   593	
   594			if (!console_is_usable(c, flags, true))
   595				continue;
   596			if (c == dbg_io_ops->cons)
   597				continue;
   598	
   599			if (flags & CON_NBCON) {
   600				struct nbcon_write_context wctxt = { };
   601	
   602				/*
   603				 * Do not continue if the console is NBCON and the context
   604				 * can't be acquired.
   605				 */
   606				if (!nbcon_kdb_try_acquire(c, &wctxt))
   607					continue;
   608	
   609				nbcon_write_context_set_buf(&wctxt, (char *)msg, msg_len);
   610	
   611				c->write_atomic(c, &wctxt);
 > 612				nbcon_kdb_release(&wctxt);
   613			} else {
   614				/*
   615				 * Set oops_in_progress to encourage the console drivers to
   616				 * disregard their internal spin locks: in the current calling
   617				 * context the risk of deadlock is a bigger problem than risks
   618				 * due to re-entering the console driver. We operate directly on
   619				 * oops_in_progress rather than using bust_spinlocks() because
   620				 * the calls bust_spinlocks() makes on exit are not appropriate
   621				 * for this calling context.
   622				 */
   623				++oops_in_progress;
   624				c->write(c, msg, msg_len);
   625				--oops_in_progress;
   626			}
   627			touch_nmi_watchdog();
   628		}
   629		console_srcu_read_unlock(cookie);
   630	}
   631	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
  2025-10-16 14:47 ` [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles Marcos Paulo de Souza
  2025-10-17  2:17   ` kernel test robot
@ 2025-10-17  7:14   ` kernel test robot
  1 sibling, 0 replies; 16+ messages in thread
From: kernel test robot @ 2025-10-17  7:14 UTC (permalink / raw)
  To: Marcos Paulo de Souza, Greg Kroah-Hartman, Petr Mladek,
	Steven Rostedt, John Ogness, Sergey Senozhatsky, Jason Wessel,
	Daniel Thompson, Douglas Anderson
  Cc: oe-kbuild-all, linux-kernel, kgdb-bugreport,
	Marcos Paulo de Souza

Hi Marcos,

kernel test robot noticed the following build errors:

[auto build test ERROR on 3a8660878839faadb4f1a6dd72c3179c1df56787]

url:    https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-nbcon-Export-console_is_usable/20251016-225503
base:   3a8660878839faadb4f1a6dd72c3179c1df56787
patch link:    https://lore.kernel.org/r/20251016-nbcon-kgdboc-v6-5-866aac60a80e%40suse.com
patch subject: [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
config: sh-randconfig-002-20251017 (https://download.01.org/0day-ci/archive/20251017/202510171450.G2KdvDMm-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251017/202510171450.G2KdvDMm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510171450.G2KdvDMm-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/debug/kdb/kdb_io.c: In function 'kdb_msg_write':
>> kernel/debug/kdb/kdb_io.c:612:43: error: passing argument 1 of 'nbcon_kdb_release' from incompatible pointer type [-Wincompatible-pointer-types]
     612 |                         nbcon_kdb_release(&wctxt);
         |                                           ^~~~~~
         |                                           |
         |                                           struct nbcon_write_context *
   In file included from kernel/debug/kdb/kdb_io.c:17:
   include/linux/console.h:667:54: note: expected 'struct console *' but argument is of type 'struct nbcon_write_context *'
     667 | static inline void nbcon_kdb_release(struct console *con) { }
         |                                      ~~~~~~~~~~~~~~~~^~~

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for I2C_K1
   Depends on [n]: I2C [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && OF [=n]
   Selected by [y]:
   - MFD_SPACEMIT_P1 [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && I2C [=y]


vim +/nbcon_kdb_release +612 kernel/debug/kdb/kdb_io.c

   560	
   561	static void kdb_msg_write(const char *msg, int msg_len)
   562	{
   563		struct console *c;
   564		const char *cp;
   565		int cookie;
   566		int len;
   567	
   568		if (msg_len == 0)
   569			return;
   570	
   571		cp = msg;
   572		len = msg_len;
   573	
   574		while (len--) {
   575			dbg_io_ops->write_char(*cp);
   576			cp++;
   577		}
   578	
   579		/*
   580		 * The console_srcu_read_lock() only provides safe console list
   581		 * traversal. The use of the ->write() callback relies on all other
   582		 * CPUs being stopped at the moment and console drivers being able to
   583		 * handle reentrance when @oops_in_progress is set.
   584		 *
   585		 * There is no guarantee that every console driver can handle
   586		 * reentrance in this way; the developer deploying the debugger
   587		 * is responsible for ensuring that the console drivers they
   588		 * have selected handle reentrance appropriately.
   589		 */
   590		cookie = console_srcu_read_lock();
   591		for_each_console_srcu(c) {
   592			short flags = console_srcu_read_flags(c);
   593	
   594			if (!console_is_usable(c, flags, true))
   595				continue;
   596			if (c == dbg_io_ops->cons)
   597				continue;
   598	
   599			if (flags & CON_NBCON) {
   600				struct nbcon_write_context wctxt = { };
   601	
   602				/*
   603				 * Do not continue if the console is NBCON and the context
   604				 * can't be acquired.
   605				 */
   606				if (!nbcon_kdb_try_acquire(c, &wctxt))
   607					continue;
   608	
   609				nbcon_write_context_set_buf(&wctxt, (char *)msg, msg_len);
   610	
   611				c->write_atomic(c, &wctxt);
 > 612				nbcon_kdb_release(&wctxt);
   613			} else {
   614				/*
   615				 * Set oops_in_progress to encourage the console drivers to
   616				 * disregard their internal spin locks: in the current calling
   617				 * context the risk of deadlock is a bigger problem than risks
   618				 * due to re-entering the console driver. We operate directly on
   619				 * oops_in_progress rather than using bust_spinlocks() because
   620				 * the calls bust_spinlocks() makes on exit are not appropriate
   621				 * for this calling context.
   622				 */
   623				++oops_in_progress;
   624				c->write(c, msg, msg_len);
   625				--oops_in_progress;
   626			}
   627			touch_nmi_watchdog();
   628		}
   629		console_srcu_read_unlock(cookie);
   630	}
   631	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context
  2025-10-17  1:25   ` kernel test robot
@ 2025-10-17  9:19     ` Petr Mladek
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Mladek @ 2025-10-17  9:19 UTC (permalink / raw)
  To: kernel test robot
  Cc: Marcos Paulo de Souza, Greg Kroah-Hartman, Steven Rostedt,
	John Ogness, Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, oe-kbuild-all, linux-kernel, kgdb-bugreport

On Fri 2025-10-17 09:25:53, kernel test robot wrote:
> Hi Marcos,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on 3a8660878839faadb4f1a6dd72c3179c1df56787]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-nbcon-Export-console_is_usable/20251016-225503
> base:   3a8660878839faadb4f1a6dd72c3179c1df56787
> patch link:    https://lore.kernel.org/r/20251016-nbcon-kgdboc-v6-3-866aac60a80e%40suse.com
> patch subject: [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context
> config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20251017/202510170949.NTx9lt0p-lkp@intel.com/config)
> compiler: or1k-linux-gcc (GCC) 15.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251017/202510170949.NTx9lt0p-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202510170949.NTx9lt0p-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from kernel/kallsyms.c:19:
>    include/linux/kdb.h: In function 'kdb_printf_on_this_cpu':
> >> include/linux/kdb.h:229:63: error: expected ';' before '}' token
>      229 | static inline bool kdb_printf_on_this_cpu(void) { return false };

Great catch! This should be:

	static inline bool kdb_printf_on_this_cpu(void) { return false; }

No need for v7. I could fix it when commtting the change.

BTW: It is interesting that the robot was so quick this time but
     it did not catch it in the earlier versions of the patchset.
     Maybe the robot had a summer vacation as well ;-)

     I am just joking. I know that any resources are limited and
     could not test everything. It is great to have the robot around.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context
  2025-10-16 14:47 ` [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context Marcos Paulo de Souza
  2025-10-17  1:25   ` kernel test robot
@ 2025-10-17  9:22   ` Petr Mladek
  1 sibling, 0 replies; 16+ messages in thread
From: Petr Mladek @ 2025-10-17  9:22 UTC (permalink / raw)
  To: Marcos Paulo de Souza
  Cc: Greg Kroah-Hartman, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, linux-kernel, kgdb-bugreport

On Thu 2025-10-16 11:47:56, Marcos Paulo de Souza wrote:
> KDB can interrupt any console to execute the "mirrored printing" at any
> time, so add an exception to nbcon_context_try_acquire_direct to allow
> to get the context if the current CPU is the same as kdb_printf_cpu.
> 
> This change will be necessary for the next patch, which fixes
> kdb_msg_write to work with NBCON consoles by calling ->write_atomic on
> such consoles. But to print it first needs to acquire the ownership of
> the console, so nbcon_context_try_acquire_direct is fixed here.
> 
> @@ -207,11 +208,26 @@ static inline const char *kdb_walk_kallsyms(loff_t *pos)
>  /* Dynamic kdb shell command registration */
>  extern int kdb_register(kdbtab_t *cmd);
>  extern void kdb_unregister(kdbtab_t *cmd);
> +
> +/* Return true when KDB as locked for printing a message on this CPU. */
> +static inline
> +bool kdb_printf_on_this_cpu(void)
> +{
> +	/*
> +	 * We can use raw_smp_processor_id() here because the task could
> +	 * not get migrated when KDB has locked for printing on this CPU.
> +	 */
> +	return unlikely(READ_ONCE(kdb_printf_cpu) == raw_smp_processor_id());
> +}
> +
>  #else /* ! CONFIG_KGDB_KDB */
>  static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
>  static inline void kdb_init(int level) {}
>  static inline int kdb_register(kdbtab_t *cmd) { return 0; }
>  static inline void kdb_unregister(kdbtab_t *cmd) {}
> +
> +static inline bool kdb_printf_on_this_cpu(void) { return false };

As the robot pointed out, this should be:

   static inline bool kdb_printf_on_this_cpu(void) { return false; }

> +
>  #endif	/* CONFIG_KGDB_KDB */
>  enum {
>  	KDB_NOT_INITIALIZED,

The rest looks good. With the above change:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
  2025-10-17  2:17   ` kernel test robot
@ 2025-10-17 10:12     ` Petr Mladek
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Mladek @ 2025-10-17 10:12 UTC (permalink / raw)
  To: kernel test robot
  Cc: Marcos Paulo de Souza, Greg Kroah-Hartman, Steven Rostedt,
	John Ogness, Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, llvm, oe-kbuild-all, linux-kernel,
	kgdb-bugreport

On Fri 2025-10-17 10:17:37, kernel test robot wrote:
> Hi Marcos,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on 3a8660878839faadb4f1a6dd72c3179c1df56787]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Marcos-Paulo-de-Souza/printk-nbcon-Export-console_is_usable/20251016-225503
> base:   3a8660878839faadb4f1a6dd72c3179c1df56787
> patch link:    https://lore.kernel.org/r/20251016-nbcon-kgdboc-v6-5-866aac60a80e%40suse.com
> patch subject: [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
> config: i386-buildonly-randconfig-006-20251017 (https://download.01.org/0day-ci/archive/20251017/202510171023.YREXxhMK-lkp@intel.com/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251017/202510171023.YREXxhMK-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202510171023.YREXxhMK-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
> >> kernel/debug/kdb/kdb_io.c:612:22: error: incompatible pointer types passing 'struct nbcon_write_context *' to parameter of type 'struct console *' [-Werror,-Wincompatible-pointer-types]
>      612 |                         nbcon_kdb_release(&wctxt);
>          |                                           ^~~~~~
>    include/linux/console.h:667:54: note: passing argument to parameter 'con' here
>      667 | static inline void nbcon_kdb_release(struct console *con) { }

This should be:

static inline void nbcon_kdb_release(struct nbcon_write_context *wctxt) { }

Again, no need for v7. I could fix this when committing the patch.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 2/5] printk: nbcon: Introduce KDB helpers
  2025-10-16 14:47 ` [PATCH v6 2/5] printk: nbcon: Introduce KDB helpers Marcos Paulo de Souza
@ 2025-10-17 10:16   ` Petr Mladek
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Mladek @ 2025-10-17 10:16 UTC (permalink / raw)
  To: Marcos Paulo de Souza
  Cc: Greg Kroah-Hartman, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, linux-kernel, kgdb-bugreport

On Thu 2025-10-16 11:47:55, Marcos Paulo de Souza wrote:
> These helpers will be used when calling console->write_atomic on
> KDB code in the next patch. It's basically the same implementation
> as nbcon_device_try_acquire, but using NBCON_PRIO_EMERGENCY when
> acquiring the context.
> 
> If the acquire succeeds, the message and message length are assigned to
> nbcon_write_context so ->write_atomic can print the message.
> 
> After release try to flush the console since there may be a backlog of
> messages in the ringbuffer. The kthread console printers do not get a
> chance to run while kdb is active.
> 
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -606,6 +606,9 @@ extern bool nbcon_can_proceed(struct nbcon_write_context *wctxt);
>  extern bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt);
>  extern bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt);
>  extern void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt);
> +extern bool nbcon_kdb_try_acquire(struct console *con,
> +				  struct nbcon_write_context *wctxt);
> +extern void nbcon_kdb_release(struct nbcon_write_context *wctxt);
>  
>  /*
>   * Check if the given console is currently capable and allowed to print
> @@ -655,6 +658,9 @@ static inline bool nbcon_can_proceed(struct nbcon_write_context *wctxt) { return
>  static inline bool nbcon_enter_unsafe(struct nbcon_write_context *wctxt) { return false; }
>  static inline bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt) { return false; }
>  static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { }
> +static inline bool nbcon_kdb_try_acquire(struct console *con,
> +					 struct nbcon_write_context *wctxt) { return false; }
> +static inline void nbcon_kdb_release(struct console *con) { }

A test robot found that this definition is using a wrong type,
see https://lore.kernel.org/all/202510171023.YREXxhMK-lkp@intel.com/

It should be:

static inline void nbcon_kdb_release(struct nbcon_write_context *wctxt) { }

No need for v7. I am going to fix this when committing the patchset.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 0/5] Handle NBCON consoles on KDB
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
                   ` (4 preceding siblings ...)
  2025-10-16 14:47 ` [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles Marcos Paulo de Souza
@ 2025-10-17 11:34 ` Petr Mladek
  2025-10-17 12:12   ` Marcos Paulo de Souza
  2025-10-24 11:52 ` Petr Mladek
  6 siblings, 1 reply; 16+ messages in thread
From: Petr Mladek @ 2025-10-17 11:34 UTC (permalink / raw)
  To: Marcos Paulo de Souza
  Cc: Greg Kroah-Hartman, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, linux-kernel, kgdb-bugreport

On Thu 2025-10-16 11:47:53, Marcos Paulo de Souza wrote:
> In v6 the patches were rebased on top of v6.18-rc1, added Reviewed-by tags from
> John and did some small changes suggested by him as well.
> 
> As usual, how I tested the changes:
> 
> Testing
> -------
> 
> I did the tests using qemu and reapplying commit f79b163c4231
> ('Revert "serial: 8250: Switch to nbcon console"') created originally by
> John, just to exercise the common 8250 serial from qemu. The commit can
> be checked on [1]. I had to solve some conflicts since the code has been
> reworked after the commit was reverted.
> 
> Then I would create three different serial entries on qemu:
> -serial mon:stdio -serial pty -serial pty
> 
> And for the kernel command line I added:
> earlyprintk=serial,ttyS2 console=ttyS2 console=ttyS1 console=ttyS1 kgdboc=ttyS1,115200
> 
> Without the last patch on this patchset, when KDB is triggered, the mirroring
> only worked on the earlyprintk console, since it's using the legacy console.
> 
> With the last patch applied, KDB mirroring works on legacy and nbcon
> console. For debugging I added some messages to be printed by KDB, showing
> also the console->name and console->index, and I was able to see both
> ->write and ->write_atomic being called, and it all working together.
> 
> [1]: https://github.com/marcosps/linux/commit/618bd49f8533db85d9c322f9ad1cb0da22aca9ee
> [2]: https://lore.kernel.org/lkml/20250825022947.1596226-1-wangjinchao600@gmail.com/
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> Changes in v6:
> - Rebased on top opf v6.18-rc1
> - Changed some includes, as suggedted by John
> - Reworked comments as suggested by John
> 
> Changes in v5:
> - Added review tags from Petr
> - Changes the way we detect if a CPU is running KDB.
> - Link to v4: https://lore.kernel.org/r/20250915-nbcon-kgdboc-v4-0-e2b6753bb566@suse.com
> 
> Changes in v4:
> - Added ifdefs to only check for KGDB if KGDB was enabled, suggested by John Ogness
> - Updated comments about KDB on acquire_direct, suggested by Petr and John
> - Added a new patch to export nbcon_write_context_set_buf, suggested by Petr and John
> - Link to v3: https://lore.kernel.org/r/20250902-nbcon-kgdboc-v3-0-cd30a8106f1c@suse.com
> 
> Changes in v3:
> - Only call nbcon_context_release if nbcon_context_exit_unsafe returns true (John Ogness)
> - Dropped the prototype of console_is_usable from kernel/printk/internal. (Petr Mladek)
> - Add comments to the new functions introduced (Petr Mladek)
> - Flush KDB console on nbcon_kdb_release (Petr Mladek)
> - Add an exception for KDB on nbcon_context_try_acquire_direct (John Ogness and Petr Mladek)
> - Link to v2: https://lore.kernel.org/r/20250811-nbcon-kgdboc-v2-0-c7c72bcdeaf6@suse.com
> 
> Changes in v2:
> - Set by mistake ..
> - Link to v1: https://lore.kernel.org/r/20250713-nbcon-kgdboc-v1-0-51eccd9247a8@suse.com
> 
> ---
> Marcos Paulo de Souza (5):
>       printk: nbcon: Export console_is_usable
>       printk: nbcon: Introduce KDB helpers
>       printk: nbcon: Allow KDB to acquire the NBCON context
>       printk: nbcon: Export nbcon_write_context_set_buf
>       kdb: Adapt kdb_msg_write to work with NBCON consoles
> 
>  include/linux/console.h   | 55 ++++++++++++++++++++++++++++++++++++
>  include/linux/kdb.h       | 16 +++++++++++
>  kernel/debug/kdb/kdb_io.c | 47 +++++++++++++++++++++----------
>  kernel/printk/internal.h  | 45 ------------------------------
>  kernel/printk/nbcon.c     | 71 +++++++++++++++++++++++++++++++++++++++++++++--
>  5 files changed, 171 insertions(+), 63 deletions(-)

With the two below compilation fixes, the series seems to be ready for
linux-next.

I am going to wait with pushing a week or so to give other printk and
kdb maintainers and reviewers a chance to look at it.

The following two changes are needed to fix build with
CONFIG_PRINTK and/or CONFIG_KGDB_KDB disabled. I am going
to do the in the respective patches when committing:

diff --git a/include/linux/console.h b/include/linux/console.h
index 81d2c247c01f..690a5f698a5c 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -664,7 +664,7 @@ static inline bool nbcon_exit_unsafe(struct nbcon_write_context *wctxt) { return
 static inline void nbcon_reacquire_nobuf(struct nbcon_write_context *wctxt) { }
 static inline bool nbcon_kdb_try_acquire(struct console *con,
 					 struct nbcon_write_context *wctxt) { return false; }
-static inline void nbcon_kdb_release(struct console *con) { }
+static inline void nbcon_kdb_release(struct nbcon_write_context *wctxt) { }
 static inline bool console_is_usable(struct console *con, short flags,
 				     bool use_atomic) { return false; }
 #endif
diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index db9d73b12a1a..741c58e86431 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -226,7 +226,7 @@ static inline void kdb_init(int level) {}
 static inline int kdb_register(kdbtab_t *cmd) { return 0; }
 static inline void kdb_unregister(kdbtab_t *cmd) {}
 
-static inline bool kdb_printf_on_this_cpu(void) { return false };
+static inline bool kdb_printf_on_this_cpu(void) { return false; }
 
 #endif	/* CONFIG_KGDB_KDB */
 enum {


Best Regards,
Petr




> ---
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> change-id: 20250713-nbcon-kgdboc-efcfc37fde46
> 
> Best regards,
> --  
> Marcos Paulo de Souza <mpdesouza@suse.com>

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 0/5] Handle NBCON consoles on KDB
  2025-10-17 11:34 ` [PATCH v6 0/5] Handle NBCON consoles on KDB Petr Mladek
@ 2025-10-17 12:12   ` Marcos Paulo de Souza
  0 siblings, 0 replies; 16+ messages in thread
From: Marcos Paulo de Souza @ 2025-10-17 12:12 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Greg Kroah-Hartman, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, linux-kernel, kgdb-bugreport

On Fri, 2025-10-17 at 13:34 +0200, Petr Mladek wrote:
> On Thu 2025-10-16 11:47:53, Marcos Paulo de Souza wrote:
> > In v6 the patches were rebased on top of v6.18-rc1, added Reviewed-
> > by tags from
> > John and did some small changes suggested by him as well.
> > 
> > As usual, how I tested the changes:
> > 
> > Testing
> > -------
> > 
> > I did the tests using qemu and reapplying commit f79b163c4231
> > ('Revert "serial: 8250: Switch to nbcon console"') created
> > originally by
> > John, just to exercise the common 8250 serial from qemu. The commit
> > can
> > be checked on [1]. I had to solve some conflicts since the code has
> > been
> > reworked after the commit was reverted.
> > 
> > Then I would create three different serial entries on qemu:
> > -serial mon:stdio -serial pty -serial pty
> > 
> > And for the kernel command line I added:
> > earlyprintk=serial,ttyS2 console=ttyS2 console=ttyS1 console=ttyS1
> > kgdboc=ttyS1,115200
> > 
> > Without the last patch on this patchset, when KDB is triggered, the
> > mirroring
> > only worked on the earlyprintk console, since it's using the legacy
> > console.
> > 
> > With the last patch applied, KDB mirroring works on legacy and
> > nbcon
> > console. For debugging I added some messages to be printed by KDB,
> > showing
> > also the console->name and console->index, and I was able to see
> > both
> > ->write and ->write_atomic being called, and it all working
> > together.
> > 
> > [1]:
> > https://github.com/marcosps/linux/commit/618bd49f8533db85d9c322f9ad1cb0da22aca9ee
> > [2]:
> > https://lore.kernel.org/lkml/20250825022947.1596226-1-wangjinchao600@gmail.com/
> > 
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > ---
> > Changes in v6:
> > - Rebased on top opf v6.18-rc1
> > - Changed some includes, as suggedted by John
> > - Reworked comments as suggested by John
> > 
> > Changes in v5:
> > - Added review tags from Petr
> > - Changes the way we detect if a CPU is running KDB.
> > - Link to v4:
> > https://lore.kernel.org/r/20250915-nbcon-kgdboc-v4-0-e2b6753bb566@suse.com
> > 
> > Changes in v4:
> > - Added ifdefs to only check for KGDB if KGDB was enabled,
> > suggested by John Ogness
> > - Updated comments about KDB on acquire_direct, suggested by Petr
> > and John
> > - Added a new patch to export nbcon_write_context_set_buf,
> > suggested by Petr and John
> > - Link to v3:
> > https://lore.kernel.org/r/20250902-nbcon-kgdboc-v3-0-cd30a8106f1c@suse.com
> > 
> > Changes in v3:
> > - Only call nbcon_context_release if nbcon_context_exit_unsafe
> > returns true (John Ogness)
> > - Dropped the prototype of console_is_usable from
> > kernel/printk/internal. (Petr Mladek)
> > - Add comments to the new functions introduced (Petr Mladek)
> > - Flush KDB console on nbcon_kdb_release (Petr Mladek)
> > - Add an exception for KDB on nbcon_context_try_acquire_direct
> > (John Ogness and Petr Mladek)
> > - Link to v2:
> > https://lore.kernel.org/r/20250811-nbcon-kgdboc-v2-0-c7c72bcdeaf6@suse.com
> > 
> > Changes in v2:
> > - Set by mistake ..
> > - Link to v1:
> > https://lore.kernel.org/r/20250713-nbcon-kgdboc-v1-0-51eccd9247a8@suse.com
> > 
> > ---
> > Marcos Paulo de Souza (5):
> >       printk: nbcon: Export console_is_usable
> >       printk: nbcon: Introduce KDB helpers
> >       printk: nbcon: Allow KDB to acquire the NBCON context
> >       printk: nbcon: Export nbcon_write_context_set_buf
> >       kdb: Adapt kdb_msg_write to work with NBCON consoles
> > 
> >  include/linux/console.h   | 55
> > ++++++++++++++++++++++++++++++++++++
> >  include/linux/kdb.h       | 16 +++++++++++
> >  kernel/debug/kdb/kdb_io.c | 47 +++++++++++++++++++++----------
> >  kernel/printk/internal.h  | 45 ------------------------------
> >  kernel/printk/nbcon.c     | 71
> > +++++++++++++++++++++++++++++++++++++++++++++--
> >  5 files changed, 171 insertions(+), 63 deletions(-)
> 
> With the two below compilation fixes, the series seems to be ready
> for
> linux-next.
> 
> I am going to wait with pushing a week or so to give other printk and
> kdb maintainers and reviewers a chance to look at it.
> 
> The following two changes are needed to fix build with
> CONFIG_PRINTK and/or CONFIG_KGDB_KDB disabled. I am going
> to do the in the respective patches when committing:
> 
> diff --git a/include/linux/console.h b/include/linux/console.h
> index 81d2c247c01f..690a5f698a5c 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -664,7 +664,7 @@ static inline bool nbcon_exit_unsafe(struct
> nbcon_write_context *wctxt) { return
>  static inline void nbcon_reacquire_nobuf(struct nbcon_write_context
> *wctxt) { }
>  static inline bool nbcon_kdb_try_acquire(struct console *con,
>  					 struct nbcon_write_context
> *wctxt) { return false; }
> -static inline void nbcon_kdb_release(struct console *con) { }
> +static inline void nbcon_kdb_release(struct nbcon_write_context
> *wctxt) { }
>  static inline bool console_is_usable(struct console *con, short
> flags,
>  				     bool use_atomic) { return
> false; }
>  #endif
> diff --git a/include/linux/kdb.h b/include/linux/kdb.h
> index db9d73b12a1a..741c58e86431 100644
> --- a/include/linux/kdb.h
> +++ b/include/linux/kdb.h
> @@ -226,7 +226,7 @@ static inline void kdb_init(int level) {}
>  static inline int kdb_register(kdbtab_t *cmd) { return 0; }
>  static inline void kdb_unregister(kdbtab_t *cmd) {}
>  
> -static inline bool kdb_printf_on_this_cpu(void) { return false };
> +static inline bool kdb_printf_on_this_cpu(void) { return false; }
>  
>  #endif	/* CONFIG_KGDB_KDB */
>  enum {
> 
> 

Ouch... thanks a lot Petr for fixing my mistakes here. I should have
disabled the configs to double check these counterparts.

> Best Regards,
> Petr
> 
> 
> 
> 
> > ---
> > base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> > change-id: 20250713-nbcon-kgdboc-efcfc37fde46
> > 
> > Best regards,
> > --  
> > Marcos Paulo de Souza <mpdesouza@suse.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v6 0/5] Handle NBCON consoles on KDB
  2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
                   ` (5 preceding siblings ...)
  2025-10-17 11:34 ` [PATCH v6 0/5] Handle NBCON consoles on KDB Petr Mladek
@ 2025-10-24 11:52 ` Petr Mladek
  6 siblings, 0 replies; 16+ messages in thread
From: Petr Mladek @ 2025-10-24 11:52 UTC (permalink / raw)
  To: Marcos Paulo de Souza
  Cc: Greg Kroah-Hartman, Steven Rostedt, John Ogness,
	Sergey Senozhatsky, Jason Wessel, Daniel Thompson,
	Douglas Anderson, linux-kernel, kgdb-bugreport

On Thu 2025-10-16 11:47:53, Marcos Paulo de Souza wrote:
> In v6 the patches were rebased on top of v6.18-rc1, added Reviewed-by tags from
> John and did some small changes suggested by him as well.
> 
> As usual, how I tested the changes:
> 
> Testing
> -------
> 
> I did the tests using qemu and reapplying commit f79b163c4231
> ('Revert "serial: 8250: Switch to nbcon console"') created originally by
> John, just to exercise the common 8250 serial from qemu. The commit can
> be checked on [1]. I had to solve some conflicts since the code has been
> reworked after the commit was reverted.
> 
> Then I would create three different serial entries on qemu:
> -serial mon:stdio -serial pty -serial pty
> 
> And for the kernel command line I added:
> earlyprintk=serial,ttyS2 console=ttyS2 console=ttyS1 console=ttyS1 kgdboc=ttyS1,115200
> 
> Without the last patch on this patchset, when KDB is triggered, the mirroring
> only worked on the earlyprintk console, since it's using the legacy console.
> 
> With the last patch applied, KDB mirroring works on legacy and nbcon
> console. For debugging I added some messages to be printed by KDB, showing
> also the console->name and console->index, and I was able to see both
> ->write and ->write_atomic being called, and it all working together.
> 
> [1]: https://github.com/marcosps/linux/commit/618bd49f8533db85d9c322f9ad1cb0da22aca9ee
> [2]: https://lore.kernel.org/lkml/20250825022947.1596226-1-wangjinchao600@gmail.com/
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> Changes in v6:
> - Rebased on top opf v6.18-rc1
> - Changed some includes, as suggedted by John
> - Reworked comments as suggested by John

> Marcos Paulo de Souza (5):
>       printk: nbcon: Export console_is_usable
>       printk: nbcon: Introduce KDB helpers
>       printk: nbcon: Allow KDB to acquire the NBCON context
>       printk: nbcon: Export nbcon_write_context_set_buf
>       kdb: Adapt kdb_msg_write to work with NBCON consoles
> 
>  include/linux/console.h   | 55 ++++++++++++++++++++++++++++++++++++
>  include/linux/kdb.h       | 16 +++++++++++
>  kernel/debug/kdb/kdb_io.c | 47 +++++++++++++++++++++----------
>  kernel/printk/internal.h  | 45 ------------------------------
>  kernel/printk/nbcon.c     | 71 +++++++++++++++++++++++++++++++++++++++++++++--
>  5 files changed, 171 insertions(+), 63 deletions(-)

JFYI, the patchset has been committed into printk/linux.git,
branch rework/nbcon-in-kdb.

Note: As promised, I have fixed the two compilation problems reported
      by the robots when committing.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-10-24 11:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 14:47 [PATCH v6 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
2025-10-16 14:47 ` [PATCH v6 1/5] printk: nbcon: Export console_is_usable Marcos Paulo de Souza
2025-10-16 14:47 ` [PATCH v6 2/5] printk: nbcon: Introduce KDB helpers Marcos Paulo de Souza
2025-10-17 10:16   ` Petr Mladek
2025-10-16 14:47 ` [PATCH v6 3/5] printk: nbcon: Allow KDB to acquire the NBCON context Marcos Paulo de Souza
2025-10-17  1:25   ` kernel test robot
2025-10-17  9:19     ` Petr Mladek
2025-10-17  9:22   ` Petr Mladek
2025-10-16 14:47 ` [PATCH v6 4/5] printk: nbcon: Export nbcon_write_context_set_buf Marcos Paulo de Souza
2025-10-16 14:47 ` [PATCH v6 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles Marcos Paulo de Souza
2025-10-17  2:17   ` kernel test robot
2025-10-17 10:12     ` Petr Mladek
2025-10-17  7:14   ` kernel test robot
2025-10-17 11:34 ` [PATCH v6 0/5] Handle NBCON consoles on KDB Petr Mladek
2025-10-17 12:12   ` Marcos Paulo de Souza
2025-10-24 11:52 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox