Re: [PATCH] serial: Fail TIOCMGET/SET if port is suspended

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/11/2015 08:15 AM, Gabriel Krisman Bertazi wrote:
> When a PCI error is detected, reset code in 8250_pci.c suspends the uart
> ports to block IO while recovery procedure is performed.  Nevertheless,
> TIOCMGET and TIOCMSET ioctls are still able to reach the device even
> when it is suspended, which might cause EEH recovery of serial adapters
> to fail on Power systems.  This patch blocks any TIOCMGET/TIOCMSET calls
> from reaching the device if the port is suspended, to avoid racing with
> the recovery procedure.

This really should be handled by the 8250_pci sub-driver ticking
TTY_IO_ERROR so that almost all tty operations fail (a minor bug fix
to properly order the clearing of ASYNC_INITIALIZED w/ setting TTY_IO_ERROR
in uart_shutdown() would be req'd).

Unfortunately the machinery to do that doesn't exist.
I could trivially add a means given a uart_port ptr but the difficulty
of _safely_ getting a uart_port from line index still remains;
serial8250_get_port() should have just added a full ref count mechanism.

We should really just bite the bullet and do the heavy lifting required.

Regards,
Peter Hurley

> Signed-off-by: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxxxxxxx>
> ---
>  drivers/tty/serial/serial_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 603d2cc..e4ecbd2 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -979,7 +979,7 @@ static int uart_tiocmget(struct tty_struct *tty)
>  	int result = -EIO;
>  
>  	mutex_lock(&port->mutex);
> -	if (!(tty->flags & (1 << TTY_IO_ERROR))) {
> +	if (!(tty->flags & (1 << TTY_IO_ERROR)) && !uport->suspended) {
>  		result = uport->mctrl;
>  		spin_lock_irq(&uport->lock);
>  		result |= uport->ops->get_mctrl(uport);
> @@ -999,7 +999,7 @@ uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)
>  	int ret = -EIO;
>  
>  	mutex_lock(&port->mutex);
> -	if (!(tty->flags & (1 << TTY_IO_ERROR))) {
> +	if (!(tty->flags & (1 << TTY_IO_ERROR)) && !uport->suspended) {
>  		uart_update_mctrl(uport, set, clear);
>  		ret = 0;
>  	}
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux