[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZdNGlzwqwdsfwwab@smile.fi.intel.com>
Date: Mon, 19 Feb 2024 14:16:23 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Tony Lindgren <tony@...mide.com>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Justin Chen <justin.chen@...adcom.com>,
Jiaqing Zhao <jiaqing.zhao@...ux.intel.com>,
linux-serial@...r.kernel.org
Subject: Re: [PATCH printk v2 08/26] printk: nbcon: Implement processing in
port->lock wrapper
On Sun, Feb 18, 2024 at 08:03:08PM +0106, John Ogness wrote:
> Currently the port->lock wrappers uart_port_lock(),
> uart_port_unlock() (and their variants) only lock/unlock
> the spin_lock.
>
> If the port is an nbcon console, the wrappers must also
> acquire/release the console and mark the region as unsafe. This
> allows general port->lock synchronization to be synchronized
> with the nbcon console ownership.
>
> Add a flag to struct uart_port to track nbcon console ownership.
..
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -6,6 +6,7 @@
> #include <linux/console.h>
> #include <linux/delay.h>
> #include <linux/slab.h>
> +#include <linux/serial_core.h>
The headers in this file is a mess. But here you can at least keep the piece
ordered, can you?
..
> +static inline bool uart_is_nbcon(struct uart_port *up)
> +{
> + int cookie;
> + bool ret;
> +
> + if (!uart_console(up))
> + return false;
> +
> + cookie = console_srcu_read_lock();
> + ret = (console_srcu_read_flags(up->cons) & CON_NBCON);
The outer parentheses are redundant.
> + console_srcu_read_unlock(cookie);
> + return ret;
> +}
..
> +void uart_nbcon_acquire(struct uart_port *up)
> +{
> + struct console *con = up->cons;
> + struct nbcon_context ctxt;
> +
> + if (!uart_is_nbcon(up))
> + return;
> + WARN_ON_ONCE(up->nbcon_locked_port);
+ include linux/bug.h
> + do {
> + do {
> + memset(&ctxt, 0, sizeof(ctxt));
+ include linux/string.h
> + ctxt.console = con;
> + ctxt.prio = NBCON_PRIO_NORMAL;
> + } while (!nbcon_context_try_acquire(&ctxt));
> +
> + } while (!nbcon_context_enter_unsafe(&ctxt));
> +
> + up->nbcon_locked_port = true;
> +}
> +EXPORT_SYMBOL_GPL(uart_nbcon_acquire);
+ include linux/export.h
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists