From patchwork Mon Jan 9 07:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 40682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2012392wrt; Sun, 8 Jan 2023 23:02:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXt50mfqR+NJ+rb6Yt4hq8hDPcrA27bz15ZnZ1geOCaEY2BPEgKuDWPorzUaL0/LzcSkX0L7 X-Received: by 2002:a17:902:bd98:b0:188:8cfc:6ba7 with SMTP id q24-20020a170902bd9800b001888cfc6ba7mr66471910pls.68.1673247769219; Sun, 08 Jan 2023 23:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673247769; cv=none; d=google.com; s=arc-20160816; b=akEdYtDBWhkNBaZYVERQQjOhzFqF3VnmCJwUUUZHKFiajjr8hi4m687W7UTN+f2QDj Om89N9Rf+s+yVjsi4GXMOHsZSOhF+cA0jKKCoNJhz+JYKMu1FbIlV4xsjrUEfBtlWxf7 Z1uT8EKw7vI1Av1/fk8RC9tQa9xLve2/Pf6uWKvYI9K7mesoWRobn8GTVpvZL3HJmpCg 8ogngKLL318B8pVsZqWg7LN5SHwS23v9uSgaus7ItQKp/NDXDuK0D0K+mURB1ABpzytS dNnNA3SOEe355MzQdP4fXSjJMrJXWB0Flm5dM1G1Aj6q0hVMUwbuqOt1AUpP01vbNxoP 1ynQ== 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=oCppCv1oBsre+FVN86oFN46fKVCfGcF37Evg0UDVbMg=; b=p1BhFr7eggZc+SABrY7ojI+AHsYnar3KQ4MXn/T+w+LU9vOYnqVFaCQALL4/0fae6M QFIn0OG3znqjoNEdwigWR3iIAgyDroeS7hS3nD7S1/lzYWjYjA3YNTihvjiCCk98Wg2C v9aESi5k09+TmK55lT2UsvimLXQWGXNzmAbNmnvtgq3I9pHUppuRG+7FGrMAbFedt+7M 2QcmeI6LFTQTDv6Qj0UCuKf89Vf8IFZ4ldVNqMCBwXBdtpWz8OBwJB3nYqU8Rg91BhXW cYkBqH+VjMKYDcPe4M4D/1y59ZkJ9G6Bsc/oZaxZk3Bc0tz5vwNUXhBDYXcvp2WPFmFd ZDEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@manjaro.org header.s=2021 header.b="lXde/TaE"; 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 b4-20020a170903228400b00188f882599csi9810428plh.58.2023.01.08.23.02.37; Sun, 08 Jan 2023 23:02:49 -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="lXde/TaE"; 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 S233655AbjAIHCL (ORCPT + 99 others); Mon, 9 Jan 2023 02:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233304AbjAIHCJ (ORCPT ); Mon, 9 Jan 2023 02:02:09 -0500 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E78D5FAE for ; Sun, 8 Jan 2023 23:02:07 -0800 (PST) From: Tobias Schramm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1673247725; 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=oCppCv1oBsre+FVN86oFN46fKVCfGcF37Evg0UDVbMg=; b=lXde/TaEiwxChv4sBX/aT/8+A5We1Huz6H/ExEvgCIS96gaNehxWUSxhbYoeFnuf5ZDWfq iciIAbeKcl8VwT3kJIBvZPvL59pG5dS9H5WzfbjTWD1uR0LP45A/0vV2VT7nO/IOBNLe1h rH6TlalMTyuBtilnFyNOF61AHaxmBW+zs2evkFWG0nmqMzyR7HeRh7xq4JlNi3FjNcfh0L tkCcOpiuVCRj3hti8bA/WVK8HeqxlsJhTD93CSqUBV4KF/tqZ8ctnXb0jl6uFmR1P6OPhD YT/zm94sVU3AUThynErZiXiPOdzNv2evc35h1P7O6QCqBBMQvJjLzjIzrrvMOA== To: Richard Genoud Cc: Greg Kroah-Hartman , Jiri Slaby , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Tobias Schramm Subject: [PATCH] serial: atmel: fix incorrect baudrate setup Date: Mon, 9 Jan 2023 08:02:00 +0100 Message-Id: <20230109070200.200181-1-t.schramm@manjaro.org> MIME-Version: 1.0 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: 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?1754527453166038356?= 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. Signed-off-by: Tobias Schramm --- 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)