From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14ABFC00140 for ; Wed, 24 Aug 2022 12:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: MIME-Version:References:Message-ID:In-Reply-To:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=opYLdPBcAX3ecJm/8nCTlvLKrrj6FDwvcR6FnIK3gJM=; b=QLi3evy95CLZnhT6KG5xHuexcu 0YIhYjGt4OTem9HlsynA41BjhBPctpkGX6euZGo1nUgWgKl3qNQ7DJjvdRbfbrWk2nS21GZs2YUey Fm1oxA5L2fGbqpdhX6J+RzPgE9StoNwHXl9bT9BO6My/4cnQeEZlf6AkmyFIJGH/0NoeBefEwjkmO cINHTkWyLnoRC00P/7biyI0oPF1Xg1z4U+slHCY6qVqO32N0Ha7cuAXTqPRXid8Et7UU9bTA4TFRV aT2oZbcuol4l856eM1UpHHiwXakPxrmQrQcquj/uBMBPCOMBbDA+xs5MUGQ21u2ffjDvnEGqB3w6K YXcI5xmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQp5s-00CfFh-EJ; Wed, 24 Aug 2022 12:02:48 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQp5p-00CfCl-G7 for linux-arm-kernel@lists.infradead.org; Wed, 24 Aug 2022 12:02:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661342565; x=1692878565; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=CrWyZLJD2SRdNlJrJZciJFk6p2Q2ugSTZKjZU9gzjJ4=; b=hcW5jsyxeclBodEM4Frvqx00xg9eBqoU5bMDNbytcohtZOoo0cjdflnx u0WEFUlsnbGFIjPIFEfLuGKfTWpA7OM0XrHLE8idFGJ2RfWbYQmAy+FdZ tYomyZilJsdtckWYstnZJ3/0D16eFDt4QzOmoAdKYdU0GL0dDPfmjfkoP +FgQ9XJzJl2ggL7sUU+XTbvZoqKE015SHxA5FHNyeI2n1FVw560eZ2oft /c374pCkzPn6HFCjm6qS16eGGcEHyxTXBDfyoyQyAwXKdoJuwliqNiA4A pRHtnp8WutvdBsZrmSdl5ieEIjodplDslwqDEny5QdpxUqq7j9znVTeHh g==; X-IronPort-AV: E=McAfee;i="6500,9779,10448"; a="295225901" X-IronPort-AV: E=Sophos;i="5.93,260,1654585200"; d="scan'208";a="295225901" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 05:02:41 -0700 X-IronPort-AV: E=Sophos;i="5.93,260,1654585200"; d="scan'208";a="670474495" Received: from cdenk-mobl.ger.corp.intel.com ([10.252.40.24]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 05:02:36 -0700 Date: Wed, 24 Aug 2022 15:02:30 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Sergiu Moga Subject: Re: [PATCH] tty: serial: atmel: Preserve previous USART mode if RS485 disabled In-Reply-To: <20220824114255.444655-1-sergiu.moga@microchip.com> Message-ID: <2cab23a2-7a82-9321-dca1-5c7c71484ad@linux.intel.com> References: <20220824114255.444655-1-sergiu.moga@microchip.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-121819602-1661342560=:1558" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220824_050245_715208_BC23B67F X-CRM114-Status: GOOD ( 26.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, rick@efn.org, richard.genoud@gmail.com, Greg Kroah-Hartman , claudio@evidence.eu.com, LKML , ryan@bluewatersys.com, linux-serial , michael@evidence.eu.com, rmk+kernel@arm.linux.org.uk, Jiri Slaby , claudiu.beznea@microchip.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-121819602-1661342560=:1558 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT On Wed, 24 Aug 2022, Sergiu Moga wrote: > Whenever the atmel_rs485_config driver method would be called, > the USART mode is reset to normal mode before even checking if > RS485 flag is set, thus resulting in losing the previous USART > mode in the case where the checking fails. Some tools, such as > `linux-serial-test`, lead to the driver calling this method > when doing the setup of the serial port: after setting the port > mode (Hardware Flow Control, Normal Mode, RS485 Mode, etc.), > `linux-serial-test` tries to enable/disable RS485 depending on > the commandline arguments passed. If we were to, for example, enable > Hardware Flow Control through `linux-serial-test`, the tool would > make the driver set the corresponding bit to 1 (ATMEL_US_USMODE_HWHS > bit in the ATMEL_US_MR register) through the atmel_set_termios method > and then proceed to disabling RS485. This, in turn, causes the > ATMEL_US_USMODE_HWHS bit of the ATMEL_US_MR mode register to be unset > and, if the checking for RS485 fails, leads to having the mode set > back to the ATMEL_US_USMODE_NORMAL normal mode. Since in hardware > flow control mode the meanings of the ATMEL_US_RTSDIS and > ATMEL_US_RTSEN bits are swapped, this leads to our endpoint leaving > the RTS line to high when wanting to receive, which is the opposite > of what the other endpoint is expecting in order to start transmitting. > This fix ensures that this reset is done only if the checking for RS485 > succeeds. Could you please try to split this long paragraph to a slightly shorter bits such that it would be easier to read. > Fixes: e8faff7330a35 ("ARM: 6092/1: atmel_serial: support for RS485 communications") > Signed-off-by: Sergiu Moga > --- > drivers/tty/serial/atmel_serial.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index 0a0b46ee0955..c29b1fb48694 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c > @@ -298,9 +298,6 @@ static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios, > > mode = atmel_uart_readl(port, ATMEL_US_MR); > > - /* Resetting serial mode to RS232 (0x0) */ > - mode &= ~ATMEL_US_USMODE; > - > if (rs485conf->flags & SER_RS485_ENABLED) { > dev_dbg(port->dev, "Setting UART to RS485\n"); > if (rs485conf->flags & SER_RS485_RX_DURING_TX) > @@ -310,6 +307,7 @@ static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios, > > atmel_uart_writel(port, ATMEL_US_TTGR, > rs485conf->delay_rts_after_send); > + mode &= ~ATMEL_US_USMODE; > mode |= ATMEL_US_USMODE_RS485; > } else { > dev_dbg(port->dev, "Setting UART to RS232\n"); > Makes sense. Reviewed-by: Ilpo Järvinen Unrelated to this patch but I came across it while reviewing yours... Do you BTW have any idea why atmel_serial_probe() sets ATMEL_US_USMODE_NORMAL inside rs485_enabled block? I'd have expected it wanted to do ATMEL_US_USMODE_RS485 there too like is done in atmel_config_rs485(). -- i. --8323329-121819602-1661342560=:1558 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --8323329-121819602-1661342560=:1558--