Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1185697ybi; Fri, 2 Aug 2019 10:44:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDViOdx2/eFSpbPVPfsB8YCmp12xxbLOkhgy73V8QUE+YtyBLcstxaWM2G0StUs6YAPdLy X-Received: by 2002:a63:724b:: with SMTP id c11mr46817866pgn.30.1564767883245; Fri, 02 Aug 2019 10:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564767883; cv=none; d=google.com; s=arc-20160816; b=pO34hD0VdzyXHha/fbPY6iqd3yPMloJ+9TxmCh9oX2R3T4cQHS/FfOG6bVvLrdOfPu m2aGRmS6VmHUYdC5VyeI3+mLP3JnqvNzSgPWOb/o+X8hq6MNh3C8xVO28r8no7gHcQLj opvT0SHkfZe/It7/3/6dS83aSS3H2LoPeBr6nZAkAJcY3Hz+CI2gUWOxc3ZvT7qbXv/Q eLE2nZLdIYSKh56EyxSo/PlJTDGLfGaZ0eZkPlxB8hbjVeVA282JREQ7tqL3rexKHqc+ lso6qHhMFvrqmEG22I6qpKUrIsriV8PRhAOoTNzHpFOsy5sLbUkh76SXX9k8cpLEN8WY I4kA== 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=L7Aekej2ZfpJ7POt8UHYEKw0wX6M8FjuTbt66aK8NI8=; b=SYgCy9qQi53F0Z19Yk5zN39gVnQ8dmnthilvPpN4PCCOV3H05L1uizUDFgECMlatU7 D624ceGRNOrk9Jch7h740w0w3u2jcY0brmegyJ0ce6o/PZuLlaod6wDVe+lMwkDD0n5Z 7VvoBu7CaZMJD0m/t/wufkEfa8/VQghWMovSwMtzWx94Fpdub4f5ysqtI1cOIu+SLRKP ez/xu2tQSaOqs7dUDcFTsZnV0oDcMJ4xsy3g6qR/jDBa6n3XQs8/q9kzhaQCZPIAdZSK AwBihV/VdF/mrDmg7Ib6ElhjoypOwELjFcAYCzD/JNjtmqWVNye1WSAFsPPPG96fBBN+ 7P9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TJeiyNCz; 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 f15si36146854plr.260.2019.08.02.10.44.27; Fri, 02 Aug 2019 10:44:43 -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=TJeiyNCz; 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 S2405933AbfHBJsv (ORCPT + 99 others); Fri, 2 Aug 2019 05:48:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:54364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405920AbfHBJss (ORCPT ); Fri, 2 Aug 2019 05:48:48 -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 C7A9F206A2; Fri, 2 Aug 2019 09:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739328; bh=uaG/nocy+VuJbNmkPLj0hukthBq5FUvJyceyfyA9W0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJeiyNCzW1XhKUdvExY6ipGTM+i2qfl7q9VzlMVTO+ZPtzShyQ7xu2tCGwubsGx9a 9LgXdS62sr5D++FyMm1oc+ExbXhCvOFPFa99KNLawxHl+mDU3NMEWFUyGGgOYfEtgc 1q1FdCRqOtSyo9zCIAc1i0q1pZRdM1/n4raXPerQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kimmo Rautkoski , Sasha Levin Subject: [PATCH 4.9 169/223] serial: 8250: Fix TX interrupt handling condition Date: Fri, 2 Aug 2019 11:36:34 +0200 Message-Id: <20190802092248.929363205@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 84474f06dbcf..8f1233324586 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1819,7 +1819,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); spin_unlock_irqrestore(&port->lock, flags); -- 2.20.1