From: Marcos Paulo de Souza <mpdesouza@suse.com>
To: Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Jason Wessel <jason.wessel@windriver.com>,
Daniel Thompson <danielt@kernel.org>,
Douglas Anderson <dianders@chromium.org>,
Richard Weinberger <richard@nod.at>,
Anton Ivanov <anton.ivanov@cambridgegreys.com>,
Johannes Berg <johannes@sipsolutions.net>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
kgdb-bugreport@lists.sourceforge.net,
linux-um@lists.infradead.org,
Marcos Paulo de Souza <mpdesouza@suse.com>
Subject: [PATCH v2 4/4] printk: Make console_{suspend,resume} handle CON_SUSPENDED
Date: Fri, 21 Nov 2025 15:50:36 -0300 [thread overview]
Message-ID: <20251121-printk-cleanup-part2-v2-4-57b8b78647f4@suse.com> (raw)
In-Reply-To: <20251121-printk-cleanup-part2-v2-0-57b8b78647f4@suse.com>
Since commit 9e70a5e109a4 ("printk: Add per-console suspended state")
the CON_SUSPENDED flag was introced, and this flag was being checked
on console_is_usable function, which returns false if the console is
suspended.
To make the behavior consistent, change show_cons_active to look for
consoles that are not suspended, instead of checking CON_ENABLED.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
drivers/tty/tty_io.c | 2 +-
kernel/printk/printk.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index e2d92cf70eb7..1b2ce0f36010 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3554,7 +3554,7 @@ static ssize_t show_cons_active(struct device *dev,
continue;
if (!(c->flags & CON_NBCON) && !c->write)
continue;
- if ((c->flags & CON_ENABLED) == 0)
+ if (c->flags & CON_SUSPENDED)
continue;
cs[i++] = c;
if (i >= ARRAY_SIZE(cs))
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fed98a18e830..fe7c956f73bd 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3542,7 +3542,7 @@ void console_suspend(struct console *console)
{
__pr_flush(console, 1000, true);
console_list_lock();
- console_srcu_write_flags(console, console->flags & ~CON_ENABLED);
+ console_srcu_write_flags(console, console->flags | CON_SUSPENDED);
console_list_unlock();
/*
@@ -3555,13 +3555,14 @@ void console_suspend(struct console *console)
}
EXPORT_SYMBOL(console_suspend);
+/* Unset CON_SUSPENDED flag so the console can start printing again. */
void console_resume(struct console *console)
{
struct console_flush_type ft;
bool is_nbcon;
console_list_lock();
- console_srcu_write_flags(console, console->flags | CON_ENABLED);
+ console_srcu_write_flags(console, console->flags & ~CON_SUSPENDED);
is_nbcon = console->flags & CON_NBCON;
console_list_unlock();
--
2.51.1
prev parent reply other threads:[~2025-11-21 18:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 18:50 [PATCH v2 0/4] printk cleanup - part 2 Marcos Paulo de Souza
2025-11-21 18:50 ` [PATCH v2 1/4] drivers: serial: kgdboc: Drop checks for CON_ENABLED and CON_BOOT Marcos Paulo de Souza
2025-11-21 18:50 ` [PATCH v2 2/4] arch: um: kmsg_dump: Use console_is_usable Marcos Paulo de Souza
2025-11-21 18:50 ` [PATCH v2 3/4] printk: Use console_is_usable on console_unblank Marcos Paulo de Souza
2025-11-21 18:50 ` Marcos Paulo de Souza [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251121-printk-cleanup-part2-v2-4-57b8b78647f4@suse.com \
--to=mpdesouza@suse.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=danielt@kernel.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jason.wessel@windriver.com \
--cc=jirislaby@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=john.ogness@linutronix.de \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=pmladek@suse.com \
--cc=richard@nod.at \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).