summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0006-printk-nbcon-Add-callbacks-to-synchronize-with-drive.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches-rt/0006-printk-nbcon-Add-callbacks-to-synchronize-with-drive.patch')
-rw-r--r--debian/patches-rt/0006-printk-nbcon-Add-callbacks-to-synchronize-with-drive.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/debian/patches-rt/0006-printk-nbcon-Add-callbacks-to-synchronize-with-drive.patch b/debian/patches-rt/0006-printk-nbcon-Add-callbacks-to-synchronize-with-drive.patch
new file mode 100644
index 0000000000..ef850cfd27
--- /dev/null
+++ b/debian/patches-rt/0006-printk-nbcon-Add-callbacks-to-synchronize-with-drive.patch
@@ -0,0 +1,85 @@
+From: John Ogness <john.ogness@linutronix.de>
+Date: Mon, 18 Mar 2024 10:11:56 +0000
+Subject: [PATCH 06/48] printk: nbcon: Add callbacks to synchronize with driver
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.10/older/patches-6.10.2-rt14.tar.xz
+
+Console drivers typically must deal with access to the hardware
+via user input/output (such as an interactive login shell) and
+output of kernel messages via printk() calls. To provide the
+necessary synchronization, usually some driver-specific locking
+mechanism is used (for example, the port spinlock for uart
+serial consoles).
+
+Until now, usage of this driver-specific locking has been hidden
+from the printk-subsystem and implemented within the various
+console callbacks. However, nbcon consoles would need to use it
+even in the generic code.
+
+Add device_lock() and device_unlock() callback which will need
+to get implemented by nbcon consoles.
+
+The callbacks will use whatever synchronization mechanism the
+driver is using for itself. The minimum requirement is to
+prevent CPU migration. It would allow a context friendly
+acquiring of nbcon console ownership in non-emergency and
+non-panic context.
+
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Reviewed-by: Petr Mladek <pmladek@suse.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/console.h | 43 +++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 43 insertions(+)
+
+--- a/include/linux/console.h
++++ b/include/linux/console.h
+@@ -372,6 +372,49 @@ struct console {
+ */
+ void (*write_atomic)(struct console *con, struct nbcon_write_context *wctxt);
+
++ /**
++ * @device_lock:
++ *
++ * NBCON callback to begin synchronization with driver code.
++ *
++ * Console drivers typically must deal with access to the hardware
++ * via user input/output (such as an interactive login shell) and
++ * output of kernel messages via printk() calls. This callback is
++ * called by the printk-subsystem whenever it needs to synchronize
++ * with hardware access by the driver. It should be implemented to
++ * use whatever synchronization mechanism the driver is using for
++ * itself (for example, the port lock for uart serial consoles).
++ *
++ * The callback is always called from task context. It may use any
++ * synchronization method required by the driver.
++ *
++ * IMPORTANT: The callback MUST disable migration. The console driver
++ * may be using a synchronization mechanism that already takes
++ * care of this (such as spinlocks). Otherwise this function must
++ * explicitly call migrate_disable().
++ *
++ * The flags argument is provided as a convenience to the driver. It
++ * will be passed again to device_unlock(). It can be ignored if the
++ * driver does not need it.
++ */
++ void (*device_lock)(struct console *con, unsigned long *flags);
++
++ /**
++ * @device_unlock:
++ *
++ * NBCON callback to finish synchronization with driver code.
++ *
++ * It is the counterpart to device_lock().
++ *
++ * This callback is always called from task context. It must
++ * appropriately re-enable migration (depending on how device_lock()
++ * disabled migration).
++ *
++ * The flags argument is the value of the same variable that was
++ * passed to device_lock().
++ */
++ void (*device_unlock)(struct console *con, unsigned long flags);
++
+ atomic_t __private nbcon_state;
+ atomic_long_t __private nbcon_seq;
+ struct printk_buffers *pbufs;