Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3098283ybi; Thu, 18 Jul 2019 21:00:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdYlrwVJGjgvQZRvFgpHqibC2qNZpAL9nS4OuTK/mEjg9N3BfUWnqMOeBOttNve8eBPEXZ X-Received: by 2002:a63:3203:: with SMTP id y3mr52189746pgy.191.1563508823411; Thu, 18 Jul 2019 21:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508823; cv=none; d=google.com; s=arc-20160816; b=UeeybPcrcTTj8CwD3kj9JsCrDFPvXLmlwwlduPgxdiSID5bSQtUJa6d+PR7gq9dDNF IjvADy9cmOT7BBezZdUoqp12M24L+JLCJEKELBBcT/8oZMEenGiw1WCpG5vLVgg3Rddj UAlprdKBFOu260U9tIAEOBHevNzDzu3sVhdzwa7TzbcsHTfbKTOnoFSO57QsjOncHR+C 5Cimv1e/uF6B6LlRaYFsPKncwxbVXDqhuuzzpM0LBYZrQVsX5IYCgsOdfH1MgZXahQfH sJTqx1ujL5pP3gVRMhXKIdlnZzaCJMekSmhgCTfc+cQvmV1n8ReN2ew9y4qgG5J64yXU JCoQ== 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 :dkim-signature; bh=7mUjE46xMg8+Z5kWkBmlGEOm6/8gaqEQZ+c9tvR0b+g=; b=l1FzS+mDgW9lxA0asPOeoVC14guabX0iHyimh4NnSY6sR3X+YoePuiXe2kTZ2dSl8B EHLfGBxyQJchRzpwQ38yuNJDa0SwOm/3m6ruSfvJbtZ5Jts9FW+RiQUNed7BW1l4dyIT i5aVXM+1JtV43ewdjPZZNAFDsE1nRasVQFL+4oqt8DDpwexp5YCK5toeYmKq7jiU95Ei k8qZzUtvd3K2f7Fp6az2oH2mDa1AXHWd8HG8UoEqQZ6G0gb51ZV3+3wpllaFgSMJJYqM +oz9sROjFYfNTdwRCQV+TCxxuP/NrBMGZBcOG7bb4QRB56w2csci8/7Fodm7w/7/2yh5 jQoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mKK8Lo2T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cn1si1808614plb.204.2019.07.18.21.00.07; Thu, 18 Jul 2019 21:00:23 -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=mKK8Lo2T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727011AbfGSD6k (ORCPT + 99 others); Thu, 18 Jul 2019 23:58:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728175AbfGSD6h (ORCPT ); Thu, 18 Jul 2019 23:58:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9666121871; Fri, 19 Jul 2019 03:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508716; bh=GLbL3FyzfUad1Fjle5j4mAmrF0o2jqKJECEIfieDOOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKK8Lo2T32npFi3889HRDI7uWhdmnyRQeKoVfRVQoFCxPsLi1t+9LUw/f33+q8uHa aYBQYKTuN8tbrHwJLrzUZkn40lB0V6IyUUJlV+TX99m8TAizhEqvLuca1yv5XL8czh CTxUkZUcGdcOMzYBzRSEAsd3PGw9KX/qOP+bwz88= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rautkoski Kimmo EXT , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 050/171] serial: 8250: Fix TX interrupt handling condition Date: Thu, 18 Jul 2019 23:54:41 -0400 Message-Id: <20190719035643.14300-50-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rautkoski Kimmo EXT [ 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