All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Ogness <john.ogness@linutronix.de>
To: Lukas Wunner <lukas@wunner.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>,
	Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH tty-linus] serial: Reduce spinlocked portion of uart_rs485_config()
Date: Thu, 21 Sep 2023 17:24:04 +0206	[thread overview]
Message-ID: <87zg1fees3.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <f3a35967c28b32f3c6432d0aa5936e6a9908282d.1695307688.git.lukas@wunner.de>

On 2023-09-21, Lukas Wunner <lukas@wunner.de> wrote:
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 7bdc21d5e13b..ca26a8aef2cb 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -1404,12 +1404,18 @@ static void uart_set_rs485_termination(struct uart_port *port,
>  static int uart_rs485_config(struct uart_port *port)
>  {
>  	struct serial_rs485 *rs485 = &port->rs485;
> +	unsigned long flags;
>  	int ret;
>  
> +	if (!(rs485->flags & SER_RS485_ENABLED))
> +		return 0;
> +
>  	uart_sanitize_serial_rs485(port, rs485);
>  	uart_set_rs485_termination(port, rs485);
>  
> +	spin_lock_irqsave(&port->lock, flags);
>  	ret = port->rs485_config(port, NULL, rs485);
> +	spin_unlock_irqrestore(&port->lock, flags);
>  	if (ret)
>  		memset(rs485, 0, sizeof(*rs485));

Is there some kind of guarantee that 2 CPUs cannot go into
uart_rs485_config() simultaneously? Otherwise it seems dangerous to be
using and clearing @port->rs485 outside of the spin_lock.

John Ogness

  parent reply	other threads:[~2023-09-21 20:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 14:52 [PATCH tty-linus] serial: Reduce spinlocked portion of uart_rs485_config() Lukas Wunner
2023-09-21 15:01 ` Ilpo Järvinen
2023-09-22  4:02   ` Lukas Wunner
2023-09-22  4:04     ` Lukas Wunner
2023-09-22  9:30       ` Ilpo Järvinen
2023-09-21 15:18 ` John Ogness [this message]
2023-09-21 15:23   ` Ilpo Järvinen
2023-09-22  4:23   ` Lukas Wunner

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=87zg1fees3.fsf@jogness.linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=LinoSanfilippo@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lukas@wunner.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.