Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4587718imu; Tue, 18 Dec 2018 18:34:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/VrB7HrbwDtVgCkyv8rHAR46ySDg/jYgtzLrOcsHFnQ7C00YyDOzrbu7N8vU4tBMQ76DCyD X-Received: by 2002:a63:658:: with SMTP id 85mr17736196pgg.373.1545186898309; Tue, 18 Dec 2018 18:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545186898; cv=none; d=google.com; s=arc-20160816; b=CztBCyUw3P5KQV93ggjHbCSG8CuMts9BmM2zuu57su3+K51uH2Vz1Yn6KW7z1yZFKk wcTU3fqegAsvUu6ZZQDiiGmPJs1ZsAFi//DPrgA9voX4m8f/AHG/Cldcbw99FPCkff3I FBE8j7lu0z1mOwL+fPsUi5TrXMr1/RxrYMFbUXh9QgzFMzpUBVGv+/8NRaTWr5VZC5WG bXPwv+RN8dlY/33WJFt19eRWO1gpXUotvTzZS+HFIflFYn0/YG9GNA2jF5lA0Ce/H3mP 3QvdLBiMni51oLxm2zPReK0i0CuEsqabaUDh6OVkbmiYJJOLgCxBuZNG7mdPb3MEk2a5 eZsw== 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:user-agent:date :message-id:from:references:cc:to:subject; bh=sY7rJPoPHBmGfxeG0YivzPfH9ZGrMag7ItAc6aSB8fQ=; b=NZYadA14GO/wY/4SwaAT0s1ebnzWffpUdVf1r5TNdZNLz++KuaUJa+kHsoneN3SPBW fQXKfxb3Cw095kB82udGecx9L6TacVBglYHdyPD+rX6SIp6vaTFqfDN3/CHwI9OSyh+C YgNqUuYhalwlpx/7AgMWIwXvWEbMmozvVchdl2gZOchdVCNUGUE0dFf5I1gi5Rdj6KJ2 PlSPNyiWr2xVGGyGlGT8k0Uw3zMvgKh1aQeiRDrwHvuC0lvozlCX/PLem6NN1ZwUv4Nq hlgm6dPKTxH0cNcpYdTcuISetNBn+oC8R2ivY46FNilOZur6h7lnOizc7m/qc/9fthnc Blbg== 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 102si14809966plc.277.2018.12.18.18.34.40; Tue, 18 Dec 2018 18:34:58 -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 S1727088AbeLSAww (ORCPT + 99 others); Tue, 18 Dec 2018 19:52:52 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:51245 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbeLSAww (ORCPT ); Tue, 18 Dec 2018 19:52:52 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43KGZl34ZGz1qxJV; Wed, 19 Dec 2018 01:52:47 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43KGZl0czLz1qstF; Wed, 19 Dec 2018 01:52:47 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id p_ITxdhnlddH; Wed, 19 Dec 2018 01:52:45 +0100 (CET) X-Auth-Info: SygMuPJdcDDgj4NzomDDkYcRzDyyuT7DUkCZwdEoMpM= Received: from [IPv6:::1] (unknown [195.140.253.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 19 Dec 2018 01:52:45 +0100 (CET) Subject: Re: [PATCH] Revert "serial: 8250: Fix clearing FIFOs in RS485 mode again" To: Ezequiel Garcia , Paul Burton Cc: "linux-serial@vger.kernel.org" , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , Paul Burton , Daniel Jedrychowski , "linux-mips@vger.kernel.org" , stable , Ezequiel Garcia References: <20181213174834.kxdy6fphaeoivqgh@pburton-laptop> <20181216200833.27928-1-paul.burton@mips.com> <20181216213133.kwe24pif3v4wcgwp@pburton-laptop> <949fdd3d-535e-d235-f406-d5bde4658c5e@denx.de> <20181216222411.5jkexuaqxpfudj7b@pburton-laptop> <20181216223510.hxsdotf332ousinh@pburton-laptop> <61a3177f-4e8d-fc51-1e81-95af3baab3a8@denx.de> From: Marek Vasut Message-ID: <3086d1b7-9ed9-9d48-4371-89139c356d22@denx.de> Date: Wed, 19 Dec 2018 01:12:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <61a3177f-4e8d-fc51-1e81-95af3baab3a8@denx.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/17/2018 06:20 PM, Marek Vasut wrote: > On 12/17/2018 05:30 PM, Ezequiel Garcia wrote: >> On Sun, 16 Dec 2018 at 19:35, Paul Burton wrote: >>> >>> Hi Ezequiel, >>> >>> On Sun, Dec 16, 2018 at 07:28:22PM -0300, Ezequiel Garcia wrote: >>>> On Sun, 16 Dec 2018 at 19:24, Paul Burton wrote: >>>>> This helps, but it only addresses one part of one of the 4 reasons I >>>>> listed as motivation for my revert. For example serial8250_do_shutdown() >>>>> also clearly intends to disable the FIFOs. >>>>> >>>> >>>> OK. So, let's fix that :-) >>> >>> I already did, or at least tried to, on Thursday [1]. >>> >>>> By all means, it would be really nice to push forward and fix the garbage >>>> issue on JZ4780, as well as the transmission issue on AM335x. >>>> >>>> AM335x is a wildly popular platform, and it's not funny to break it. >>> >>> Well, clearly not if it was broken in v4.10 & only just fixed..? And >>> from Marek's commit message the patch in v4.10 doesn't break the whole >>> system just RS485. >>> >> >> Careful here. It's naive to consider v4.10 as old in this context. >> >> AM335x is used in hundreds of thousands of products, probably >> "industrial" products. >> Manufacturers don't always follow the kernel, and it's entirely >> likely that they notice a regression only when developing a new product, >> or when rebasing on top of a newer longterm kernel. >> >> Then again, I don't have any details about what is Marek's original fix >> actually fixing. >> >> Marek: could you please post the test case that you used to validate your fix? >> I can't find that anywhere. > > I can't share the testcase itself because it has no license and I didn't > write it, but I can tell you what it's doing. (I'll check if I can share > the testcase verbatim too, I just sent an email to the author) > > The test spawns two threads, one sending , one receiving. The sending > thread sends 8 bytes of data from /dev/ttyS4 , the receiving thread > receives the data on /dev/ttyS2 and compares the pattern. The port > settings is B1000000 8N1 with rs485conf.flags set to SER_RS485_ENABLED > and SER_RS485_RTS_AFTER_SEND. Sometimes the received data do not match > the sent data, but rather look as if one character was left over from > the previous transmission in the FIFO. > > Those two UARTs are connected together by two wires, without any real > RS485 hardware to minimize the hardware complexity (it's easy to > implement that on the pocketbeagle, which is the cheap option here). Test code is below . On the pocketbeagle, connect SPI0:CLK with U4:TX and SPI0:MISO with U4:RX , apply the DT patch below and run the example. It'll fail after a few iterations. #include #include #include #include #include #include #include #include #include #include #include std::atomic running{true}; int set_interface_attribs (int fd, int speed, int parity) { struct termios tty; memset (&tty, 0, sizeof tty); if (tcgetattr (fd, &tty) != 0) { std::cerr << "Error from tcgetattr" << std::endl; return -1; } cfsetospeed (&tty, speed); cfsetispeed (&tty, speed); tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; tty.c_iflag &= ~IGNBRK; tty.c_lflag = 0; tty.c_oflag = 0; tty.c_cc[VMIN] = 8; tty.c_cc[VTIME] = 0; tty.c_iflag &= ~(IXON | IXOFF | IXANY); tty.c_cflag |= (CLOCAL | CREAD); tty.c_cflag &= ~(PARENB | PARODD); tty.c_cflag |= parity; tty.c_cflag &= ~CSTOPB; tty.c_cflag &= ~CRTSCTS; if (tcsetattr (fd, TCSANOW, &tty) != 0) { std::cerr << "Error from tcsetattr" << std::endl; return -1; } return 0; } void enable_rts(int fd, int rts) { struct serial_rs485 rs485conf; if (rts) { rs485conf.flags = SER_RS485_ENABLED ; rs485conf.flags |= SER_RS485_RTS_AFTER_SEND; rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND); rs485conf.delay_rts_before_send = 0; rs485conf.delay_rts_after_send = 0; } else { rs485conf.flags = 0 ; } if (ioctl( fd, TIOCSRS485, &rs485conf) < 0){ std::cerr << "Cannot set device in RS485 mode" << std::endl; } } void output_function(int fd) { while(running) { write (fd, "asdfghjk", 8); usleep (20000); } } void input_function(int fd) { char buf [100]; size_t count=0; std::cout << std::unitbuf; while(running){ int n = read (fd, buf, sizeof buf); if( (n >0) && (buf[0] != 'a') ){ std::cout << "\nunexpected receive! " << std::string(buf,8) << std::endl; running = false; } else { ++count; if(count%100 == 0){ std::cout << "\r" << std::setw(8) << count << " possibly ok"; } } } } int main(int argc, char** argv) { std::string in_port = "/dev/ttyS2"; std::string out_port = "/dev/ttyS4"; int c, rts = 1; while ((c = getopt (argc, argv, "i:o:r")) != -1) { switch (c) { case 'i': in_port = std::string(optarg); break; case 'o': out_port = std::string(optarg); break; case 'r': rts = 0; break; case '?': return 1; default: break; } } std::cout << "opening output " << out_port << std::endl; int outfd = open ( out_port.c_str(), O_RDWR | O_NOCTTY | O_SYNC); if (outfd < 0) { std::cerr << "Could not open " << out_port << std::endl; return 1; } std::cout << "opening input " << in_port << std::endl; int infd = open ( in_port.c_str(), O_RDWR | O_NOCTTY | O_SYNC); if (infd < 0) { std::cerr << "Could not open " << in_port << std::endl; return 1; } set_interface_attribs (infd, B1000000, 0); set_interface_attribs (outfd, B1000000, 0); enable_rts(outfd, rts); enable_rts(infd, rts); std::thread in(input_function, infd); std::thread out(output_function, outfd); in.join(); out.join(); close(infd); close(outfd); } diff --git a/arch/arm/boot/dts/am335x-pocketbeagle.dts b/arch/arm/boot/dts/am335x-pocketbeagle.dts index 62fe5cab9fae..d9b8f09920a6 100644 --- a/arch/arm/boot/dts/am335x-pocketbeagle.dts +++ b/arch/arm/boot/dts/am335x-pocketbeagle.dts @@ -92,15 +92,6 @@ >; }; - spi0_pins: pinmux-spi0-pins { - pinctrl-single,pins = < - AM33XX_IOPAD(0x950, PIN_INPUT_PULLUP | MUX_MODE0) /* (A17) spi0_sclk.spi0_sclk */ - AM33XX_IOPAD(0x954, PIN_INPUT_PULLUP | MUX_MODE0) /* (B17) spi0_d0.spi0_d0 */ - AM33XX_IOPAD(0x958, PIN_INPUT_PULLUP | MUX_MODE0) /* (B16) spi0_d1.spi0_d1 */ - AM33XX_IOPAD(0x95c, PIN_INPUT_PULLUP | MUX_MODE0) /* (A16) spi0_cs0.spi0_cs0 */ - >; - }; - spi1_pins: pinmux-spi1-pins { pinctrl-single,pins = < AM33XX_IOPAD(0x964, PIN_INPUT_PULLUP | MUX_MODE4) /* (C18) eCAP0_in_PWM0_out.spi1_sclk */ @@ -126,6 +117,13 @@ >; }; + uart2_pins: pinmux-uart2-pins { + pinctrl-single,pins = < + AM33XX_IOPAD(0x950, PIN_INPUT | MUX_MODE1) /* spi0_sclk.uart2_rxd */ + AM33XX_IOPAD(0x954, PIN_OUTPUT | MUX_MODE1) /* spi0_d0.uart2_txd */ + >; + }; + uart4_pins: pinmux-uart4-pins { pinctrl-single,pins = < AM33XX_IOPAD(0x870, PIN_INPUT_PULLUP | MUX_MODE6) /* (T17) gpmc_wait0.uart4_rxd */ @@ -199,6 +197,13 @@ status = "okay"; }; +&uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2_pins>; + + status = "okay"; +}; + &uart4 { pinctrl-names = "default"; pinctrl-0 = <&uart4_pins>; -- Best regards, Marek Vasut