Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2806755ybk; Mon, 18 May 2020 08:21:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3ky2z34Y9fKJ69awXNIT0F7zFBTewlmLCr+/S0/bgSjFkdE3Z3zFtq9//S8ww2axiIMYn X-Received: by 2002:a17:906:3095:: with SMTP id 21mr14928571ejv.32.1589815310067; Mon, 18 May 2020 08:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589815310; cv=none; d=google.com; s=arc-20160816; b=X0JhhDn+kUr7PyJohKd9LBrgnpfPdXgSbbuyr4snhFVW+mwVM7aumYGTMxzX4zX+LZ 37Ln3r4OO42f6pM9Pd8B9dk3P5cjzeOGoHaGgqTbWyfN0gxD0lVSZNIQ6T0+N6bh0mGb IkdtTzRFJsFHAfuMhwGfzA3iLETINMFLlkOHO0ETGq5QscHgTm/OKN7Ral91ZwgNUJYc DfPYixUaSe49NhSe7yHnecMXYLh9zllIBrRcVq1HA37PGk+aAfOuJObT9FpxkPEaTHo7 KCXnepN479X5yvdYbEyvAs6EtMB034zx5Shfzu1gjpE5euJ4zip3YswlyJvLgMSmTkNJ dzmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=Wyb+nDC3NVmQ/xvV6a9MVbZw0m16b7Zvv+8LGLcCU3A=; b=xxUpvCfuFGC6tsP9Pqp8EG4fKP17rxPgRRFbAqXXhbCCOMrjSSyLqgUnfvmDS/wAwe 7pV+bDZuXwpy0bYfIzY1nd708qYX1/QjIjjLoHChhR0Top9cJduYrNUsVinnSRgFItQC x6V7wl2IiAN+5HHuYGR/opCFhsrNKADtxzZgqnWg/wxNAFqO6qvKtvnK5xqrw+qvKT/h H4caDtVDRSTZfKXc0xHNq7V1+4EUX5+Mxbs5WmMtzAkBsSFz44fZWZNq8q+ZEMJ5+Wpg YanH67Cq4Ku1PFOzoIfffoXvMNYNfhgI7S78jpV/hEoW7FaYvuuxwTISdLvet1ObFWpS keaA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si1254306edu.369.2020.05.18.08.21.25; Mon, 18 May 2020 08:21:50 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728231AbgERPT3 (ORCPT + 99 others); Mon, 18 May 2020 11:19:29 -0400 Received: from mga14.intel.com ([192.55.52.115]:41250 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726918AbgERPT3 (ORCPT ); Mon, 18 May 2020 11:19:29 -0400 IronPort-SDR: 5du6UNZm67WGDdjaoay2zBAu/WerH0Jy8smlnwrcBslXjftYr0wglQxuhib8WSbgUbfpy2GMqB JR+35kQ3iF/g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 08:19:28 -0700 IronPort-SDR: U8tanuJZgItrxDVxI2EQNOWz4OZSaCzMnY/DJOBY0uYWX7O9+e3eSF+9xgdC8+5g0KD6f9giHY Ae5WAxSPTknQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="342825873" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga001.jf.intel.com with ESMTP; 18 May 2020 08:19:25 -0700 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1jahY8-007S4o-AU; Mon, 18 May 2020 18:19:28 +0300 Date: Mon, 18 May 2020 18:19:28 +0300 From: Andy Shevchenko To: Heiko Stuebner Cc: gregkh@linuxfoundation.org, jslaby@suse.com, matwey.kornilov@gmail.com, giulio.benetti@micronovasrl.com, lukas@wunner.de, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, christoph.muellner@theobroma-systems.com, Heiko Stuebner Subject: Re: [PATCH v3 4/5] serial: 8250: Handle implementations not having TEMT interrupt using em485 Message-ID: <20200518151928.GH1634618@smile.fi.intel.com> References: <20200517215610.2131618-1-heiko@sntech.de> <20200517215610.2131618-5-heiko@sntech.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200517215610.2131618-5-heiko@sntech.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 17, 2020 at 11:56:09PM +0200, Heiko Stuebner wrote: > From: Giulio Benetti > > Some 8250 ports have a TEMT interrupt but it's not a part of the 8250 > standard, instead only available on some implementations. > > The current em485 implementation does not work on ports without it. > The only chance to make it work is to loop-read on LSR register. > > So add UART_CAP_TEMT to mark 8250 uarts having this interrupt, > update all current em485 users with that capability and add > a loop-reading during __stop_tx_rs485() on uarts not having it. > > As __stop_tx_rs485() can also be called from a hard-irq context the > loop-reading is split. If the fifo clears in under 100us in > __stop_tx_rs485() itself just the regular stop calls get executed. > If it takes longer, re-use the existing stop-timer infrastructure > but with only a 10us timer to again poll the LSR registers. > > Signed-off-by: Giulio Benetti > [moved to use added UART_CAP_TEMT, use readx_poll_timeout] I can't parse first part... Also, shouldn't it be rather like [heiko: ...] ? ... > +static inline int __get_lsr(struct uart_8250_port *p) > +{ > + return serial_in(p, UART_LSR); > +} > + > +static inline int __wait_for_empty(struct uart_8250_port *p, u64 timeout_us) > +{ > + int lsr; > + > + return readx_poll_timeout(__get_lsr, p, lsr, > + (lsr & BOTH_EMPTY) == BOTH_EMPTY, > + 0, timeout_us); > +} ... > + int ret = __wait_for_empty(p, 100); Do you expect something different than 100? If no, perhaps for now just put it inside the function as a constant? > + if (ret < 0) { > + restart = HRTIMER_RESTART; > + goto out; > + } ... > + } else if (!(p->capabilities & UART_CAP_TEMT) && > + __wait_for_empty(p, 100)) { I would leave it on one line even if you leave 100 as a parameter, but it's up to you. ... > + if (p->capabilities & UART_CAP_TEMT) { > + if ((lsr & BOTH_EMPTY) != BOTH_EMPTY) > + return; > + } if (a) { if (b) { ... } } is equivalent to if (a && b) { ... } But it's up to you which one to choose. -- With Best Regards, Andy Shevchenko