mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH printk v2 0/2] nbcon irq_work fixes
@ 2026-08-28 14:02 John Ogness
  2026-08-28 14:02 ` [PATCH printk v2 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: John Ogness @ 2026-08-28 14:02 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner

Hi,

This is v2 of a series to address some irq_work issues with nbcon.
Initially motivated as a workaround for hardware-related regressions
reported [0], it turns out that the workaround is actually a nice
improvement for nbcon deferred printing in general.

v1 is here [1].

John Ogness

The changes since v1:

- Add a preceding patch to flush the irq_work on nbcon_free(). This
  pre-existing issue was reported [2] by Sashiko while it was
  reviewing v1.

[0] https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
[1] https://lore.kernel.org/lkml/20260827184750.203521-1-john.ogness@linutronix.de
[2] https://sashiko.dev/#/patchset/20260827184750.203521-1-john.ogness%40linutronix.de

John Ogness (2):
  printk/nbcon: Flush nbcon_irq_work in nbcon_free()
  printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY

 kernel/printk/nbcon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


base-commit: ffe0486b139e45cd9c9ca2584f04a1910fe4f8a6
-- 
2.47.3


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

* [PATCH printk v2 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free()
  2026-08-28 14:02 [PATCH printk v2 0/2] nbcon irq_work fixes John Ogness
@ 2026-08-28 14:02 ` John Ogness
  2026-08-28 14:02 ` [PATCH printk v2 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: John Ogness @ 2026-08-28 14:02 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel

Ensure any pending nbcon_irq_work is flushed before allowing the
console to be recycled.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/printk/nbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index a5921a84a80ed..218b1922a58de 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1849,6 +1849,8 @@ void nbcon_free(struct console *con)
 			printk_kthreads_running = false;
 	}
 
+	irq_work_sync(&con->irq_work);
+
 	nbcon_state_set(con, &state);
 
 	/* Boot consoles share global printk buffers. */
-- 
2.47.3


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

* [PATCH printk v2 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY
  2026-08-28 14:02 [PATCH printk v2 0/2] nbcon irq_work fixes John Ogness
  2026-08-28 14:02 ` [PATCH printk v2 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
@ 2026-08-28 14:02 ` John Ogness
  2026-08-28 15:36 ` [PATCH printk v2 0/2] nbcon irq_work fixes Jon Hunter
  2026-08-28 23:39 ` Bradley Morgan
  3 siblings, 0 replies; 5+ messages in thread
From: John Ogness @ 2026-08-28 14:02 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Jon Hunter, Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner

For some platforms it is a problem to queue irq_work when entering
cpuidle states. Since nbcon uses irq_work for waking the printing
kthreads, any printk() calls when entering cpuidle states can lead
to the affected hardware hanging. Tegra20 and Tegra30 are examples
of such platforms. Avoiding raising the irq_work IRQ has shown to
circumvent the problem.

Change the nbcon_irq_work to be IRQ_WORK_LAZY, thus not raising
an IRQ upon irq_work queuing. The irq_work is then handled on the
next interrupt (worst case, kernel tick). This additional delay is
acceptable because nbcon_irq_work is only responsible for
non-emergency deferred printing, which is delayed anyway. This also
has the benefit of not needing to raise an IRQ for each printk()
call.

Link: https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
 kernel/printk/nbcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 218b1922a58de..e5aede99304ed 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1782,7 +1782,7 @@ bool nbcon_alloc(struct console *con)
 	}
 
 	rcuwait_init(&con->rcuwait);
-	init_irq_work(&con->irq_work, nbcon_irq_work);
+	con->irq_work = IRQ_WORK_INIT_LAZY(nbcon_irq_work);
 	atomic_long_set(&ACCESS_PRIVATE(con, nbcon_prev_seq), -1UL);
 	nbcon_state_set(con, &state);
 
-- 
2.47.3


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

* Re: [PATCH printk v2 0/2] nbcon irq_work fixes
  2026-08-28 14:02 [PATCH printk v2 0/2] nbcon irq_work fixes John Ogness
  2026-08-28 14:02 ` [PATCH printk v2 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
  2026-08-28 14:02 ` [PATCH printk v2 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
@ 2026-08-28 15:36 ` Jon Hunter
  2026-08-28 23:39 ` Bradley Morgan
  3 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2026-08-28 15:36 UTC (permalink / raw)
  To: John Ogness, Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Sebastian Andrzej Siewior,
	Thierry Reding, Greg Kroah-Hartman, linux-kernel,
	Thomas Gleixner, linux-tegra

Hi John,

On 28/08/2026 15:02, John Ogness wrote:
> Hi,
> 
> This is v2 of a series to address some irq_work issues with nbcon.
> Initially motivated as a workaround for hardware-related regressions
> reported [0], it turns out that the workaround is actually a nice
> improvement for nbcon deferred printing in general.
> 
> v1 is here [1].
> 
> John Ogness
> 
> The changes since v1:
> 
> - Add a preceding patch to flush the irq_work on nbcon_free(). This
>    pre-existing issue was reported [2] by Sashiko while it was
>    reviewing v1.
> 
> [0] https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
> [1] https://lore.kernel.org/lkml/20260827184750.203521-1-john.ogness@linutronix.de
> [2] https://sashiko.dev/#/patchset/20260827184750.203521-1-john.ogness%40linutronix.de
> 
> John Ogness (2):
>    printk/nbcon: Flush nbcon_irq_work in nbcon_free()
>    printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY
> 
>   kernel/printk/nbcon.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

I have tested these on Tegra and all is working well, so for
the series ...

Tested-by: Jon Hunter <jonathanh@nvidia.com>

Thanks for fixing this!

Cheers
Jon

-- 
nvpublic


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

* Re: [PATCH printk v2 0/2] nbcon irq_work fixes
  2026-08-28 14:02 [PATCH printk v2 0/2] nbcon irq_work fixes John Ogness
                   ` (2 preceding siblings ...)
  2026-08-28 15:36 ` [PATCH printk v2 0/2] nbcon irq_work fixes Jon Hunter
@ 2026-08-28 23:39 ` Bradley Morgan
  3 siblings, 0 replies; 5+ messages in thread
From: Bradley Morgan @ 2026-08-28 23:39 UTC (permalink / raw)
  To: john.ogness
  Cc: bigeasy, gregkh, jonathanh, linux-kernel, pmladek, rostedt,
	senozhatsky, tglx, thierry.reding

On 28 August 2026 15:02:07 BST, John Ogness <john.ogness@linutronix.de>
wrote:
>Hi,
>
>This is v2 of a series to address some irq_work issues with nbcon.
>Initially motivated as a workaround for hardware-related regressions
>reported [0], it turns out that the workaround is actually a nice
>improvement for nbcon deferred printing in general.
>
>v1 is here [1].
>
>John Ogness
>
>The changes since v1:
>
>- Add a preceding patch to flush the irq_work on nbcon_free(). This
>  pre-existing issue was reported [2] by Sashiko while it was
>  reviewing v1.
>
>[0]
>https://lore.kernel.org/lkml/f3757a75-0ba1-4558-bf57-f19ab7e59a4c@nvidia.com
>[1]
>https://lore.kernel.org/lkml/20260827184750.203521-1-john.ogness@linutronix.de
>[2]
>https://sashiko.dev/#/patchset/20260827184750.203521-1-john.ogness%40linutronix.de
>
>John Ogness (2):
>  printk/nbcon: Flush nbcon_irq_work in nbcon_free()
>  printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY
>
> kernel/printk/nbcon.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>
>base-commit: ffe0486b139e45cd9c9ca2584f04a1910fe4f8a6
>
Tested-by: Bradley Morgan <brads@mainlining.org> # PKVM, based on Pixel 7 (ARM64)



--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

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

end of thread, other threads:[~2026-08-28 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 14:02 [PATCH printk v2 0/2] nbcon irq_work fixes John Ogness
2026-08-28 14:02 ` [PATCH printk v2 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free() John Ogness
2026-08-28 14:02 ` [PATCH printk v2 2/2] printk/nbcon: Change nbcon_irq_work to IRQ_WORK_LAZY John Ogness
2026-08-28 15:36 ` [PATCH printk v2 0/2] nbcon irq_work fixes Jon Hunter
2026-08-28 23:39 ` Bradley Morgan

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

all inboxes | Powered by JetHome®