Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2243888ybk; Sun, 17 May 2020 15:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqrzfRAoJIPfCclv9Zr/rOGAUWgJg4zKC7pcJpF+QZqcpDrIvZ6vxFbPT92WNcmUbn+Vzf X-Received: by 2002:aa7:db4c:: with SMTP id n12mr10834862edt.99.1589752995035; Sun, 17 May 2020 15:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589752995; cv=none; d=google.com; s=arc-20160816; b=0I4j7M03NqeSaUGcMS0Y+sXzanQ+1w65UJCdrU9GRpugL/ThcnNM5j0NWDpqo/7hN1 dVeo3S5MYNFC9/H5dbDQJ8aNqN7xGQ4AsTc5rXW8fQFTNcmY1LG1FuaqsT3qnDVp4Ujh igwLkg5VnoPfyRtlzmZX7sYyJgTimZn4IQ6GFWezPp9YwJHJHe7/k45Pn5BIZ97q3Hja 8a5n92KdRlDfUaD+8YB9wh+gM+/ObKn1qdDMuDvNukbVQAvsaHquUsUuNTWtXbxTXGXv Rdo/NyMpzXyFqgMGDDVR+CLId8jP8ogBBTykz5Dpa5ya1kXZ+sEJ7tOnmWOIRYwc/vB7 LKIA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KezhvmWHAceMf48c2RjqU+c3QYMRgbLMC3J5PF+5DWc=; b=LNE5vR+5sdr4z9MvbLljj/aOf5ioAz0mbpZWVWdGhtYp6djd0DZnf02th4ppbP36dm 7dD+dPgwinKaLR/o92kBp8a+r3H5zNCFg5g6BpKO9TbxTpN1S+j65JJZb2Ie1EGLN7Ag 5c30Rd8g6JvZUoDtbiXHEIeYxwv7NsGGMis//hGMjt3dPE9NYcoGqbPNFeh3N3fg6kA5 +O19VLQRTM8ItcGsZgqV/02omCwWYUiURutlHnkxftyCtFwmtRcx/6skk6LRyjQXvEjn iPVv9YqzJgTDHuIRBP/UApZM9b1HR2tWOtWk5JjKnFHDSFGuntAzgYWJ0/PGzUe7FQYM rFBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si5274310edr.76.2020.05.17.15.02.52; Sun, 17 May 2020 15:03:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbgEQWBa (ORCPT + 99 others); Sun, 17 May 2020 18:01:30 -0400 Received: from gloria.sntech.de ([185.11.138.130]:45200 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgEQWBa (ORCPT ); Sun, 17 May 2020 18:01:30 -0400 Received: from ip5f5aa64a.dynamic.kabel-deutschland.de ([95.90.166.74] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jaRLU-0002e6-TF; Mon, 18 May 2020 00:01:20 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Lukas Wunner Cc: gregkh@linuxfoundation.org, jslaby@suse.com, andriy.shevchenko@linux.intel.com, matwey.kornilov@gmail.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, christoph.muellner@theobroma-systems.com, giulio.benetti@micronovasrl.com Subject: Re: [PATCH v2 4/7] serial: 8250: Handle implementations not having TEMT interrupt using em485 Date: Mon, 18 May 2020 00:01:20 +0200 Message-ID: <2596761.4mVKVPr5sX@diego> In-Reply-To: <20200502134927.6sb7f3na3ff3rpoa@wunner.de> References: <20200325231422.1502366-1-heiko@sntech.de> <20200325231422.1502366-5-heiko@sntech.de> <20200502134927.6sb7f3na3ff3rpoa@wunner.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lukas, Am Samstag, 2. Mai 2020, 15:49:27 CEST schrieb Lukas Wunner: > On Thu, Mar 26, 2020 at 12:14:19AM +0100, Heiko Stuebner wrote: > > @@ -1529,11 +1535,22 @@ static inline void __stop_tx(struct uart_8250_port *p) > > /* > > * To provide required timeing and allow FIFO transfer, > > * __stop_tx_rs485() must be called only when both FIFO and > > - * shift register are empty. It is for device driver to enable > > - * interrupt on TEMT. > > + * shift register are empty. If 8250 port supports it, > > + * it is for device driver to enable interrupt on TEMT. > > + * Otherwise must loop-read until TEMT and THRE flags are set. > > */ > > - if ((lsr & BOTH_EMPTY) != BOTH_EMPTY) > > - return; > > + if (p->capabilities & UART_CAP_TEMT) { > > + if ((lsr & BOTH_EMPTY) != BOTH_EMPTY) > > + return; > > + } else { > > + int lsr; > > + > > + if (readx_poll_timeout(__get_lsr, p, lsr, > > + (lsr & BOTH_EMPTY) == BOTH_EMPTY, > > + 0, 10000) < 0) > > + pr_warn("%s: timeout waiting for fifos to empty\n", > > + p->port.name); > > + } > > Do you actually need to check for the timeout? How could this happen? > Only if some other part of the driver would disable the transmitter > I guess, which would be a bug. Checking for a timeout was strongly suggested in v1 ;-) > Also, note that __stop_tx() may be called from hardirq context via > serial8250_tx_chars(). If the baudrate is low, you may spin for a > fairly long time in IRQ context. E.g. with 9600 8N1, it takes about > 1 msec for one char to transmit. I did play around with different baud rates and data amounts today and even ran into the timeout with the current 10ms when doing a "dmesg > /dev/ttyS3" ... combined with the hardirq issue you mentioned I think I found a slightly better variant to do this ... by catching the first 100us in the interrupt handler and otherwise re-using the existing stop-timer infrastructure to move this out of the actual __stop_tx function. I've sent a v3 based on your new series just now ... if you find time please have a look :-) Thanks Heiko