Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5272186imm; Tue, 12 Jun 2018 05:29:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJb+VWtp1gvcL6UdyjC4t4o+3j902SfqUs4tMrX7UgwSh+KUantPZfAL1PbhC8YZOKAszKm X-Received: by 2002:a62:1fd6:: with SMTP id l83-v6mr197684pfj.182.1528806588344; Tue, 12 Jun 2018 05:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528806588; cv=none; d=google.com; s=arc-20160816; b=zDEfTxDfOfRixH/PyyIzOJlXmQY9dwrUiAX5z8Bp/5gNrjipMeAm/1qlOzqh/ybzld 4Yv9s00vl0lY83Gz9joHBX2aos9cDH4ge8R8neWdHopmyhIfvT2j10sRgtm/8yPpe98l ctQQMYzIiFG43LmHVQuTFSfoZpJ67zl9LaYA5Vl6RXv64MdAcD1ywz7SO5nyahKW1/h8 pJJ/s7hURG/62Utae7v4tcUnSZVbGmPUWW9szVB7TtB4qE2c4zTbRZr8LWoGgp9qHob1 IlWhZfDazq3uVXl1zscc4b3PHH9yzVK0OakUwM0Lf7EXsubfrRLt/GqQZyuUUuzMCoyj JGwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=1KIjnkBH5u30YZHsgkSadPE2IqL6g5oLKfhEhXNnr4s=; b=U2Sz2//yWqId36bN5VBgsuiaYqvR11YsQWSQePCLeB4SHFRy7j0n92iEvxvpvrm9Jq jGvYCAEYyj+h8nc+IgjkiIcaRytZgTsnObU4qReSj/HE+osNfkHQJLYAKpTDiOtyH3x2 1DCCO9QwLfO7FaR0BQuu13EbDLE5/feCOkfwjGSUCWj0sVZHgxLvW1pW2zIIw2pdzsdQ gG0zz2itVHtgGzx+AZsOOrY03if9MVGmgOXg34LLXBbzRb214pBAe/rTQjbB1iqy04oL 2kBfnbGsyLip8xI0Fgw2nBuU03gX7vjB4KxrlQa3dY0zg3EEtDVizv0+E6mZqMNX2bWw mPAQ== 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 90-v6si59103pla.38.2018.06.12.05.29.34; Tue, 12 Jun 2018 05:29:48 -0700 (PDT) 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 S933424AbeFLM3B (ORCPT + 99 others); Tue, 12 Jun 2018 08:29:01 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:59059 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933082AbeFLM3A (ORCPT ); Tue, 12 Jun 2018 08:29:00 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSiPu-0006Ev-Kz; Tue, 12 Jun 2018 14:28:54 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fSiPr-0005vi-Cn; Tue, 12 Jun 2018 14:28:51 +0200 Date: Tue, 12 Jun 2018 14:28:51 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Stefan Agner Cc: gregkh@linuxfoundation.org, festevam@gmail.com, jslaby@suse.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] serial: imx: fix cached UCR2 read on software reset Message-ID: <20180612122851.7xjneseskhkvn3ih@pengutronix.de> References: <20180420124407.12892-1-stefan@agner.ch> <20180607075633.y3tm245jv7nkdrqx@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 12, 2018 at 02:11:44PM +0200, Stefan Agner wrote: > On 07.06.2018 09:56, Uwe Kleine-K?nig wrote: > > On Fri, Apr 20, 2018 at 02:44:07PM +0200, Stefan Agner wrote: > >> To reset the UART the SRST needs be cleared (low active). According > >> to the documentation the bit will remain active for 4 module clocks > >> until it is cleared (set to 1). > >> > >> Hence the real register need to be read in case the cached register > >> indicates that the SRST bit is zero. > >> > >> This bug lead to wrong baudrate because the baud rate register got > >> restored before reset completed in imx_flush_buffer. > >> > >> Fixes: 3a0ab62f43de ("serial: imx: implement shadow registers for UCRx and UFCR") > >> Signed-off-by: Stefan Agner > >> Reviewed-by: Fabio Estevam > >> Reviewed-by: Uwe Kleine-K?nig > > > > For the record, there is a customer of mine who reports that this commit > > breaks rs485 communication on i.MX25 because RTS stops to toggle as > > intended. > > > > (Some details: uart3, fsl,uart-has-rtscts, fsl,dte-mode, > > linux,rs485-enabled-at-boot-time, native RTS.) > > > > I didn't debug this yet. > > I have seen your patch today "serial: imx: fix comment about UCR2_SRST > and its handling for shadowing" so I assume you looked into this issue? > > Was it related to that change? I started looking into this issue, but didn't find the culprit yet. My work in progress patch looks as follows: diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 758a67f3c8b3..5270173721c6 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1357,6 +1357,12 @@ static int imx_uart_startup(struct uart_port *port) while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) udelay(1); + if (imx_uart_readl(sport, UCR2) & UCR2_SRST) { + spin_unlock_irqrestore(&sport->port.lock, flags); + dev_warn(port->dev, "SRST didn't go away\n"); + return -EIO; + } + /* * Finally, clear and enable interrupts */ which seems to trigger on both i.MX25 and i.MX6 at least occasionally. Maybe 100 us is too short? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |