lkml.org 
[lkml]   [2022]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v9 4/6] serial: take termios_rwsem for ->rs485_config() & pass termios as param
From
On 24. 06. 22, 22:42, Ilpo Järvinen wrote:
> To be able to alter ADDRB within ->rs485_config(), take termios_rwsem
> before calling ->rs485_config() and pass termios.

OK, FTR, worth noting the tty->termios_rwsem -> port->mutex lock chain
is preexisting.

Anyway, I'm not sure I buy the above. Why is termios_rwsem needed to
alter ADDRB?

> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 621fc15e2e54..44c3785445e3 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
...
> @@ -1511,6 +1511,10 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
> if (ret != -ENOIOCTLCMD)
> goto out;
>
> + /* rs485_config requires more locking than others */
> + if (cmd == TIOCGRS485)
> + down_write(&tty->termios_rwsem);
> +
> mutex_lock(&port->mutex);
> uport = uart_port_check(state);
>
...
> @@ -1551,6 +1555,8 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
> }
> out_up:
> mutex_unlock(&port->mutex);
> + if (cmd == TIOCGRS485)
> + up_write(&tty->termios_rwsem);
> out:
> return ret;
> }

thanks,
--
js

\
 
 \ /
  Last update: 2022-07-04 08:53    [W:0.089 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site