Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp862246ybl; Fri, 13 Dec 2019 05:50:17 -0800 (PST) X-Google-Smtp-Source: APXvYqx14EXwnhkZ3Sh2L6W0S6YDyhIH6+hhMPlWmyn51OEnoMyFRuqYtc9Qek/fnZYRYhTq8t+4 X-Received: by 2002:a9d:7f16:: with SMTP id j22mr14346098otq.256.1576245017728; Fri, 13 Dec 2019 05:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576245017; cv=none; d=google.com; s=arc-20160816; b=dgi8WXzKNLY4SWz7JebokJA7fNpJJMASb0sl9lgN3xqxcd11vo92dA8Rs6J6ivM5tl nxkjjhd4Glo+gokxoe7uaO1bQuADaZVYNeDcCHkgyqAWMj4U63JXmdFJ1DensMkEoxXz Pea4EHB2h2tWC4YonyytnxAVdM9nBLXsOCVQGxMIXS1GLwQhc25xXOo3vsLQJpKHF0jj B7Z/I6Zk49b92iE7bixt0YU7ISb53hRm79klvG0MptahvWaqOBh+U+dXxdcm2tzG9JUh 9iepyRR7cJPBru6L1FVPBvvkFg/kQXah5FclSCGB5qBAjPgUBRZcX7Or+OsJnibfSHQ/ ObjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:cc:to:subject; bh=f1luU71/gaWM/SH52yZGaNPykJbh2MrJGT2aZdrI6As=; b=b4EKKWfvUyaIfk5eYYCIQ+4oFBNCgzi2nfrMRMVZjOYpyIwzAmQ53CPpnHzYK2ZQJQ ZPRDwdGCG4gGlqM1i/qZ4SKBk8AB+AKazpmK/dAFSPPnuIDDcVl8nRlsyBtB42vams0n uHFgiO0UdkaBtW6XIzb/0rvUyuznX7tQxmhSXek9L4m+ZZ4eL1IbxkVCgN3aQkRDtMvV fXuUtqld/wuI1B6xn0TmmYe6OUw5qlRpLfBTKu4WqGJpFJ+6Ieg2Au+CIYl/hxyKFoIe 3GpHH/izuz2azk3M9NBUSN8ILI9fJ62cCHeYN/X9njNa/k/MLXsKp82H+l4e51/dZMFs 6M9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t134si4743794oie.148.2019.12.13.05.50.05; Fri, 13 Dec 2019 05:50:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfLMNtH (ORCPT + 99 others); Fri, 13 Dec 2019 08:49:07 -0500 Received: from mail.sysgo.com ([176.9.12.79]:58406 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfLMNtH (ORCPT ); Fri, 13 Dec 2019 08:49:07 -0500 Subject: Re: [PATCH] tty/serial: atmel: fix out of range clock divider handling To: Richard Genoud , gregkh@linuxfoundation.org, jslaby@suse.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20191211162954.8393-1-david.engraf@sysgo.com> <822ac68e-4dde-21e8-caf9-a219b910d49e@gmail.com> From: David Engraf Message-ID: <1e2e3f63-84db-4b38-1bf1-85916116e0a2@sysgo.com> Date: Fri, 13 Dec 2019 14:49:03 +0100 MIME-Version: 1.0 In-Reply-To: <822ac68e-4dde-21e8-caf9-a219b910d49e@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 13.12.19 at 10:57, Richard Genoud wrote: > 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 > > It seems that this bug was introduced by: > commit 5bf5635ac170 ("tty/serial: atmel: add fractional baud rate support") > > Could you add the "Fixes:" header ? Sure. > 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. I fully agree, the RTS pin configuration depends on USART_MODE. I will make a new version of the patch. Thanks - David > >> 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 ! >