Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3798169ybi; Mon, 29 Jul 2019 12:50:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjGuPhJvM4uKU0c4XnksewDGZXfizNqVufMoq9t6e3uMnMwoNfXBsXi/pq5t6N/KELfpbe X-Received: by 2002:a17:902:704c:: with SMTP id h12mr106713997plt.318.1564429821121; Mon, 29 Jul 2019 12:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429821; cv=none; d=google.com; s=arc-20160816; b=h1YfyWzFYfHDH9M0HHiVmaIpfmTHRQJOdAmJXC8fvnxvXghHL2jw6AWy2JH0Un0QsN TXWVnc/P+vgSIssNkkS+w31cCAe4gGegJ5GcuH3JO8dV6zGUiFGPocbzdPajIkbEZQur 31Oppbd4LftVesGaeoNWGT7eR6pyqUolGCnjopaSMOAijBz0eGuSwxO30xM5VUWvrBBh DR0BGfcWDJYzS6LGp1xkmCfMts3oeCZmWAqy0ECKRt+uZfD1WN1bHSIRPeZQ2f32s5Gm oxoT4BYfTpf9PzNU5C1R92WnUyKqrWIEWStCu3YjjNHgYVzz5IZ00Z5y6p7Lg9VkR89Z ahcg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VgP1Ot6XKJHCv2RuxcjAOasNk7sGNY5U6wouUviq+w4=; b=emtjZDjO3w6/gKnHoMXT2EIIpPPC8OXYFeIhGB09J15zqeAJkB+cfZ+luXrjqbiqCh fyDUh2cNeqEiqezJ62QLPqH/ttABpZz72dRXMHwcljULLFn/sj4/SIArxrKitGXET7+0 ONi1flZoNNvc5ywXj1f3JA9kYeb3W78jzgP00PoKofCVI06FvyKWkO0mYsWe60l0dQuy TxAViBZqqipZVShD9SqOQvwu30unvpnUHzX3KjmYG5UMCdH6CDeYf7BhJdUgMxzoeLzW TKCXyF6PWkdeJyZ2q+VwyjP0OVglQjaBMken9BL7O8FUK7DecKLGT9kSMCmkHi1RFLUD EuRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FoRGB1gH; 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 a16si25748751pgw.156.2019.07.29.12.50.06; Mon, 29 Jul 2019 12:50:21 -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; dkim=pass header.i=@kernel.org header.s=default header.b=FoRGB1gH; 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 S2390359AbfG2Trp (ORCPT + 99 others); Mon, 29 Jul 2019 15:47:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:37334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389978AbfG2Trf (ORCPT ); Mon, 29 Jul 2019 15:47:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 141FC20C01; Mon, 29 Jul 2019 19:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429654; bh=ue65A/VHffRhGxa92M9SL1+8Tm3NdmZW+uzUza6JSTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FoRGB1gHhhFp8Q8P5V0dsFDoBFdvK3wwfaeuDBC91jYyhbpKiO1Vpnkgb1xSH4hmT ssENsXRl4y7aHi+nXAMo5MprL1y+NGRL2w3i5mJHjK+cXfTtpgMHgp1Dxa7x8X755j rBluCRwrAl8Yl5tSLv+4O6m+QRUUkLiOwi4nqvVU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kimmo Rautkoski , Sasha Levin Subject: [PATCH 5.2 052/215] serial: 8250: Fix TX interrupt handling condition Date: Mon, 29 Jul 2019 21:20:48 +0200 Message-Id: <20190729190749.568119012@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit db1b5bc047b3cadaedab3826bba82c3d9e023c4b ] Interrupt handler checked THRE bit (transmitter holding register empty) in LSR to detect if TX fifo is empty. In case when there is only receive interrupts the TX handling got called because THRE bit in LSR is set when there is no transmission (FIFO empty). TX handling caused TX stop, which in RS-485 half-duplex mode actually resets receiver FIFO. This is not desired during reception because of possible data loss. The fix is to check if THRI is set in IER in addition of the TX fifo status. THRI in IER is set when TX is started and cleared when TX is stopped. This ensures that TX handling is only called when there is really transmission on going and an interrupt for THRE and not when there are only RX interrupts. Signed-off-by: Kimmo Rautkoski Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 682300713be4..eb2e2d141c01 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1874,7 +1874,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) status = serial8250_rx_chars(up, status); } serial8250_modem_status(up); - if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE)) + if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE) && + (up->ier & UART_IER_THRI)) serial8250_tx_chars(up); uart_unlock_and_check_sysrq(port, flags); -- 2.20.1