]> git.ipfire.org Git - thirdparty/linux.git/commit
nbcon: Add API to acquire context for non-printing operations
authorJohn Ogness <john.ogness@linutronix.de>
Tue, 20 Aug 2024 06:29:39 +0000 (08:35 +0206)
committerPetr Mladek <pmladek@suse.com>
Wed, 21 Aug 2024 12:56:23 +0000 (14:56 +0200)
commitadf6f37d142e14896115929f3892bbc0a86e25bf
treef9698bf96f2e0ae470cc8e822780517a6d9d08c9
parentdc219d8d858d95549543aa7a41b6e64a0da9e406
nbcon: Add API to acquire context for non-printing operations

Provide functions nbcon_device_try_acquire() and
nbcon_device_release() which will try to acquire the nbcon
console ownership with NBCON_PRIO_NORMAL and mark it unsafe for
handover/takeover.

These functions are to be used together with the device-specific
locking when performing non-printing activities on the console
device. They will allow synchronization against the
atomic_write() callback which will be serialized, for higher
priority contexts, only by acquiring the console context
ownership.

Pitfalls:

The API requires to be called in a context with migration
disabled because it uses per-CPU variables internally.

The context is set unsafe for a takeover all the time. It
guarantees full serialization against any atomic_write() caller
except for the final flush in panic() which might try an unsafe
takeover.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20240820063001.36405-14-john.ogness@linutronix.de
Signed-off-by: Petr Mladek <pmladek@suse.com>
include/linux/console.h
include/linux/printk.h
kernel/printk/nbcon.c