Message ID | 20230109072940.202936-1-t.schramm@manjaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2021395wrt; Sun, 8 Jan 2023 23:32:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXvrEe03ueh5spNorMc048Y4778oICST69CE/xHLZIWMzji07uOEbsi+ds8VWS5EZFvK6pfg X-Received: by 2002:aa7:d4d5:0:b0:493:1770:e87e with SMTP id t21-20020aa7d4d5000000b004931770e87emr11988577edr.9.1673249570534; Sun, 08 Jan 2023 23:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673249570; cv=none; d=google.com; s=arc-20160816; b=kCrjK8ZuPZcRmfJSbxAoDT+dULAzziY3w3wkNd+P0/Dbd68X2EQHdlSz0TVGVsnjm4 /xoVo5womLa9kPrhD4rUy1odlPEFAY3Ou7DBuoxwXciQcUvjVNtrKnmckiMMngPtDfpF gxJaGEd0WzJvElYoUndARa6tThxbgHa2ir0LSqEzmjw8ze8fWHMgNt8byafTRttKU8ug gKmom7K8MR+QOHDPdxtvmPjERA49wrAgUWdtYTHWm5u0/ep6IgZbitYHbAHjtNerBZCn cPWJy4JWhmzKBNykO35Vi8pQtPQ8zo1j81AfEusXzKF4Xexi76SDOxbf9diix5dFP0kZ Yvfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=29QIL+QEkq9knr5zcwLlDSxRecRnTAv84UiAsJWQ0iY=; b=xMzJLbSIs9NGmLsv+qopXkD2BBLdoxAQE8S7BKl7lzPokiULeEekvPq1cJ+wdL31ts LO/SyjoctJDBxJvSGPR86Uz4OGTj3xye4xH+pndnltCE/PLWF9sBgcD/wxF0eabs/aGb DdesQi7h0CkrL1TJQO7F95yNS4qEMk16d2w1QHD3zu0HzjU5KgX4GLEIMZI4sQQW8CID ekP5ymSteOpWpDsQkMOA1DgeugVz9WC2E/Ci8w/FpsKjD4fchCu7+41uWKfExuTguVrJ oL7gkqZdE6BP5cw0zweKnvXnBLzzblnnyJxm0v1OqwF2alXErcmywZZxSvr06QicORi0 QNSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@manjaro.org header.s=2021 header.b="aR/qko7k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=manjaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a056402120c00b00484e95ad48bsi6869630edw.115.2023.01.08.23.32.27; Sun, 08 Jan 2023 23:32:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@manjaro.org header.s=2021 header.b="aR/qko7k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=manjaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233666AbjAIH3v (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Mon, 9 Jan 2023 02:29:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233304AbjAIH3s (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 02:29:48 -0500 Received: from mail.manjaro.org (mail.manjaro.org [IPv6:2a01:4f8:c0c:51f3::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A4C5FEA; Sun, 8 Jan 2023 23:29:47 -0800 (PST) From: Tobias Schramm <t.schramm@manjaro.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1673249386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=29QIL+QEkq9knr5zcwLlDSxRecRnTAv84UiAsJWQ0iY=; b=aR/qko7kcXgBslpNt4v3FaBnelTNie8so2GsxiYY+iCIawUFySmxheiC8+yY41V0mAz63E fu4JuUPnectJkBHurE+uMt8uPbuxD5JzS7G+alkhfUEKNIRcQ5hoFQpw1QBoskOPBuWoEU xmLANAMFDBNpw4XOxr4NdRNT/1eic/EAIpAmClKovLeUfCaq26GwTp2+cyirRR2GhRU2u5 zXgY1BL/tQ2rizg0G62pKcumDAxqjfKjRV56yGRDdYOVgv9h2LI0c25ZOJvGoILsTQ+AQE ZBTPmXma6Ni7AyEtXI58bASQvltfrrQT9XOcv9kAn0dG+7R9dwJ9MEztNlawuw== To: Richard Genoud <richard.genoud@gmail.com>, 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, Tobias Schramm <t.schramm@manjaro.org> Subject: [PATCH v2] serial: atmel: fix incorrect baudrate setup Date: Mon, 9 Jan 2023 08:29:40 +0100 Message-Id: <20230109072940.202936-1-t.schramm@manjaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: ORIGINATING; auth=pass smtp.auth=t.schramm@manjaro.org smtp.mailfrom=t.schramm@manjaro.org X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754527453166038356?= X-GMAIL-MSGID: =?utf-8?q?1754529341571451961?= |
Series |
[v2] serial: atmel: fix incorrect baudrate setup
|
|
Commit Message
Tobias Schramm
Jan. 9, 2023, 7:29 a.m. UTC
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>
---
drivers/tty/serial/atmel_serial.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
Comments
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
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)