From patchwork Sun Jan 8 18:06:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clemens Gruber X-Patchwork-Id: 9503569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1C15E606E1 for ; Sun, 8 Jan 2017 18:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 135E62838E for ; Sun, 8 Jan 2017 18:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0822F28403; Sun, 8 Jan 2017 18:06:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A97F2838E for ; Sun, 8 Jan 2017 18:06:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQHra-0002oD-O6; Sun, 08 Jan 2017 18:06:38 +0000 Received: from mail.pqgruber.com ([178.189.19.235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQHrW-0002ab-QP for linux-arm-kernel@lists.infradead.org; Sun, 08 Jan 2017 18:06:36 +0000 Received: from archie.localdomain (213-47-168-109.cable.dynamic.surfer.at [213.47.168.109]) by mail.pqgruber.com (Postfix) with ESMTPSA id 84BA2D7882; Sun, 8 Jan 2017 19:06:11 +0100 (CET) Date: Sun, 8 Jan 2017 19:06:09 +0100 From: Clemens Gruber To: Fabio Estevam Subject: Re: imx: RS-485 problems during TX, maybe DMA related Message-ID: <20170108180609.GB24155@archie.localdomain> References: <20170106225026.GA3804@archie.localdomain> <20170107134557.GA12299@archie.localdomain> <20170107153434.GA13307@archie.localdomain> <20170107205930.GA12367@archie.localdomain> <20170107230624.GA21729@archie.localdomain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170108_100635_056202_D253E95C X-CRM114-Status: GOOD ( 24.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Nandor Han , linux-arm-kernel@lists.infradead.org, Lucas Stach Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Fabio, On Sun, Jan 08, 2017 at 12:30:24AM -0200, Fabio Estevam wrote: > Hi Clemens, > > On Sat, Jan 7, 2017 at 9:06 PM, Clemens Gruber > wrote: > > > Just remuxed GPIO signals to these pads, applied your two patches and > > used rts-gpios in the DT but I still see the same problem :/ > > > > When transmit something, I get doubled characters, then zeros and at the > > end garbled data of previous transmissions, same as described in my > > first post (Logic analyzer: https://pqgruber.com/rs485_results.png) > > The data is always 4096 bytes long, this explains why the echo command > > is blocking for about 4 seconds (<- 4096 bytes at a baudrate of 9600). > > The TE line is also high until all 4096 bytes are sent. > > > > I think this comes from the UART_XMIT_SIZE which is defined to the page > > size. > > Maybe there is something wrong in imx_transmit_buffer and leads to the > > whole circular buffer being sent out all the time, not stopping.. > > > > Do these debug logs tell you anything? > > https://gist.github.com/clemensg/1ac5ee8a8ea32acc9145c5aa8407aea5 > > > > I am analyzing the signals coming directly from the i.MX6Q, so this must > > be a software problem, but I don't understand why it works for you, if > > we use the same software. > > > > Do you use any other patches on top of mainline and do you use the SDMA > > scripts from the ROM? > > No, I use the original 4.9 + the two patches I sent. Yes, I do use the > SDMA scripts from ROM. > > Here is the procedure I did to try to reproduce the issue you reported: > > (The rs485conf is available at: > https://github.com/mniestroj/rs485conf/blob/master/main.c ) > > First of all I enable rs485 for ttymxc3 using the rs485conf application: > > root@imx6qsabresd:/home# ./rs485conf /dev/ttymxc3 -e 1 > [ 27.106517] random: crng init done > = Current configuration: > RS485 enabled: false > RTS on send: high > RTS after send: low > RTS delay before send: 0 > RTS delay after send: 0 > Receive during sending data: true > > = New configuration: > RS485 enabled: true > RTS on send: high > RTS after send: low > RTS delay before send: 0 > RTS delay after send: 0 > Receive during sending data: true > > = Saved configuration: > RS485 enabled: true > RTS on send: high > RTS after send: low > RTS delay before send: 0 > RTS delay after send: 0 > Receive during sending data: true > root@imx6qsabresd:/ho > > Then > > root@imx6qsabresd:/home# echo A > /dev/ttymxc3 > > (wait 10 seconds) > > root@imx6qsabresd:/home# echo B > /dev/ttymxc3 > > (wait 10 seconds) > > root@imx6qsabresd:/home# echo C > /dev/ttymxc3 > > On the serial console at 9600bps only the: > A > B > C > > are seen, so not duplicated characters, nor noise is seen on the console. I just did the experiment with your configuration and the rs485conf tool you mentioned. But still, no luck :( What's the revision of the i.MX6Q on your board? Mine is 1.5 (TO 1.3) Another example: If I run the following on the board.. while true; do echo ABCDEFGHIJKLM > /dev/ttymxc4 sleep 0.5 echo abc > /dev/ttymxc4 > /dev/ttymxc4 sleep 0.5 done Many transmits contain garbled (doubled and sometimes also extended to a length of 4096 bytes, containing zeros) data. I can see a few transmissions that are sent correctly, though. Interesting side note: With the following patch, the problems disappear: --- Regards, Clemens diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 451e50f6d77a..eb9f0ce6c34a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1270,8 +1270,10 @@ static int imx_startup(struct uart_port *port) writel(temp & ~UCR4_DREN, sport->port.membase + UCR4); /* Can we enable the DMA support? */ +#if 0 if (!uart_console(port) && !sport->dma_is_inited) imx_uart_dma_init(sport); +#endif spin_lock_irqsave(&sport->port.lock, flags); /* Reset fifo's and state machines */