mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Richard Genoud <richard.genoud@gmail.com>
To: Tobias Schramm <t.schramm@manjaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@microchip.com>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] serial: atmel: fix incorrect baudrate setup
Date: Thu, 12 Jan 2023 17:15:10 +0100	[thread overview]
Message-ID: <97b5621c-f75c-a19d-0759-b19a8a7eb83f@gmail.com> (raw)
In-Reply-To: <20230109072940.202936-1-t.schramm@manjaro.org>

Le 09/01/2023 à 08:29, Tobias Schramm a écrit :
> Commit ba47f97a18f2 ("serial: core: remove baud_rates when serial console
> setup") changed uart_set_options to select the correct baudrate
> configuration based on the absolute error between requested baudrate and
> available standard baudrate settings.
> Prior to that commit the baudrate was selected based on which predefined
> standard baudrate did not exceed the requested baudrate.
> This change of selection logic was never reflected in the atmel serial
> driver. Thus the comment left in the atmel serial driver is no longer
> accurate.
> Additionally the manual rounding up described in that comment and applied
> via (quot - 1) requests an incorrect baudrate. Since uart_set_options uses
> tty_termios_encode_baud_rate to determine the appropriate baudrate flags
> this can cause baudrate selection to fail entirely because
> tty_termios_encode_baud_rate will only select a baudrate if relative error
> between requested and selected baudrate does not exceed +/-2%.
> Fix that by requesting actual, exact baudrate used by the serial.
> 
> Fixes: ba47f97a18f2 ("serial: core: remove baud_rates when serial console setup")
> Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
Acked-by: Richard Genoud <richard.genoud@gmail.com>

Tested-on sam9g35
> ---
>  drivers/tty/serial/atmel_serial.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index f1c06e12efa0..9cd7479b03c0 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2657,13 +2657,7 @@ static void __init atmel_console_get_options(struct uart_port *port, int *baud,
>  	else if (mr == ATMEL_US_PAR_ODD)
>  		*parity = 'o';
>  
> -	/*
> -	 * The serial core only rounds down when matching this to a
> -	 * supported baud rate. Make sure we don't end up slightly
> -	 * lower than one of those, as it would make us fall through
> -	 * to a much lower baud rate than we really want.
> -	 */
> -	*baud = port->uartclk / (16 * (quot - 1));
> +	*baud = port->uartclk / (16 * quot);
>  }
>  
>  static int __init atmel_console_setup(struct console *co, char *options)
Thanks !


Regards,
Richard

      reply	other threads:[~2023-01-12 16:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09  7:29 Tobias Schramm
2023-01-12 16:15 ` Richard Genoud [this message]

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=97b5621c-f75c-a19d-0759-b19a8a7eb83f@gmail.com \
    --to=richard.genoud@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=t.schramm@manjaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®