diff options
author | John Ogness <john.ogness@linutronix.de> | 2022-11-16 17:21:21 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2022-12-02 11:25:00 +0100 |
commit | d25a2e748ae159e43d40f4bc0a9e89cc443e325f (patch) | |
tree | c04c03454c3c78eea0a2240123552acb437ddc1f /drivers/tty | |
parent | tty: serial: kgdboc: document console_lock usage (diff) | |
download | linux-d25a2e748ae159e43d40f4bc0a9e89cc443e325f.tar.xz linux-d25a2e748ae159e43d40f4bc0a9e89cc443e325f.zip |
tty: tty_io: document console_lock usage
show_cons_active() uses the console_lock to gather information
on registered consoles. Since the console_lock is being used for
multiple reasons, explicitly document these reasons. This will
be useful when the console_lock is split into fine-grained
locking.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20221116162152.193147-10-john.ogness@linutronix.de
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_io.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index de06c3c2ff70..ee4da2fec328 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3526,6 +3526,16 @@ static ssize_t show_cons_active(struct device *dev, struct console *c; ssize_t count = 0; + /* + * Hold the console_lock to guarantee that no consoles are + * unregistered until all console processing is complete. + * This also allows safe traversal of the console list and + * race-free reading of @flags. + * + * Take console_lock to serialize device() callback with + * other console operations. For example, fg_console is + * modified under console_lock when switching vt. + */ console_lock(); for_each_console(c) { if (!c->device) |