lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 13 Dec 2019 10:57:45 +0100
From:   Richard Genoud <richard.genoud@...il.com>
To:     David Engraf <david.engraf@...go.com>, richard.genoud@...il.com,
        gregkh@...uxfoundation.org, jslaby@...e.com,
        nicolas.ferre@...rochip.com, alexandre.belloni@...tlin.com,
        ludovic.desroches@...rochip.com
Cc:     linux-serial@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty/serial: atmel: fix out of range clock divider
 handling

Hi,

Le 11/12/2019 à 17:29, David Engraf a écrit :
> Use MCK_DIV8 when the clock divider is > 65535. Unfortunately the mode
> register was already written thus the clock selection is ignored.
> 
> Fix by writing the mode register after calculating the baudrate.
> 
> Signed-off-by: David Engraf <david.engraf@...go.com>

It seems that this bug was introduced by:
commit 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support")

Could you add the "Fixes:" header ?

Ludovic, could you check if this was your intent at the time ?

> ---
>  drivers/tty/serial/atmel_serial.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index a8dc8af83f39..9983e2fabbac 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
>  		mode |= ATMEL_US_USMODE_NORMAL;
>  	}
>  
I think it's better to mo move the "Set baud rate" block here (cf bellow)

> -	/* set the mode, clock divisor, parity, stop bits and data size */
> -	atmel_uart_writel(port, ATMEL_US_MR, mode);
> -
>  	/*
>  	 * when switching the mode, set the RTS line state according to the
>  	 * new mode, otherwise keep the former state
> @@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
>  	}
>  	quot = cd | fp << ATMEL_US_FP_OFFSET;
>  
> +	/* set the mode, clock divisor, parity, stop bits and data size */
> +	atmel_uart_writel(port, ATMEL_US_MR, mode);
> +
I think your patch is good, but I'll be happier if instead of moving
those 2 lines here, the whole "Set the baud rate" block was moved before
"atmel_uart_writel(port, ATMEL_US_MR, mode);"

That's because at line 2291 the ATMEL_US_CR register is set with
ATMEL_US_RTSDIS or ATMEL_US_RTSEN.
And those 2 values have a different effect depending on US_MR.USART_MODE

Quoting from the relase manual:
RTSEN:
1: Drives RTS pin to 1 if US_MR.USART_MODE field = 2, else drives RTS
pin to 0 if US_MR.USART_MODE field = 0.

RTSDIS:
1: Drives RTS pin to 0 if US_MR.USART_MODE field = 2, else drives RTS
pin to 1 if US_MR.USART_MODE field = 0.

So, I think it's better to set the mode register before setting the
control register.


>  	if (!(port->iso7816.flags & SER_ISO7816_ENABLED))
>  		atmel_uart_writel(port, ATMEL_US_BRGR, quot);
>  	atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
> 

Thanks !

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ